From ab99c178e1a587f301ecad0e34b8bdb57e552469 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 1 Jun 2017 09:04:20 +0200 Subject: [PATCH 001/342] Print the value of fields Add a loop for printing the value of fields --- dev/skeletons/skeleton_list.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 4453f2d8302..7053486234f 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2016 Jean-François Ferry + * Copyright (C) 2017 Nicolas ZABOURI * * 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 @@ -440,17 +441,14 @@ while ($i < min($num, $limit)) // Show here line of result print ''; // LIST_OF_TD_FIELDS_LIST - /* - if (! empty($arrayfields['t.field1']['checked'])) - { - print ''.$obj->field1.''; - if (! $i) $totalarray['nbfield']++; + foreach ($arrayfields as $key => $value) { + if (!empty($arrayfields[$key]['checked'])) { + $key2 = str_replace('t.', '', $key); + print '' . $obj->$key2 . ''; + if (!$i) + $totalarray['nbfield'] ++; + } } - if (! empty($arrayfields['t.field2']['checked'])) - { - print ''.$obj->field2.''; - if (! $i) $totalarray['nbfield']++; - }*/ // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { From 0e175ba3737f1120b0ef6d5ce84c483f15ffa594 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 1 Jun 2017 11:48:14 +0200 Subject: [PATCH 002/342] Fix : SEPA XML address should also have dolEscapeXML --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index dd6b773af9f..134e125b067 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1565,7 +1565,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.strtoupper(dolEscapeXML(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - $XML_DEBITOR .=' '.dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true).''.$CrLf; + $XML_DEBITOR .=' '.dol_trunc(dolEscapeXML(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")))),70,'right','UTF-8',true).''.$CrLf; $XML_DEBITOR .=' '.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; From 6787d717f915be421949ef03b97983088940529a Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 3 Jun 2017 18:23:19 +0200 Subject: [PATCH 003/342] Update bonprelevement.class.php --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 134e125b067..a63708bfe6a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1565,7 +1565,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.strtoupper(dolEscapeXML(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - $XML_DEBITOR .=' '.dol_trunc(dolEscapeXML(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")))),70,'right','UTF-8',true).''.$CrLf; + $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")))),70,'right','UTF-8',true).''.$CrLf; $XML_DEBITOR .=' '.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; From ca5fd6ac4cd986ccdde6e5634f1e3d5105f5ab6f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 6 Jun 2017 09:15:11 +0200 Subject: [PATCH 004/342] FIX #6926 --- htdocs/contrat/class/contrat.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9878e08d447..a1696c749f8 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -46,7 +46,7 @@ class Contrat extends CommonObject public $fk_element='fk_contrat'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='contract'; - + /** * {@inheritdoc} */ @@ -609,7 +609,7 @@ class Contrat extends CommonObject $this->lines=array(); $pos = 0; - + // Selectionne les lignes contrats liees a un produit $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; @@ -1849,7 +1849,7 @@ class Contrat extends CommonObject $url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id; $picto = 'contract'; $label = ''; - + if ($user->rights->contrat->lire) { $label = ''.$langs->trans("ShowContract").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; @@ -1865,7 +1865,7 @@ class Contrat extends CommonObject $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } } - + $linkclose=''; if (empty($notooltip) && $user->rights->contrat->lire) { @@ -1881,7 +1881,7 @@ class Contrat extends CommonObject $linkstart = ''; $linkend=''; - + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; $result.=$linkstart.$this->ref.$linkend; @@ -2911,7 +2911,7 @@ class ContratLigne extends CommonObjectLine // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,"; + $sql.= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; $sql.= " info_bits,"; From 3e51d2f537b6b052b939fd973f382edc8b8d1a03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jun 2017 11:51:22 +0200 Subject: [PATCH 005/342] Fix backto link after creating a third party --- htdocs/core/class/html.form.class.php | 2 +- htdocs/societe/card.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e4f6ec7bbcb..7a69172889e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5760,7 +5760,7 @@ class Form $disabled = ($disabled ? ' disabled' : ''); $resultyesno = ''; - if (GETPOST("type") == '') print ''; + if (GETPOST("type") == '') print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print ''; if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print ''; From 543630e4876e835122a081dd5f522134e0c6a0fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jun 2017 12:21:41 +0200 Subject: [PATCH 006/342] Fix missing count of nb of columns into lists --- htdocs/contact/list.php | 20 +++++- htdocs/core/lib/functions.lib.php | 2 +- htdocs/product/list.php | 82 ++++++++++++++-------- htdocs/projet/card.php | 33 ++++++--- htdocs/projet/class/project.class.php | 14 ++++ htdocs/projet/list.php | 75 +++++++++++---------- htdocs/resource/list.php | 97 +++++++++++++-------------- htdocs/societe/list.php | 32 ++++++++- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- htdocs/user/index.php | 22 +++++- 11 files changed, 248 insertions(+), 133 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 2d46b91f922..ad71eb3786f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -682,6 +682,7 @@ print "\n"; $i = 0; +$totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); @@ -706,56 +707,67 @@ while ($i < min($num,$limit)) print ''; print $contactstatic->getNomUrl(1,'',0); print ''; + if (! $i) $totalarray['nbfield']++; } // Firstname if (! empty($arrayfields['p.firstname']['checked'])) { print ''.$obj->firstname.''; + if (! $i) $totalarray['nbfield']++; } // Zip if (! empty($arrayfields['p.zip']['checked'])) { print ''.$obj->zip.''; + if (! $i) $totalarray['nbfield']++; } // Town if (! empty($arrayfields['p.town']['checked'])) { print ''.$obj->town.''; + if (! $i) $totalarray['nbfield']++; } // Function if (! empty($arrayfields['p.poste']['checked'])) { print ''.dol_trunc($obj->poste,20).''; + if (! $i) $totalarray['nbfield']++; } // Phone if (! empty($arrayfields['p.phone']['checked'])) { print ''.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''; + if (! $i) $totalarray['nbfield']++; } // Phone perso if (! empty($arrayfields['p.phone_perso']['checked'])) { print ''.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''; + if (! $i) $totalarray['nbfield']++; } // Phone mobile if (! empty($arrayfields['p.phone_mobile']['checked'])) { print ''.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''; + if (! $i) $totalarray['nbfield']++; } // Fax if (! empty($arrayfields['p.fax']['checked'])) { print ''.dol_print_phone($obj->fax,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').''; + if (! $i) $totalarray['nbfield']++; } // EMail if (! empty($arrayfields['p.email']['checked'])) { print ''.dol_print_email($obj->email,$obj->rowid,$obj->socid,'AC_EMAIL',18).''; + if (! $i) $totalarray['nbfield']++; } // Skype if (! empty($arrayfields['p.skype']['checked'])) { if (! empty($conf->skype->enabled)) { print ''.dol_print_skype($obj->skype,$obj->rowid,$obj->socid,'AC_SKYPE',18).''; } + if (! $i) $totalarray['nbfield']++; } // Company if (! empty($arrayfields['p.thirdparty']['checked'])) @@ -770,12 +782,14 @@ while ($i < min($num,$limit)) else print ' '; print ''; + if (! $i) $totalarray['nbfield']++; } // Private/Public if (! empty($arrayfields['p.priv']['checked'])) { print ''.$contactstatic->LibPubPriv($obj->priv).''; + if (! $i) $totalarray['nbfield']++; } // Extra fields @@ -792,6 +806,7 @@ while ($i < min($num,$limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -805,6 +820,7 @@ while ($i < min($num,$limit)) print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) @@ -812,11 +828,13 @@ while ($i < min($num,$limit)) print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['p.statut']['checked'])) { print ''.$contactstatic->getLibStatut(3).''; + if (! $i) $totalarray['nbfield']++; } // Action column @@ -829,7 +847,7 @@ while ($i < min($num,$limit)) } print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5113c9f1d96..92cb35e02f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3692,7 +3692,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) * @param float $amount Amount to format * @param integer $form Type of format, HTML or not (not by default) * @param Translate $outlangs Object langs for output - * @param int $trunc 1=Truncate if there is too much decimals (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before inserted into database or after a computation, so this parameter should be useless. + * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before inserted into database or after a computation, so this parameter should be useless. * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL) * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 2b3657070e4..2afa8438e73 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -179,7 +179,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]); } @@ -219,16 +219,16 @@ if (empty($reshook)) $search_accountancy_code_buy=''; $search_array_options=array(); } - + // Mass actions $objectclass='Product'; if ((string) $search_type == '1') { $objectlabel='Services'; } if ((string) $search_type == '0') { $objectlabel='Products'; } - + $permtoread = $user->rights->produit->lire; $permtodelete = $user->rights->produit->supprimer; $uploaddir = $conf->product->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -324,7 +324,7 @@ else $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -361,7 +361,7 @@ else $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); @@ -415,8 +415,8 @@ else $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - + } + // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -425,7 +425,7 @@ else if ($user->rights->produit->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + print '
'; if ($optioncss != '') print ''; print ''; @@ -473,7 +473,7 @@ else foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + // Filter on categories $moreforfilter=''; if (! empty($conf->categorie->enabled)) @@ -505,10 +505,10 @@ else $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); - + print '
'; print ''."\n"; - + // Lines with input filters print ''; if (! empty($arrayfields['p.ref']['checked'])) @@ -591,7 +591,7 @@ else // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { if (! empty($arrayfields["ef.".$key]['checked'])) print ''; } @@ -668,12 +668,13 @@ else if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - + + $product_static=new Product($db); $product_fourn =new ProductFournisseur($db); $i = 0; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -721,6 +722,7 @@ else print '\n"; + if (! $i) $totalarray['nbfield']++; } // Ref supplier if (! empty($arrayfields['pfp.ref_fourn']['checked'])) @@ -728,24 +730,28 @@ else print '\n"; + if (! $i) $totalarray['nbfield']++; } // Label if (! empty($arrayfields['p.label']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } - + // Type if (! empty($arrayfields['p.fk_product_type']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } - + // Barcode if (! empty($arrayfields['p.barcode']['checked'])) { print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Duration if (! empty($arrayfields['p.duration']['checked'])) @@ -761,6 +767,7 @@ else else print $obj->duration; } print ''; + if (! $i) $totalarray['nbfield']++; } // Sell price @@ -773,6 +780,7 @@ else else print price($obj->price).' '.$langs->trans("HT"); } print ''; + if (! $i) $totalarray['nbfield']++; } // Better buy price @@ -796,6 +804,7 @@ else } } print ''; + if (! $i) $totalarray['nbfield']++; } // Limit alert @@ -807,6 +816,7 @@ else print $obj->seuil_stock_alerte; } print ''; + if (! $i) $totalarray['nbfield']++; } // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) @@ -817,6 +827,7 @@ else print $obj->desiredstock; } print ''; + if (! $i) $totalarray['nbfield']++; } // Stock if (! empty($arrayfields['p.stock']['checked'])) @@ -828,7 +839,8 @@ else print $product_static->stock_reel; } print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Stock if (! empty($arrayfields['stock_virtual']['checked'])) { @@ -839,24 +851,34 @@ else print $product_static->stock_theorique; } print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Lot/Serial if (! empty($arrayfields['p.tobatch']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); @@ -865,6 +887,7 @@ else $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -878,6 +901,7 @@ else print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) @@ -885,8 +909,9 @@ else print ''; - } - + if (! $i) $totalarray['nbfield']++; + } + // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { @@ -897,6 +922,7 @@ else print $product_static->LibStatut($obj->tosell,5,0); } print ''; + if (! $i) $totalarray['nbfield']++; } // Status (to buy) if (! empty($arrayfields['p.tobuy']['checked'])) @@ -908,6 +934,7 @@ else print $product_static->LibStatut($obj->tobuy,5,1); } print ''; + if (! $i) $totalarray['nbfield']++; } // Action print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; $i++; } - + $db->free($resql); print "
'; print $product_static->getNomUrl(1,'',24); print "'; print $product_static->getNomUrl(1,'',24); print "'.dol_trunc($obj->label,40).''.$obj->fk_product_type.''.$obj->barcode.''; print yn($obj->tobatch); print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''.$obj->accountancy_code_buy.''; print dol_print_date($obj->date_creation, 'dayhour'); print ''; print dol_print_date($obj->date_update, 'dayhour'); print ''; @@ -918,11 +945,12 @@ else print ''; } print '
"; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0b45a0d0696..174d93f4aef 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -41,6 +41,7 @@ $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $backtopage=GETPOST('backtopage','alpha'); $cancel=GETPOST('cancel','alpha'); +$confirm=GETPOST('confirm','aZ09'); $status=GETPOST('status','int'); $opp_status=GETPOST('opp_status','int'); $opp_percent=price2num(GETPOST('opp_percent','alpha')); @@ -68,7 +69,7 @@ if ($id > 0 || ! empty($ref)) } // Security check -$socid=GETPOST('socid'); +$socid=GETPOST('socid','int'); //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $object->id,'projet&project'); @@ -135,6 +136,12 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } + // Create with status validated immediatly + if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT)) + { + $status=Project::STATUS_VALIDATED; + } + if (! $error) { $error=0; @@ -148,10 +155,10 @@ if (empty($reshook)) $object->public = GETPOST('public','alpha'); $object->opp_amount = price2num(GETPOST('opp_amount')); $object->budget_amount = price2num(GETPOST('budget_amount')); - $object->datec=dol_now(); - $object->date_start=$date_start; - $object->date_end=$date_end; - $object->statuts = $status; + $object->datec = dol_now(); + $object->date_start = $date_start; + $object->date_end = $date_end; + $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; @@ -365,7 +372,7 @@ if (empty($reshook)) } - if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') + if ($action == 'confirm_validate' && $confirm == 'yes') { $result = $object->setValid($user); if ($result <= 0) @@ -374,7 +381,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_close' && GETPOST('confirm') == 'yes') + if ($action == 'confirm_close' && $confirm == 'yes') { $result = $object->setClose($user); if ($result <= 0) @@ -383,7 +390,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes') + if ($action == 'confirm_reopen' && $confirm == 'yes') { $result = $object->setValid($user); if ($result <= 0) @@ -409,7 +416,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') + if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { $clone_contacts=GETPOST('clone_contacts')?1:0; $clone_tasks=GETPOST('clone_tasks')?1:0; @@ -885,12 +892,16 @@ elseif ($object->id > 0) // Opportunity percent print ''.$langs->trans("OpportunityProbability").''; - if (strcmp($object->opp_percent,'')) print price($object->opp_percent,0,$langs,1,0).' %'; + if (strcmp($object->opp_percent,'')) print price($object->opp_percent, 0, $langs, 1, 0).' %'; print ''; // Opportunity Amount print ''.$langs->trans("OpportunityAmount").''; - if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency); + /*if ($object->opp_status) + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($object->opp_amount,'')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); print ''; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6a53be25c54..b22ea32f646 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -103,6 +103,20 @@ class Project extends CommonObject */ public $lines; + /** + * Draft status + */ + const STATUS_DRAFT = 0; + /** + * Open/Validated status + */ + const STATUS_VALIDATED = 1; + /** + * Closed status + */ + const STATUS_CLOSED = 2; + + /** * Constructor diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 851956f816b..b9da5379655 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -135,7 +135,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } @@ -186,7 +186,7 @@ if (empty($reshook)) $toselect=''; $search_array_options=array(); } - + // Mass actions $objectclass='Project'; @@ -297,12 +297,12 @@ else if ($search_eyear > 0) $sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'"; } if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -if ($search_status >= 0) +if ($search_status >= 0) { if ($search_status == 99) $sql .= " AND p.fk_statut <> 2"; else $sql .= " AND p.fk_statut = ".$db->escape($search_status); } -if ($search_opp_status) +if ($search_opp_status) { if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL"; @@ -313,7 +313,7 @@ if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; -if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1); // Add where from extra fields @@ -324,7 +324,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -383,8 +383,8 @@ if ($search_ref != '') $param.='&search_ref='.$search_ref; if ($search_label != '') $param.='&search_label='.$search_label; if ($search_societe != '') $param.='&search_societe='.$search_societe; if ($search_status >= 0) $param.='&search_status='.$search_status; -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); -if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent); +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); +if ($search_opp_percent != '') $param.='&search_opp_percent='.urlencode($search_opp_percent); if ($search_public != '') $param.='&search_public='.$search_public; if ($search_project_user != '') $param.='&search_project_user='.$search_project_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; @@ -532,18 +532,18 @@ if (! empty($arrayfields['p.public']['checked'])) print $form->selectarray('search_public',$array,$search_public); print ''; } -if (! empty($arrayfields['p.opp_amount']['checked'])) -{ - print ''; - print ''; - print ''; -} if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100'); print ''; } +if (! empty($arrayfields['p.opp_amount']['checked'])) +{ + print ''; + print ''; + print ''; +} if (! empty($arrayfields['p.opp_percent']['checked'])) { print ''; @@ -620,8 +620,8 @@ if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); -if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'],$_SERVER["PHP_SELF"],'p.opp_percent',"",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'],$_SERVER["PHP_SELF"],'p.budget_amount',"",$param,'align="right"',$sortfield,$sortorder); // Extra fields @@ -661,7 +661,7 @@ while ($i < min($num,$limit)) $object->datee = $db->jdate($obj->date_end); $object->statut = $obj->fk_statut; $object->opp_status = $obj->fk_opp_status; - + $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { @@ -770,20 +770,7 @@ while ($i < min($num,$limit)) print ''; if (! $i) $totalarray['nbfield']++; } - // Opp Amount - if (! empty($arrayfields['p.opp_amount']['checked'])) - { - print ''; - if ($obj->opp_status_code) - { - print price($obj->opp_amount, 1, '', 1, -1, -1, ''); - $totalarray['totalopp'] += $obj->opp_amount; - } - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield']; - } - // Opp Status + // Opp Status if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; @@ -791,11 +778,25 @@ while ($i < min($num,$limit)) print ''; if (! $i) $totalarray['nbfield']++; } + // Opp Amount + if (! empty($arrayfields['p.opp_amount']['checked'])) + { + print ''; + //if ($obj->opp_status_code) + if (strcmp($obj->opp_amount,'')) + { + print price($obj->opp_amount, 1, $langs, 1, -1, -1, ''); + $totalarray['totalopp'] += $obj->opp_amount; + } + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield']; + } // Opp percent if (! empty($arrayfields['p.opp_percent']['checked'])) { print ''; - if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; + if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%'; print ''; if (! $i) $totalarray['nbfield']++; } @@ -803,9 +804,9 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.budget_amount']['checked'])) { print ''; - if ($obj->budget_amount != '') + if ($obj->budget_amount != '') { - print price($obj->budget_amount, 1, '', 1, -1, -1); + print price($obj->budget_amount, 1, $langs, 1, -1, -1); $totalarray['totalbudget'] += $obj->budget_amount; } print ''; @@ -826,9 +827,9 @@ while ($i < min($num,$limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } - if (! $i) $totalarray['nbfield']++; } // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); @@ -866,7 +867,7 @@ while ($i < min($num,$limit)) } print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; } @@ -887,8 +888,8 @@ if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield'] if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; } - elseif ($totalarray['totaloppfield'] == $i) print ''.price($totalarray['totalopp']).''; - elseif ($totalarray['totalbudgetfield'] == $i) print ''.price($totalarray['totalbudget']).''; + elseif ($totalarray['totaloppfield'] == $i) print ''.price($totalarray['totalopp'], 1, $langs, 1, -1, -1).''; + elseif ($totalarray['totalbudgetfield'] == $i) print ''.price($totalarray['totalbudget'], 1, $langs, 1, -1, -1).''; else print ''; } print ''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 44524cd7acd..d157cfc99d2 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -257,66 +257,63 @@ if ($ret) { foreach ($object->lines as $resource) { - + print ''; - $style=''; - if ($resource->id == GETPOST('lineid')) $style='style="background: orange;"'; + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + print $resource->getNomUrl(5); + print ''; + if (! $i) $totalarray['nbfield']++; + } - print ''; + if (! empty($arrayfields['ty.label']['checked'])) + { + print ''; + print $resource->type_label; + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } - if (! empty($arrayfields['t.ref']['checked'])) - { - print ''; - print $resource->getNomUrl(5); - print ''; - } + print ''; + print ''; + print img_edit(); + print ''; + print ' '; + print ''; + print img_delete(); + print ''; + print ''; + if (! $i) $totalarray['nbfield']++; - if (! empty($arrayfields['ty.label']['checked'])) - { - print ''; - print $resource->type_label; - print ''; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1); - print ''; - } - } - if (! $i) $totalarray['nbfield']++; - } - - print ''; - print ''; - print img_edit(); - print ''; - print ' '; - print ''; - print img_delete(); - print ''; - print ''; - - print ''; + print ''; } - - print ''; - print "\n"; } else { print ''.$langs->trans('NoResourceInDatabase').''; } -llxFooter(); +print ''; +print "\n"; +llxFooter(); $db->close(); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 28d6ec27368..3cbd8768e92 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -247,7 +247,7 @@ if (empty($reshook)) $permtodelete = $user->rights->societe->supprimer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + if ($action == 'setstcomm') { $object = new Client($db); @@ -930,6 +930,7 @@ print "\n"; $i = 0; +$totalarray=array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -955,46 +956,55 @@ while ($i < min($num, $limit)) print ''; print $companystatic->getNomUrl(1,'',100); print "\n"; + if (! $i) $totalarray['nbfield']++; } // Barcode if (! empty($arrayfields['s.barcode']['checked'])) { print ''.$obj->barcode.''; + if (! $i) $totalarray['nbfield']++; } // Customer code if (! empty($arrayfields['s.code_client']['checked'])) { print ''.$obj->code_client.''; + if (! $i) $totalarray['nbfield']++; } // Supplier code if (! empty($arrayfields['s.code_fournisseur']['checked'])) { print ''.$obj->code_fournisseur.''; + if (! $i) $totalarray['nbfield']++; } // Account customer code if (! empty($arrayfields['s.code_compta']['checked'])) { print ''.$obj->code_compta.''; + if (! $i) $totalarray['nbfield']++; } // Account supplier code if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) { print ''.$obj->code_compta_fournisseur.''; + if (! $i) $totalarray['nbfield']++; } // Town if (! empty($arrayfields['s.town']['checked'])) { print "".$obj->town."\n"; + if (! $i) $totalarray['nbfield']++; } // Zip if (! empty($arrayfields['s.zip']['checked'])) { print "".$obj->zip."\n"; + if (! $i) $totalarray['nbfield']++; } // State if (! empty($arrayfields['state.nom']['checked'])) { print "".$obj->state_name."\n"; + if (! $i) $totalarray['nbfield']++; } // Country if (! empty($arrayfields['country.code_iso']['checked'])) @@ -1003,6 +1013,7 @@ while ($i < min($num, $limit)) $tmparray=getCountry($obj->fk_pays,'all'); print $tmparray['label']; print ''; + if (! $i) $totalarray['nbfield']++; } // Type ent if (! empty($arrayfields['typent.code']['checked'])) @@ -1011,42 +1022,52 @@ while ($i < min($num, $limit)) if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.email']['checked'])) { print "".$obj->email."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.phone']['checked'])) { print "".$obj->phone."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.url']['checked'])) { print "".$obj->url."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.siren']['checked'])) { print "".$obj->idprof1."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.siret']['checked'])) { print "".$obj->idprof2."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.ape']['checked'])) { print "".$obj->idprof3."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.idprof4']['checked'])) { print "".$obj->idprof4."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.idprof5']['checked'])) { print "".$obj->idprof5."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.idprof6']['checked'])) { print "".$obj->idprof6."\n"; + if (! $i) $totalarray['nbfield']++; } // Type if (! empty($arrayfields['customerorsupplier']['checked'])) @@ -1075,6 +1096,7 @@ while ($i < min($num, $limit)) } print $s; print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) @@ -1083,6 +1105,7 @@ while ($i < min($num, $limit)) print ''; print $companystatic->getLibProspLevel(); print ""; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.fk_stcomm']['checked'])) @@ -1098,6 +1121,7 @@ while ($i < min($num, $limit)) if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; } print '
'; + if (! $i) $totalarray['nbfield']++; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -1113,6 +1137,7 @@ while ($i < min($num, $limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -1126,6 +1151,7 @@ while ($i < min($num, $limit)) print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['s.tms']['checked'])) @@ -1133,11 +1159,13 @@ while ($i < min($num, $limit)) print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['s.status']['checked'])) { print ''.$companystatic->getLibStatut(3).''; + if (! $i) $totalarray['nbfield']++; } // Action column @@ -1150,7 +1178,7 @@ while ($i < min($num, $limit)) } print ''; if (! $i) $totalarray['nbfield']++; - + print ''."\n"; $i++; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c0738f004bc..f3e7df31609 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4179,7 +4179,7 @@ dl.dropdown { position:absolute; top:2px; list-style:none; - max-height: 300px; + max-height: 280px; overflow: auto; } .dropdown span.value { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4557c6856fb..49a8745f61e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4266,7 +4266,7 @@ dl.dropdown { position:absolute; top:2px; list-style:none; - max-height: 300px; + max-height: 280px; overflow: auto; } .dropdown span.value { diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 415665bc5fc..6aaa3274b9d 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -465,6 +465,7 @@ print "\n"; $i = 0; +$totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); @@ -497,32 +498,39 @@ while ($i < min($num,$limit)) print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); } print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.lastname']['checked'])) { print ''.$obj->lastname.''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.firstname']['checked'])) { print ''.$obj->firstname.''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.gender']['checked'])) { print ''; if ($obj->gender) print $langs->trans("Gender".$obj->gender); print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.employee']['checked'])) { print ''.yn($obj->employee).''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.accountancy_code']['checked'])) { print ''.$obj->accountancy_code.''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.email']['checked'])) { print ''.$obj->email.''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.fk_soc']['checked'])) { @@ -543,6 +551,7 @@ while ($i < min($num,$limit)) print $langs->trans("InternalUser"); } print ''; + if (! $i) $totalarray['nbfield']++; } // Multicompany enabled if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) @@ -560,6 +569,7 @@ while ($i < min($num,$limit)) print $mc->label; } print ''; + if (! $i) $totalarray['nbfield']++; } } // Supervisor @@ -589,17 +599,20 @@ while ($i < min($num,$limit)) } } print ''; + if (! $i) $totalarray['nbfield']++; } // Date last login if (! empty($arrayfields['u.datelastlogin']['checked'])) { print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''; + if (! $i) $totalarray['nbfield']++; } // Date previous login if (! empty($arrayfields['u.datepreviouslogin']['checked'])) { print ''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").''; + if (! $i) $totalarray['nbfield']++; } // Extra fields @@ -616,6 +629,7 @@ while ($i < min($num,$limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -629,6 +643,7 @@ while ($i < min($num,$limit)) print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['u.tms']['checked'])) @@ -636,15 +651,18 @@ while ($i < min($num,$limit)) print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['u.statut']['checked'])) { - $userstatic->statut=$obj->statut; - print ''.$userstatic->getLibStatut(3).''; + $userstatic->statut=$obj->statut; + print ''.$userstatic->getLibStatut(3).''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; $i++; From e0275285454bcb2090816e42c6298aa44a7ee768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jun 2017 14:24:12 +0200 Subject: [PATCH 007/342] Clean module builder --- .../template/core/modules/modMyModule.class.php | 8 +++++--- htdocs/modulebuilder/template/css/mycss.css.php | 6 ++---- htdocs/modulebuilder/template/js/mymodule.js.php | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 9e8f5ca9975..dc98c327cb3 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -50,7 +50,7 @@ class modMyModule extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'mymodule'; @@ -62,11 +62,13 @@ class modMyModule extends DolibarrModules // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) //$this->familyinfo = array('myownfamily' => array('position' => '001', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModue is name of module). $this->name = preg_replace('/^mod/i','',get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModue is name of module). $this->description = "MyModuleDescription"; + // Used only if file README.md and README-LL.md not found. $this->descriptionlong = "MyModuleDescription (Long)"; + $this->editor_name = 'Editor name'; $this->editor_url = 'https://www.example.com'; diff --git a/htdocs/modulebuilder/template/css/mycss.css.php b/htdocs/modulebuilder/template/css/mycss.css.php index eaa248288e8..60d49d7c0bc 100644 --- a/htdocs/modulebuilder/template/css/mycss.css.php +++ b/htdocs/modulebuilder/template/css/mycss.css.php @@ -17,11 +17,9 @@ */ /** - * \file css/mycss.css.php + * \file htdocs/modulebuilder/template/css/mycss.css.php * \ingroup mymodule - * \brief Example CSS. - * - * Put detailed description here. + * \brief CSS file for module MyModule. */ header('Content-Type: text/css'); diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index a08ae02c2fc..32915dbe34e 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -19,9 +19,7 @@ /** * \file htdocs/modulebuilder/template/js/mymodule.js.php * \ingroup mymodule - * \brief Example JavaScript. - * - * Put detailed description here. + * \brief JavaScript file for module MyModule. */ header('Content-Type: application/javascript'); From b1f93ccb0c72301ffc186ebf96669774f2d2971e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jun 2017 14:33:46 +0200 Subject: [PATCH 008/342] Fix security --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/admin/fiscalyear.php | 2 +- htdocs/accountancy/admin/importaccounts.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/accountancy/bookkeeping/listbyyear.php | 2 +- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/lines.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/admin/defaultvalues.php | 2 +- htdocs/admin/translation.php | 2 +- htdocs/bookmarks/list.php | 2 +- htdocs/comm/action/listactions.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/commande/customer.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/bank/index.php | 2 +- htdocs/compta/prelevement/card.php | 2 +- htdocs/compta/prelevement/demandes.php | 2 +- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/contact/agenda.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/contrat/services.php | 2 +- htdocs/cron/list.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/product/list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/list-with-listview.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/popuprop.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/projet/info.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/projet/tasks/time.php | 2 +- htdocs/resource/list.php | 2 +- htdocs/societe/agenda.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/societe/notify/card.php | 2 +- htdocs/user/group/index.php | 2 +- htdocs/user/index.php | 2 +- htdocs/user/notify/card.php | 2 +- 56 files changed, 56 insertions(+), 56 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index c2b6997d96e..83c844123be 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -52,7 +52,7 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden(); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); $page = GETPOST("page", 'int'); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 47759792d71..5eabf9eda25 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $action = GETPOST('action','aZ09'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index d1083c50d10..6b462928736 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -39,7 +39,7 @@ $langs->load("accountancy"); if (! $user->admin) accessforbidden(); -$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 069076e3d88..b6af74ec96d 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -70,7 +70,7 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount'); $btn_changetype = GETPOST('changetype'); -$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 34db60f7a0f..3f2c472cc58 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -55,7 +55,7 @@ if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { $action = 'export_csv'; } -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit; $offset = $limit * $page; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 60e283eea2c..26ab0fa4c4d 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -80,7 +80,7 @@ $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 6b329e421ad..b9a5526a7ab 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -59,7 +59,7 @@ $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index 5fba55f2eba..f4134a2e028 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -37,7 +37,7 @@ $langs->load("accountancy"); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit; $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $search_doc_type = GETPOST('search_doc_type', 'alpha'); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 9c88a417bac..a5dfa3941d1 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -55,7 +55,7 @@ $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 9e534d55af7..56765e1ba4f 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index ca2369a11e4..5a386c82522 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -52,7 +52,7 @@ $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 01acf759260..7fb5f26b28b 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -61,7 +61,7 @@ $search_vat = GETPOST('search_vat', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 06308a67fa1..164525d5214 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -54,7 +54,7 @@ $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 7ed1453982e..26000c3fb66 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha'); $btn_ventil = GETPOST('ventil', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 82ab87961f3..3dd60ad7478 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -62,7 +62,7 @@ $optioncss = GETPOST('optioncss','alpha'); if ($statut < -1) $statut = ''; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 633c872e607..a5066f98f0c 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -42,7 +42,7 @@ $optioncss = GETPOST('optioncss','alpha'); $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 4935b6c4c6d..1461098034e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -44,7 +44,7 @@ $search_email = GETPOST('search_email','alpha'); $type = GETPOST('type','alpha'); $status = GETPOST('status','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 7409ef1b973..04a9320f4c1 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -39,7 +39,7 @@ $action=GETPOST('action','alpha'); $mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 67433eca35d..f48ef749b8a 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -45,7 +45,7 @@ $transvalue=GETPOST('transvalue','alpha'); $mode = GETPOST('mode')?GETPOST('mode'):'overwrite'; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 57bb6a71cec..71c8174f1cd 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -39,7 +39,7 @@ if (! $user->rights->bookmark->lire) { } $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 400b882d143..186165b2f9a 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -76,7 +76,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $filtert=$user->id; } -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 8ee163e8e6f..73aaab22248 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -39,7 +39,7 @@ if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden(); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 1fa05a07832..cdf26b6a36d 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -45,7 +45,7 @@ accessforbidden(); $langs->load("companies"); $langs->load("orders"); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c879a2da7d8..2f8dfc28ae7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -82,7 +82,7 @@ $result = restrictedArea($user, 'commande', $id,''); $diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 6315b8e1d50..f5e9d347e8c 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -55,7 +55,7 @@ $result=restrictedArea($user,'banque'); $diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 443f93eb52c..915cf43fb79 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -48,7 +48,7 @@ $id = GETPOST('id','int'); $socid = GETPOST('socid','int'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 8b5e024f3b6..6e63b74a408 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -45,7 +45,7 @@ $page = GETPOST('page','int'); $sortorder = GETPOST('sortorder','alpha'); $sortfield = GETPOST('sortfield','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 9987d41e802..28836abe667 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -44,7 +44,7 @@ if ($user->societe_id > 0) accessforbidden(); $prev_id = GETPOST('id','int'); $socid = GETPOST('socid','int'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 5ec219a48ee..3ddb99a4369 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -40,7 +40,7 @@ $object = new Societe($db); if ($id > 0) $object->fetch($id); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 8a69af99cf5..61d18cd85cc 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -52,7 +52,7 @@ if ($user->societe_id > 0) $socid = $user->societe_id; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index ba0ec3f8ef0..96876ed561d 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -89,7 +89,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ad71eb3786f..fd48794afad 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -74,7 +74,7 @@ $optioncss = GETPOST('optioncss','alpha'); $type=GETPOST("type"); $view=GETPOST("view"); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index bbe30fe26dd..0003bdec348 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -65,7 +65,7 @@ $month=GETPOST("month","int"); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 8d4fa7e69d4..6902927a8b7 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -33,7 +33,7 @@ $langs->load("products"); $langs->load("contracts"); $langs->load("companies"); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 636770ef567..12c92e9bdd3 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -39,7 +39,7 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 68938afef6a..517a231fdb9 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -53,7 +53,7 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $sall = GETPOST('sall', 'alphanohtml'); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index e41666cdd92..8fcacda5d44 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -51,7 +51,7 @@ $diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'. // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 9650aa5328b..4b117cc4a2c 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -101,7 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index d6af4d3b1ac..d6d0ac734a2 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -42,7 +42,7 @@ $type = GETPOST('type'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index baca7249a51..8fac1c8a388 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -68,7 +68,7 @@ $search_myfield=GETPOST('search_myfield'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 41c03756a44..93a18788f95 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; $langs->load("stock"); $langs->load("inventory"); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 61f6233f32e..f3119af83c9 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -77,7 +77,7 @@ if (!$_POST) { $diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 2afa8438e73..841156ebb0d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -77,7 +77,7 @@ if (!$_POST) { $diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 5670b62e6bd..8aa5191b176 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -38,7 +38,7 @@ $type=GETPOST("type","int"); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index de245b9b04a..1d74cf85fad 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -61,7 +61,7 @@ $search_myfield=GETPOST('search_myfield'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 74015626b9e..135517f26db 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -35,7 +35,7 @@ $ref = GETPOST('ref','alpha'); $socid = GETPOST('socid','int'); $action = GETPOST('action','alpha'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b9da5379655..c85b96ffcf4 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -55,7 +55,7 @@ if (!$user->rights->projet->lire) accessforbidden(); $diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 67f745c0b57..7e809fe966f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -85,7 +85,7 @@ if (!$user->rights->projet->lire) accessforbidden(); $diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ecd15a8aa3b..8aa496eaa5a 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -58,7 +58,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index d157cfc99d2..f16d1ef122c 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -91,7 +91,7 @@ if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index d0eb936fcbb..dbb9e831fe9 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -50,7 +50,7 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3cbd8768e92..9842e913dae 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -84,7 +84,7 @@ $mode=GETPOST("mode"); $diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 7e7648db712..9a5405de7fd 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -44,7 +44,7 @@ $actionid=GETPOST('actionid'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 16091381e8d..d88d591a152 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -45,7 +45,7 @@ $search_group=GETPOST('search_group'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 6aaa3274b9d..1aedee87908 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -46,7 +46,7 @@ if ($user->societe_id > 0) $mode = GETPOST("mode", 'alpha'); // Load variable for pagination -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index e39d8153cac..5fc0af8fa14 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -44,7 +44,7 @@ $actionid=GETPOST('actionid'); if ($user->societe_id) $id=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); From b441c62e1d595aaa472ef8fef58a8ecb56c2c6d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Jun 2017 14:55:12 +0200 Subject: [PATCH 009/342] Fix syntax error --- htdocs/accountancy/admin/account.php | 2 +- htdocs/accountancy/admin/fiscalyear.php | 2 +- htdocs/accountancy/admin/importaccounts.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/admin/defaultvalues.php | 2 +- htdocs/admin/translation.php | 2 +- htdocs/bookmarks/list.php | 2 +- htdocs/comm/action/listactions.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/commande/customer.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/bank/index.php | 2 +- htdocs/compta/prelevement/card.php | 2 +- htdocs/compta/prelevement/demandes.php | 2 +- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/recap-compta.php | 2 +- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/contact/agenda.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/contrat/services.php | 2 +- htdocs/cron/class/cronjob.class.php | 72 +++++++++---------- htdocs/cron/info.php | 2 +- htdocs/cron/list.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/product/list.php | 2 +- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/product/inventory/list.php | 2 +- htdocs/product/list-with-listview.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/popuprop.php | 2 +- htdocs/product/stock/productlot_list.php | 2 +- htdocs/projet/info.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/projet/tasks/time.php | 2 +- htdocs/resource/list.php | 2 +- htdocs/societe/agenda.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/societe/notify/card.php | 2 +- htdocs/user/group/index.php | 2 +- htdocs/user/index.php | 2 +- htdocs/user/notify/card.php | 2 +- 48 files changed, 83 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 83c844123be..e369081f7e1 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -52,7 +52,7 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden(); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); $page = GETPOST("page", 'int'); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 5eabf9eda25..bf26348b50a 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; $action = GETPOST('action','aZ09'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 6b462928736..6ae94dc8ce2 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -39,7 +39,7 @@ $langs->load("accountancy"); if (! $user->admin) accessforbidden(); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index b6af74ec96d..33bf067fa9e 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -70,7 +70,7 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount'); $btn_changetype = GETPOST('changetype'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 3dd60ad7478..06de3e09f95 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -62,7 +62,7 @@ $optioncss = GETPOST('optioncss','alpha'); if ($statut < -1) $statut = ''; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index a5066f98f0c..af3174c0b60 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -42,7 +42,7 @@ $optioncss = GETPOST('optioncss','alpha'); $date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"]; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 1461098034e..f2fa12446b3 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -44,7 +44,7 @@ $search_email = GETPOST('search_email','alpha'); $type = GETPOST('type','alpha'); $status = GETPOST('status','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 04a9320f4c1..bd539becb86 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -39,7 +39,7 @@ $action=GETPOST('action','alpha'); $mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index f48ef749b8a..0c4e40948ed 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -45,7 +45,7 @@ $transvalue=GETPOST('transvalue','alpha'); $mode = GETPOST('mode')?GETPOST('mode'):'overwrite'; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 71c8174f1cd..a192076e88a 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -39,7 +39,7 @@ if (! $user->rights->bookmark->lire) { } $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 186165b2f9a..0e6fbb196a1 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -76,7 +76,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $filtert=$user->id; } -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 73aaab22248..6c580cc93d6 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -39,7 +39,7 @@ if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden(); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index cdf26b6a36d..8aa699fed71 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -45,7 +45,7 @@ accessforbidden(); $langs->load("companies"); $langs->load("orders"); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 2f8dfc28ae7..dbfeafc8f94 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -82,7 +82,7 @@ $result = restrictedArea($user, 'commande', $id,''); $diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index f5e9d347e8c..44ecbe6eb6f 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -55,7 +55,7 @@ $result=restrictedArea($user,'banque'); $diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 915cf43fb79..1a0435862ea 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -48,7 +48,7 @@ $id = GETPOST('id','int'); $socid = GETPOST('socid','int'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 6e63b74a408..dd453bd7f4e 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -45,7 +45,7 @@ $page = GETPOST('page','int'); $sortorder = GETPOST('sortorder','alpha'); $sortfield = GETPOST('sortfield','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 28836abe667..996a1aabe88 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -44,7 +44,7 @@ if ($user->societe_id > 0) accessforbidden(); $prev_id = GETPOST('id','int'); $socid = GETPOST('socid','int'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 3ddb99a4369..c3231ecccdd 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -40,7 +40,7 @@ $object = new Societe($db); if ($id > 0) $object->fetch($id); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 61d18cd85cc..62ee285d70b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -52,7 +52,7 @@ if ($user->societe_id > 0) $socid = $user->societe_id; if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 96876ed561d..6c412c146d1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -89,7 +89,7 @@ $search_agenda_label=GETPOST('search_agenda_label'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index fd48794afad..b2f8066367c 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -74,7 +74,7 @@ $optioncss = GETPOST('optioncss','alpha'); $type=GETPOST("type"); $view=GETPOST("view"); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 0003bdec348..11a259abce7 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -65,7 +65,7 @@ $month=GETPOST("month","int"); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 6902927a8b7..0af99eeed33 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -33,7 +33,7 @@ $langs->load("products"); $langs->load("contracts"); $langs->load("companies"); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 789e3bafcec..9d01ec888f0 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -109,7 +109,7 @@ class Cronjob extends CommonObject if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); if (isset($this->libname)) $this->libname = trim($this->libname); if (isset($this->test)) $this->test = trim($this->test); - + // Check parameters // Put here code to add a control on parameters values if (dol_strlen($this->datestart)==0) { @@ -361,15 +361,15 @@ class Cronjob extends CommonObject * @param int $offset page * @param int $status display active or not * @param array $filter filter output - * @param int $processing Processing or not + * @param int $processing Processing or not * @return int <0 if KO, >0 if OK */ function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='', $processing=-1) { global $langs; - + $this->lines=array(); - + $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.entity,"; @@ -409,7 +409,7 @@ class Cronjob extends CommonObject if ($status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { - foreach($filter as $key => $value) + foreach($filter as $key => $value) { if ($key == 't.rowid') $sql.= ' AND '.$key.' = '.$this->db->escape($value); else $sql.= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -532,7 +532,7 @@ class Cronjob extends CommonObject if (empty($this->maxrun)) $this->maxrun=0; if (empty($this->processing)) $this->processing=0; - + // Check parameters // Put here code to add a control on parameters values if (dol_strlen($this->datestart)==0) { @@ -845,8 +845,8 @@ class Cronjob extends CommonObject /** * Run a job. - * Once job is finished, status and nb of run is updated. - * This function does not plan the next run. This is done by function ->reprogram_jobs + * Once job is finished, status and nb of run is updated. + * This function does not plan the next run. This is done by function ->reprogram_jobs * * @param string $userlogin User login * @return int <0 if KO, >0 if OK @@ -861,7 +861,7 @@ class Cronjob extends CommonObject $langs->load('cron'); - if (empty($userlogin)) + if (empty($userlogin)) { $this->error="User login is mandatory"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); @@ -948,7 +948,7 @@ class Cronjob extends CommonObject $error++; } } - + // Load langs if (! $error) { @@ -963,14 +963,14 @@ class Cronjob extends CommonObject $error++; } } - + if (! $error) { dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG); - + // Create Object for the call module $object = new $this->objectname($this->db); - + $params_arr = array_map('trim', explode(",",$this->params)); if (!is_array($params_arr)) { @@ -980,7 +980,7 @@ class Cronjob extends CommonObject { $result = call_user_func_array(array($object, $this->methodename), $params_arr); } - + if ($result===false || $result != 0) { $langs->load("errors"); @@ -998,7 +998,7 @@ class Cronjob extends CommonObject $this->lastresult=var_export($result,true); $retval = $this->lastresult; } - } + } } if($this->jobtype == 'function') @@ -1071,7 +1071,7 @@ class Cronjob extends CommonObject $this->lastoutput = ''; // Will be filled later $this->lastresult = $retval; $retval = $this->lastresult; - $error++; + $error++; } } if ($execmethod == 2) @@ -1102,14 +1102,14 @@ class Cronjob extends CommonObject $this->lastoutput.=$val."\n"; } } - + $this->lastresult=$retval; - + dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); } - + dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)"); - + $this->datelastresult=dol_now(); $this->processing=0; $result = $this->update($user); // This include begin/commit @@ -1135,19 +1135,19 @@ class Cronjob extends CommonObject function reprogram_jobs($userlogin, $now) { dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); - + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $user=new User($this->db); $result=$user->fetch('',$userlogin); - if ($result<0) + if ($result<0) { $this->error="User Error:".$user->error; dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; } - else + else { - if (empty($user->id)) + if (empty($user->id)) { $this->error=" User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); @@ -1155,28 +1155,28 @@ class Cronjob extends CommonObject } } - dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG); + dol_syslog(get_class($this)."::reprogram_jobs datenextrun=".$this->datenextrun." ".dol_print_date($this->datenextrun, 'dayhourrfc')." frequency=".$this->frequency." unitfrequency=".$this->unitfrequency, LOG_DEBUG); - - if (empty($this->datenextrun)) + if (empty($this->datenextrun)) { if (empty($this->datestart)) $this->datenextrun = $now + ($this->frequency * $this->unitfrequency); else $this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency); } - if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0) + if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0) { // Loop until date is after future while ($this->datenextrun < $now) { $this->datenextrun += ($this->frequency * $this->unitfrequency); - + // TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit) } } - else + else { //$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency); + dol_syslog(get_class($this)."::reprogram_jobs datenextrun is already in future, we do not change it"); } @@ -1190,9 +1190,9 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::reprogram_jobs Job will be set to archived", LOG_ERR); } } - + $result = $this->update($user); - if ($result<0) + if ($result<0) { dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; @@ -1200,7 +1200,7 @@ class Cronjob extends CommonObject return 1; } - + /** * Return label of status of user (active, inactive) * @@ -1211,7 +1211,7 @@ class Cronjob extends CommonObject { return $this->LibStatut($this->status,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -1223,7 +1223,7 @@ class Cronjob extends CommonObject { global $langs; $langs->load('users'); - + if ($mode == 0) { $prefix=''; @@ -1255,7 +1255,7 @@ class Cronjob extends CommonObject if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } - } + } } diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index 334a5da6890..18ab50adeaa 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -48,7 +48,7 @@ $object->info($id); $head = cron_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'cron'); +dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); print '
'; dol_print_object_info($object); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 12c92e9bdd3..3b830e4801f 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -39,7 +39,7 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 517a231fdb9..091b5e44bb8 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -53,7 +53,7 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $sall = GETPOST('sall', 'alphanohtml'); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 8fcacda5d44..9cf47ddea94 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -51,7 +51,7 @@ $diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'. // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4b117cc4a2c..86fb7e5c4f5 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -101,7 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index d6d0ac734a2..00e2dbf939d 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -42,7 +42,7 @@ $type = GETPOST('type'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 8fac1c8a388..ef3cb110224 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -68,7 +68,7 @@ $search_myfield=GETPOST('search_myfield'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 93a18788f95..c8d570a6fd7 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; $langs->load("stock"); $langs->load("inventory"); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index f3119af83c9..947cfaecbc2 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -77,7 +77,7 @@ if (!$_POST) { $diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 841156ebb0d..4cd986de291 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -77,7 +77,7 @@ if (!$_POST) { $diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = (GETPOST("page",'int')?GETPOST("page", 'int'):0); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 8aa5191b176..21491eab512 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -38,7 +38,7 @@ $type=GETPOST("type","int"); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 1d74cf85fad..61e9438c929 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -61,7 +61,7 @@ $search_myfield=GETPOST('search_myfield'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 135517f26db..05c31287745 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -35,7 +35,7 @@ $ref = GETPOST('ref','alpha'); $socid = GETPOST('socid','int'); $action = GETPOST('action','alpha'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c85b96ffcf4..827719148fe 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -55,7 +55,7 @@ if (!$user->rights->projet->lire) accessforbidden(); $diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 7e809fe966f..18f133513b1 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -85,7 +85,7 @@ if (!$user->rights->projet->lire) accessforbidden(); $diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8aa496eaa5a..08eb429f664 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -58,7 +58,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index f16d1ef122c..5ec9eabbfb1 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -91,7 +91,7 @@ if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index dbb9e831fe9..15ea29e9954 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -50,7 +50,7 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9842e913dae..422768bce31 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -84,7 +84,7 @@ $mode=GETPOST("mode"); $diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 9a5405de7fd..eacd047d93a 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -44,7 +44,7 @@ $actionid=GETPOST('actionid'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index d88d591a152..06e11caced9 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -45,7 +45,7 @@ $search_group=GETPOST('search_group'); $optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 1aedee87908..da5ddd99339 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -46,7 +46,7 @@ if ($user->societe_id > 0) $mode = GETPOST("mode", 'alpha'); // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 5fc0af8fa14..b803fd93f7b 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -44,7 +44,7 @@ $actionid=GETPOST('actionid'); if ($user->societe_id) $id=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$limit = GETPOST('limit','int')?GETPOST('limit', 'int')::$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield=GETPOST("sortfield",'alpha'); $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); From 9b3b2e600f80823e222ce6e60f4952f5ea1dd848 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Thu, 8 Jun 2017 17:52:02 +0200 Subject: [PATCH 010/342] init blockedlog trigger and hash store --- htdocs/core/class/blockedlog.class.php | 235 ++++++++++++++++++ ..._modBlockedlog_ActionsBlockedLog.class.php | 78 ++++++ .../install/mysql/migration/5.0.0-6.0.0.sql | 18 ++ 3 files changed, 331 insertions(+) create mode 100644 htdocs/core/class/blockedlog.class.php create mode 100644 htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php diff --git a/htdocs/core/class/blockedlog.class.php b/htdocs/core/class/blockedlog.class.php new file mode 100644 index 00000000000..3e622c42dc4 --- /dev/null +++ b/htdocs/core/class/blockedlog.class.php @@ -0,0 +1,235 @@ +db =&$db; + + } + + public function create($user) { + + global $conf,$langs,$hookmanager; + + $langs->load('blockedlog'); + + $error=0; + + dol_syslog(get_class($this).'::create', LOG_DEBUG); + + // Clean parameters + $this->signature = $this->getSignatureRecursive(); + + + if (is_null($this->key_value1)) + { + $this->error=$langs->trans("BlockLogNeedKey1Value"); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + if(empty($this->element)) { + $this->error=$langs->trans("BlockLogNeedElement"); + dol_syslog($this->error, LOG_WARNING); + return -2; + } + + if(empty($this->action)) { + $this->error=$langs->trans("BlockLogNeedAction"); + dol_syslog($this->error, LOG_WARNING); + return -3; + } + + $this->fk_user = $user->id; + + $this->db->begin(); + + //TODO add fk_user; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; + $sql.= "action,"; + $sql.= " key_value1,"; + $sql.= " signature,"; + $sql.= " element,"; + $sql.= " fk_object,"; + $sql.= " certified,"; + $sql.= " entity"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->action)."',"; + $sql.= "".$this->key_value1.","; + $sql.= "'".$this->db->escape($this->signature)."',"; + $sql.= "'".$this->db->escape($this->element)."',"; + $sql.= "".$this->fk_object.","; + $sql.= "'".($this->certified ? 1 : 0)."',"; + $sql.= $conf->entity; + $sql.= ")"; + + $res = $this->db->query($sql); + if ($res) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); + + if ($id > 0) + { + $this->id = $id; + + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + + } + + private function crypt($value) { + + return md5($value); + + } + + public function checkSignature() { + + $signature = $this->getSignatureRecursive(); + + return ($signature === $this->signature); + + } + + private function getSignatureRecursive(){ + + $signature = $this->crypt( $this->action . $this->getSignature() . $this->key_value1 ); + + $logs = $this->getLog('payment', 0, 0, 'ASC') ; + if($logs!==false) { + foreach($logs as &$b) { + + if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature + + $b->updateValue(); // on récupère la valeur actuelle en base de l'élément enregistré + + $signature = $this->crypt($signature. $this->action . $b->signature . $b->key_value1); + } + } + return $signature; + + } + + public function getLog($element, $fk_object, $limit = 0, $order = 'DESC') { + global $conf,$cachedlogs ; + + if(empty($cachedlogs)) $cachedlogs=array(); + + + if($element=='payment') { + + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' + ORDER BY tms ".$order; + + } + else if($element=='payments_not_certified') { + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' AND certified = 0 + ORDER BY tms ".$order; + + } + else if($element=='payments_just_certified') { + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' AND certified = 1 + ORDER BY tms ".$order; + + } + else{ + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE element='".$element."' AND fk_object=".(int)$fk_object." + ORDER BY tms ".$order; + + } + + + if($limit > 0 )$sql.=' LIMIT '.$limit; + + $res = $this->db->query($sql); + + if($res) { + + $results=array(); + + while($obj = $this->db->fetch_object($res)) { + + if(!isset($cachedlogs[$obj->rowid])) { + $b=new BlockedLog($this->db); + $b->fetch($obj->rowid); + + $cachedlogs[$obj->rowid] = $b; + } + + $results[] = $cachedlogs[$obj->rowid]; + + } + + return $results; + } + else{ + return false; + } + } + + private function updateValue() { + + if($this->action === 'PAYMENT_CUSTOMER_CREATE' + || $this->action === 'PAYMENT_ADD_TO_BANK') { + $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; + + $res = $this->db->query($sql); + + if($res && $obj = $db->fetch_object($res)) { + $this->key_value1 = (double)$obj->amount; + } + } + + } + + + public function getSignature() { + global $db,$conf,$mysoc; + + if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint + + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + + $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); + + dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, '',0,'Numeric Unique Fingerprint', $conf->entity); + + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; + } + + return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; + } + +} + diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php new file mode 100644 index 00000000000..3307e4216ea --- /dev/null +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -0,0 +1,78 @@ + + * Copyright (C) 2009-2011 Regis Houssin + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2013 Cedric GROSS + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php + * \ingroup agenda + * \brief Trigger file for agenda module + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/blockedlog.class.php'; + +/** + * Class of triggered functions for agenda module + */ +class InterfaceActionsBlockedLog extends DolibarrTriggers +{ + public $family = 'system'; + public $description = "Triggers of this module add blocklog."; + public $version = self::VERSION_DOLIBARR; + public $picto = 'system'; + + /** + * Function called on Dolibarrr payment or invoice event. + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + // Do not log events not enabled for this action + if (empty($conf->blockedlog->enabled)) { + return 0; + } + + $b=new BlockedLog($this->db); + $b->element = $object->element; + $b->action = $action; + $b->fk_object = $object->id; + $b->key_value1 = 0; + + $res = $b->create($user); + if($res<0) { + setEventMessage($b->error,'errors'); + + return -1; + } + else { + return 1; + } + + + } + +} 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 85b9d3106cf..786becac0ba 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 @@ -395,3 +395,21 @@ 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); +CREATE TABLE llx_blockedlog +( + rowid integer AUTO_INCREMENT, + tms timestamp, + action varchar(50), + key_value1 real NOT NULL, + signature varchar(32) NOT NULL, + element varchar(50), + fk_object integer, + entity integer, + certified integer, + PRIMARY KEY (rowid), + KEY signature (signature), + KEY fk_object_element (fk_object,element), + KEY entity (entity), + KEY entity_action (entity,action), + KEY entity_action_certified (entity,action,certified) +) From 75624376a525a4e819c62e2adb42da9726fd7bc3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 00:27:19 +0200 Subject: [PATCH 011/342] FIX Warnings --- htdocs/core/lib/files.lib.php | 10 +++++----- htdocs/core/lib/images.lib.php | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3fa17aa8bcf..06df150d983 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -72,11 +72,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $reshook = 0; $file_list = array(); - $hookmanager->resArray=array(); - - if (! $nohook) + if (is_object($hookmanager) && ! $nohook) { - $hookmanager->initHooks(array('fileslib')); + $hookmanager->resArray=array(); + + $hookmanager->initHooks(array('fileslib')); $parameters=array( 'path' => $newpath, @@ -197,7 +197,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil } } - $file_list = array_merge($file_list, $hookmanager->resArray); + if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray); return $file_list; } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index acfa917720e..d9d7d0d9730 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -38,7 +38,7 @@ $quality = 80; function image_format_supported($file) { $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into product.class.php - + // Case filename is not a format image if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; @@ -90,7 +90,7 @@ function dol_getImageSize($file, $url = false) $ret['width']=$infoImg[0]; // Largeur de l'image $ret['height']=$infoImg[1]; // Hauteur de l'image } - + return $ret; } @@ -438,6 +438,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ dol_mkdir($dirthumb); // Initialisation des variables selon l'extension de l'image + $img=null; switch($infoImg[2]) { case IMAGETYPE_GIF: // 1 From 811b0d9af44158f0aac7aaeacfa0c7183c425d4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 00:27:44 +0200 Subject: [PATCH 012/342] Fix missing thumbs images for products --- htdocs/install/repair.php | 121 ++++++++++++++++++++++++++++---------- 1 file changed, 90 insertions(+), 31 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index a70553cbfb0..bab7b5e5da4 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -26,6 +26,7 @@ include_once 'inc.php'; if (file_exists($conffile)) include_once $conffile; require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; +include_once $dolibarr_main_document_root.'/core/lib/images.lib.php'; require_once $dolibarr_main_document_root.'/core/class/extrafields.class.php'; require_once 'lib/repair.lib.php'; @@ -72,11 +73,12 @@ $actiondone=1; print '

'.$langs->trans("Repair").'

'; -print 'Option restore_thirdparties_logos is '.(GETPOST('restore_thirdparties_logos')?GETPOST('restore_thirdparties_logos'):'0').'
'."\n"; -print 'Option clean_linked_elements is '.(GETPOST('clean_linked_elements')?GETPOST('clean_linked_elements'):'0').'
'."\n"; -print 'Option clean_orphelin_dir (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_orphelin_dir')?GETPOST('clean_orphelin_dir'):'0').'
'."\n"; -print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_product_stock_batch')?GETPOST('clean_product_stock_batch'):'0').'
'."\n"; -print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount')?GETPOST('set_empty_time_spent_amount'):'0').'
'."\n"; +print 'Option restore_thirdparties_logos is '.(GETPOST('restore_thirdparties_logos','alpha')?GETPOST('restore_thirdparties_logos','alpha'):'0').'
'."\n"; +print 'Option clean_linked_elements is '.(GETPOST('clean_linked_elements','alpha')?GETPOST('clean_linked_elements','alpha'):'0').'
'."\n"; +print 'Option clean_orphelin_dir (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_orphelin_dir','alpha')?GETPOST('clean_orphelin_dir','alpha'):'0').'
'."\n"; +print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_product_stock_batch','alpha')?GETPOST('clean_product_stock_batch','alpha'):'0').'
'."\n"; +print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'
'."\n"; +print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'
'."\n"; print '
'; print ''; @@ -253,7 +255,7 @@ if ($ok) { print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> "; $type=$extrafields->attribute_type[$code]; $length=$extrafields->attribute_size[$code]; $attribute=''; $default=''; $extra=''; $null='null'; - + if ($type=='boolean') { $typedb='int'; $lengthdb='1'; @@ -276,7 +278,7 @@ if ($ok) $typedb=$type; $lengthdb=$length; } - + $field_desc=array( 'type'=>$typedb, 'value'=>$lengthdb, @@ -318,13 +320,13 @@ if ($ok) -// clean_linked_elements: Check and clean linked elements +// restore_thirdparties_logos: Move logos to correct new directory. if ($ok && GETPOST('restore_thirdparties_logos')) { //$exts=array('gif','png','jpg'); $ext=''; - + print ''; +} + // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_linked_elements')) +if ($ok && GETPOST('clean_linked_elements','alpha')) { print ''; // propal => order @@ -418,7 +478,7 @@ if ($ok && GETPOST('clean_linked_elements')) // clean_orphelin_dir: Run purge of directory -if ($ok && GETPOST('clean_orphelin_dir')) +if ($ok && GETPOST('clean_orphelin_dir','alpha')) { $conf->setValues($db); @@ -530,7 +590,7 @@ if ($ok && GETPOST('clean_orphelin_dir')) // Clean of orphelins directories are done into repair.php print ''; - + $sql ="SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; $sql.=" FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb ON ps.rowid = pb.fk_product_stock"; $sql.=" WHERE p.rowid = ps.fk_product"; @@ -562,7 +622,7 @@ if ($ok && GETPOST('clean_product_stock_batch')) if ($resql) { $num = $db->num_rows($resql); - + if ($num) { $i = 0; @@ -570,7 +630,7 @@ if ($ok && GETPOST('clean_product_stock_batch')) { $obj=$db->fetch_object($resql); print ''; - + $i++; } } @@ -646,7 +706,7 @@ if ($ok && GETPOST('clean_product_stock_batch')) // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_product_stock_negative_if_batch')) +if ($ok && GETPOST('clean_product_stock_negative_if_batch','alpha')) { print ''; @@ -675,7 +735,7 @@ if ($ok && GETPOST('clean_product_stock_negative_if_batch')) } // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('set_empty_time_spent_amount')) +if ($ok && GETPOST('set_empty_time_spent_amount','alpha')) { print ''; @@ -684,7 +744,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount')) $sql.=" WHERE ptt.fk_user = u.rowid"; $sql.=" AND ptt.thm IS NULL and u.thm > 0"; $sql.=" GROUP BY u.rowid, u.login, u.thm"; - + $resql = $db->query($sql); if ($resql) { @@ -711,14 +771,14 @@ if ($ok && GETPOST('set_empty_time_spent_amount')) dol_print_error($db); } } - + if (!$error) $db->commit(); else $db->rollback(); print''; if ($error) break; - + $i++; } } @@ -732,7 +792,6 @@ if ($ok && GETPOST('set_empty_time_spent_amount')) dol_print_error($db); } - } From a63050bf46ca78c6563c16dff2f849c6033030c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 00:27:19 +0200 Subject: [PATCH 013/342] FIX Warnings Conflicts: htdocs/core/lib/files.lib.php htdocs/core/lib/images.lib.php --- htdocs/core/lib/files.lib.php | 57 ++++++++++++++++++++-------------- htdocs/core/lib/images.lib.php | 3 +- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 708aee9e498..7d8f29f7681 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -67,9 +67,14 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $path=preg_replace('/([\\/]+)$/i','',$path); $newpath=dol_osencode($path); - if (! $nohook) + $reshook = 0; + $file_list = array(); + + if (is_object($hookmanager) && ! $nohook) { - $hookmanager->initHooks(array('fileslib')); + $hookmanager->resArray=array(); + + $hookmanager->initHooks(array('fileslib')); $parameters=array( 'path' => $newpath, @@ -202,6 +207,10 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil return array(); } } + + if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray); + + return $file_list; } @@ -442,7 +451,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists) $destexists=dol_is_dir($destfile); if (! $overwriteifexists && $destexists) return 0; - + if (! $destexists) { // We must set mask just before creating dir, becaause it can be set differently by dol_copy @@ -452,7 +461,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists) $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files dol_mkdir($destfile."/".$file, '', decoct($dirmaskdec)); } - + $srcfile=dol_osencode($srcfile); $destfile=dol_osencode($destfile); @@ -726,7 +735,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n dol_syslog("Refused to delete file ".$file, LOG_WARNING); return False; } - + if (empty($nohook)) { $hookmanager->initHooks(array('fileslib')); @@ -777,7 +786,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n if ($nophperrors) $ok=@unlink($file_osencoded); else $ok=unlink($file_osencoded); if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); - else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); + else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); } return $ok; @@ -802,7 +811,7 @@ function dol_delete_dir($dir,$nophperrors=0) dol_syslog("Refused to delete dir ".$dir, LOG_WARNING); return False; } - + $dir_osencoded=dol_osencode($dir); return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded)); } @@ -1050,17 +1059,17 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $val = array($val); } } - + $nbfile = count($TFile['name']); - + for ($i = 0; $i < $nbfile; $i++) { // Define $destpath (path to file including filename) and $destfile (only filename) $destpath=$upload_dir . "/" . $TFile['name'][$i]; $destfile=$TFile['name'][$i]; - + $savingdocmask = dol_sanitizeFileName($savingdocmask); - + if ($savingdocmask) { $destpath=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask); @@ -1072,12 +1081,12 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $destpath = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']); $info = pathinfo($destfile); $destfile = $info['filename'].'.'.strtolower($info['extension']); - + $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) { global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; - + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; if (empty($donotupdatesession)) { @@ -1090,14 +1099,14 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create thumbs // We can't use $object->addThumbs here because there is no $object known - + // Used on logon for example $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); } - + setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } else @@ -1117,7 +1126,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio } } } - + } } elseif ($link) { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; @@ -1374,7 +1383,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu { global $user, $conf, $db; global $dolibarr_main_data_root; - + if (! is_object($fuser)) $fuser=$user; if (empty($modulepart)) return 'ErrorBadParameter'; @@ -1389,7 +1398,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu if (empty($refname)) $refname=basename(dirname($original_file)."/"); $relative_original_file = $original_file; - + // Wrapping for some images if ($modulepart == 'companylogo' && !empty($conf->mycompany->dir_output)) { @@ -1564,7 +1573,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } $original_file=$conf->user->dir_output.'/'.$original_file; } - + // Wrapping for third parties else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) { @@ -1620,7 +1629,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } - + // Wrapping for interventions else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) { @@ -1686,7 +1695,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } // Wrapping pour les commandes fournisseurs - else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) + else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) { if ($fuser->rights->fournisseur->commande->lire || preg_match('/^specimen/i',$original_file)) { @@ -1841,14 +1850,14 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $accessallowed=1; $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } - + // Wrapping for miscellaneous medias files elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) { $accessallowed=1; $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; } - + // Wrapping for backups else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { @@ -1896,7 +1905,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart else { - if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path. + if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path. if ($fuser->admin) $accessallowed=1; // If user is admin // Define $accessallowed diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 8a95a91db40..d4bc996fdfb 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -86,7 +86,7 @@ function dol_getImageSize($file, $url = false) $ret['width']=$infoImg[0]; // Largeur de l'image $ret['height']=$infoImg[1]; // Hauteur de l'image } - + return $ret; } @@ -434,6 +434,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ dol_mkdir($dirthumb); // Initialisation des variables selon l'extension de l'image + $img=null; switch($infoImg[2]) { case IMAGETYPE_GIF: // 1 From d326f161ef96cd149000ed102648be2a89b4e964 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 01:06:52 +0200 Subject: [PATCH 014/342] Fix permission on page to print barcode --- htdocs/barcode/printsheet.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index a60ac19d0af..daf366d0739 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2006-2016 Laurent Destailleur + * Copyright (C) 2006-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 @@ -145,7 +145,7 @@ if ($action == 'builddoc') // Load barcode class for generating barcode image $classname = "mod".ucfirst($generator); $module = new $classname($db); - if ($generator != 'tcpdfbarcode') + if ($generator != 'tcpdfbarcode') { // May be phpbarcode $template = 'standardlabel'; @@ -374,19 +374,25 @@ jQuery(document).ready(function() { print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; print '
'; -print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; -print '
'; -print '
'; -$form->select_produits(GETPOST('productid'), 'productid', ''); -print '   '; -print '
'; +if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)) +{ + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print '
'; + print '
'; + $form->select_produits(GETPOST('productid'), 'productid', ''); + print '   '; + print '
'; +} -print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; -print '
'; -print '
'; -print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); -print '   '; -print '
'; +if (! empty($user->rights->societe->lire)) +{ + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print '
'; + print '
'; + print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); + print '   '; + print '
'; +} print '
'; From d6ba16d3570a98406cb554ce83af4be724b4cf97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 09:45:22 +0200 Subject: [PATCH 015/342] Fix missing printFieldListWhere hook --- htdocs/product/index.php | 17 ++++++++++++++--- htdocs/product/list.php | 40 ++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 74a974804ff..56508616edd 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -42,6 +42,9 @@ else $result=restrictedArea($user,'produit|service'); $langs->load("products"); $langs->load("stocks"); +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('productindex')); + $product_static = new Product($db); @@ -80,7 +83,7 @@ print '
'; /* * Search Area of product/service */ - + // Search contract if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire)) { @@ -102,7 +105,7 @@ if (count($listofsearchfields)) print ''; $i++; } - print '

*** Restore thirdparties logo
'; //foreach($exts as $ext) //{ @@ -393,8 +395,66 @@ if ($ok && GETPOST('restore_thirdparties_logos')) } +// rebuild_product_thumbs: Rebuild thumbs for product files +if ($ok && GETPOST('rebuild_product_thumbs','alpha')) +{ + $ext=''; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; + + print '

*** Rebuild product thumbs
'; + + $sql="SELECT s.rowid, s.ref FROM ".MAIN_DB_PREFIX."product as s ORDER BY s.ref"; + $resql=$db->query($sql); + if ($resql) + { + $num=$db->num_rows($resql); + $i=0; + + while($i < $num) + { + $obj=$db->fetch_object($resql); + + if (! empty($obj->ref)) + { + $files=dol_dir_list($dolibarr_main_data_root.'/produit/'.$obj->ref, 'files', 0); + foreach($files as $file) + { + // Generate thumbs. + if (image_format_supported($file['fullname']) == 1) + { + $imgThumbSmall='notbuild'; + if (GETPOST('rebuild_product_thumbs','alpha') == 'confirmed') + { + // Used on logon for example + $imgThumbSmall = vignette($file['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbSmall." maxwidthsmall=".$maxwidthsmall." maxheightsmall=".$maxheightsmall."
\n"; + $imgThumbMini='notbuild'; + if (GETPOST('rebuild_product_thumbs','alpha') == 'confirmed') + { + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbMini." maxwidthmini=".$maxwidthmini." maxheightmini=".$maxheightmini."
\n"; + } + } + } + + $i++; + } + } + else + { + $ok=0; + dol_print_error($db); + } + + print '

*** Check table of linked elements and delete orphelins links
'; print 'Delete orphelins file '.$file['fullname'].'
'; - if (GETPOST('clean_orphelin_dir') == 'confirmed') + if (GETPOST('clean_orphelin_dir','alpha') == 'confirmed') { dol_delete_file($file['fullname'],1,1,1); dol_delete_dir(dirname($file['fullname']),1); @@ -545,12 +605,12 @@ if ($ok && GETPOST('clean_orphelin_dir')) } // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_product_stock_batch')) +if ($ok && GETPOST('clean_product_stock_batch','alpha')) { - $methodtofix=GETPOST('methodtofix')?GETPOST('methodtofix'):'updatestock'; - + $methodtofix=GETPOST('methodtofix','alpha')?GETPOST('methodtofix','alpha'):'updatestock'; + print '

*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)
Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch?$obj->reelbatch:'0').' (sum product_batch)'; - + // Fix if ($obj->reel != $obj->reelbatch) { @@ -599,9 +659,9 @@ if ($ok && GETPOST('clean_product_stock_batch')) if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error=0; - + $db->begin(); - + $sql2 ="UPDATE ".MAIN_DB_PREFIX."product_stock"; $sql2.=" SET reel = ".($obj->reelbatch?$obj->reelbatch:'0')." WHERE rowid = ".$obj->psrowid; $resql2=$db->query($sql2); @@ -610,26 +670,26 @@ if ($ok && GETPOST('clean_product_stock_batch')) // We update product_stock, so we must field stock into product too. $sql3='UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid)'; $resql3=$db->query($sql3); - if (! $resql3) + if (! $resql3) { $error++; dol_print_error($db); } } - else + else { $error++; dol_print_error($db); } - + if (!$error) $db->commit(); else $db->rollback(); } } } - + print'

Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)

*** Set value of time spent without amount
'; + print '
'; print ''; print '
'; } @@ -117,6 +120,10 @@ $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $result = $db->query($sql); while ($objp = $db->fetch_object($result)) { @@ -246,6 +253,10 @@ $sql.= " p.tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.entity IN (".getEntity($product_static->element, 1).")"; if ($type != '') $sql.= " AND p.fk_product_type = ".$type; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $sql.= $db->order("p.tms","DESC"); $sql.= $db->plimit($max,0); @@ -419,7 +430,7 @@ function activitytrim($product_type) $i = 0; $var=true; - + while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 1aec109474e..043327920db 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -78,7 +78,7 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'productser if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; } if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); $form=new Form($db); @@ -163,7 +163,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]); } @@ -284,7 +284,7 @@ else $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -369,8 +369,8 @@ else $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - + } + print '
'; if ($optioncss != '') print ''; print ''; @@ -416,7 +416,7 @@ else foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + // Filter on categories $moreforfilter=''; if (! empty($conf->categorie->enabled)) @@ -458,9 +458,9 @@ else if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -552,7 +552,7 @@ else // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { if (! empty($arrayfields["ef.".$key]['checked'])) print ''; } @@ -627,7 +627,7 @@ else $product_static->status_buy = $objp->tobuy; $product_static->status = $objp->tosell; $product_static->entity = $objp->entity; - + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) // To optimize call of load_stock { if ($objp->fk_product_type != 1) // Not a service @@ -635,8 +635,8 @@ else $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() } } - - + + $var=!$var; print ''; @@ -659,7 +659,7 @@ else { print ''.dol_trunc($objp->label,40).''; } - + // Barcode if (! empty($arrayfields['p.barcode']['checked'])) { @@ -765,7 +765,7 @@ else print ''; print yn($objp->tobatch); print ''; - } + } // Accountancy code sell if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''.$objp->accountancy_code_sell.''; // Accountancy code sell @@ -773,9 +773,9 @@ else // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); @@ -804,8 +804,8 @@ else print ''; print dol_print_date($objp->date_update, 'dayhour'); print ''; - } - + } + // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { @@ -828,13 +828,13 @@ else } print ''; } - // Action + // Action print ' '; print "\n"; $i++; } - + $db->free($resql); print ""; From 929946ad470dd950a401eba7a14a40ca4d081fac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 10:12:01 +0200 Subject: [PATCH 016/342] Fix several problem with hook printFieldListWhere --- htdocs/core/class/commonobject.class.php | 58 +++++++++++++----------- htdocs/core/class/hookmanager.class.php | 10 ++-- htdocs/core/class/html.form.class.php | 12 ++++- htdocs/core/lib/functions.lib.php | 3 +- 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 529bb20a89b..835ad698a1b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -398,7 +398,7 @@ abstract class CommonObject $lastname=$this->lastname; $firstname=$this->firstname; if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); - + $ret=''; if ($option && $this->civility_id) { @@ -597,11 +597,11 @@ abstract class CommonObject dol_syslog("CODE_NOT_VALID_FOR_THIS_ELEMENT"); return -3; } - + $datecreate = dol_now(); $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) "; @@ -1230,19 +1230,19 @@ abstract class CommonObject function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='') { global $user,$langs,$conf; - + if (empty($table)) $table=$this->table_element; if (empty($id)) $id=$this->id; if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; $error=0; - + $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - + $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); @@ -1284,7 +1284,7 @@ abstract class CommonObject /** * Load properties id_previous and id_next * - * @param string $filter Optional filter + * @param string $filter Optional filter. Example: " AND (t.field1 = 'aa' OR t.field2 = 'bb')" * @param int $fieldid Name of field to use for the select MAX and MIN * @param int $nodbprefix Do not include DB prefix to forge table name * @return int <0 if KO, >0 if OK @@ -1310,11 +1310,15 @@ abstract class CommonObject if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; - if (! empty($filter)) $sql.=" AND ".$filter; + if (! empty($filter)) + { + if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility + $sql.=$filter; + } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; - //print $sql."
"; + //print $filter.' '.$sql."
"; $result = $this->db->query($sql); if (! $result) { @@ -1518,7 +1522,7 @@ abstract class CommonObject if($mode == 1) { $line->subprice = 0; } - + switch ($this->element) { case 'propal': $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); @@ -2154,7 +2158,7 @@ abstract class CommonObject // Special cas //var_dump($this->table_element);exit; if ($this->table_element == 'product') $suffix=''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); $sql.= " WHERE rowid =". $this->id; @@ -2164,7 +2168,7 @@ abstract class CommonObject { if ($suffix == '_public') $this->note_public = $note; else if ($suffix == '_private') $this->note_private = $note; - else + else { $this->note = $note; // deprecated $this->note_private = $note; @@ -2413,7 +2417,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; - + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2446,10 +2450,10 @@ abstract class CommonObject * Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds * Possible usage for parameters: * - all parameters empty -> we look all link to current object (current object can be source or target) - * - source id+type -> will get target list linked to source - * - target id+type -> will get source list linked to target - * - source id+type + target type -> will get target list of the type - * - target id+type + target source -> will get source list of the type + * - source id+type -> will get target list linked to source + * - target id+type -> will get source list linked to target + * - source id+type + target type -> will get target list of the type + * - target id+type + target source -> will get source list of the type * * @param int $sourceid Object source id (if not defined, id of object) * @param string $sourcetype Object source type (if not defined, element name of object) @@ -2902,7 +2906,7 @@ abstract class CommonObject function isObjectUsed($id=0) { if (empty($id)) $id=$this->id; - + // Check parameters if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) { @@ -3019,12 +3023,12 @@ abstract class CommonObject foreach ($this->lines as $line) { - if (isset($line->qty_asked)) + if (isset($line->qty_asked)) { if (empty($totalOrdered)) $totalOrdered=0; // Avoid warning because $totalOrdered is '' $totalOrdered+=$line->qty_asked; // defined for shipment only } - if (isset($line->qty_shipped)) + if (isset($line->qty_shipped)) { if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is '' $totalToShip+=$line->qty_shipped; // defined for shipment only @@ -3052,7 +3056,7 @@ abstract class CommonObject if (empty($totalWeight)) $totalWeight=0; // Avoid warning because $totalWeight is '' if (empty($totalVolume)) $totalVolume=0; // Avoid warning because $totalVolume is '' - + //var_dump($line->volume_units); if ($weight_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { @@ -3369,9 +3373,9 @@ abstract class CommonObject if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; else - print ''.$langs->trans('CostPrice').''; + print ''.$langs->trans('CostPrice').''; } - + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) print ''.$langs->trans('MarginRate').''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) @@ -3906,7 +3910,7 @@ abstract class CommonObject if ($filefound) { global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db - + require_once $file; $obj = new $classname($this->db); @@ -3965,7 +3969,7 @@ abstract class CommonObject // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) + if (in_array(get_class($this), array('Adherent'))) { $arrayofrecords = array(); // The write_file of templates of adherent class need this $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); @@ -4226,7 +4230,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); - + //Eliminate copied source object extra_fields that do not exist in target object $new_array_options=array(); foreach ($this->array_options as $key => $value) { @@ -4275,7 +4279,7 @@ abstract class CommonObject { if (is_numeric($value)) $res=$object->fetch($value); else $res=$object->fetch('',$value); - + if ($res > 0) $this->array_options[$key]=$object->id; else { diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0c78e89fa9e..ea1048fd4d1 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -121,7 +121,7 @@ class HookManager * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. */ - function executeHooks($method, $parameters=false, &$object='', &$action='') + function executeHooks($method, $parameters=array(), &$object='', &$action='') { if (! is_array($this->hooks) || empty($this->hooks)) return ''; @@ -200,9 +200,9 @@ class HookManager // test to avoid running twice a hook, when a module implements several active contexts if (in_array($module,$modulealreadyexecuted)) continue; - + dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context); - + $modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice // Clean class (an error may have been set from a previous call of another method for same module/hook) @@ -229,7 +229,7 @@ class HookManager // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) else { - // TODO. this should be done into the method of hook by returning nothing + // TODO. this test should be done into the method of hook by returning nothing if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); @@ -237,7 +237,7 @@ class HookManager if (! empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; - // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string. we must use $actionclassinstance->resprints to return a string + // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string if (! is_array($resaction) && ! is_numeric($resaction)) { dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index dedac785362..b440c012f04 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5683,7 +5683,7 @@ class Form /** * Return a HTML area with the reference of object and a navigation bar for a business object - * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. + * Note: To add a particular filter on select, you can have $object->next_prev_filter set to add SQL criterias. * * @param object $object Object to show. * @param string $paramid Name of parameter to use to name the id into the URL next/previous link. @@ -5701,12 +5701,20 @@ class Form */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') { - global $langs,$conf; + global $langs,$conf,$hookmanager; $ret=''; if (empty($fieldid)) $fieldid='rowid'; if (empty($fieldref)) $fieldref='ref'; + // Add where from hooks + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters, $object); // Note that $action and $object may have been modified by hook + $object->next_prev_filter.=$hookmanager->resPrint; + } + //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0943bc1a7af..44670d7a5c1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -972,7 +972,8 @@ function dol_get_fiche_end($notab=0) } /** - * Show tab footer of a card + * Show tab footer of a card. + * Note: $object->next_prev_filter can be set to restrict select to find next or previous record by $form->showrefnav. * * @param object $object Object to show * @param string $paramid Name of parameter to use to name the id into the URL next/previous link From bec6ad9fb30f1c7037014fdab1d107a2173b8bc0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 10:22:07 +0200 Subject: [PATCH 017/342] Fix bad position of hook --- htdocs/product/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 56508616edd..c882390a56a 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -119,11 +119,11 @@ $prodser[0][0]=$prodser[0][1]=$prodser[1][0]=$prodser[1][1]=0; $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity($product_static->element, 1).')'; -$sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; $result = $db->query($sql); while ($objp = $db->fetch_object($result)) { From b92980c6ff71c83252a65a16a5b13e75b982435b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 10:38:06 +0200 Subject: [PATCH 018/342] Fix statistics on products --- htdocs/langs/en_US/products.lang | 8 ++++--- htdocs/product/index.php | 38 +++++++++++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 0ab21cae322..ae9cd743c8f 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -25,11 +25,13 @@ ProductAccountancySellCode=Accountancy code (sale) ProductOrService=Product or Service ProductsAndServices=Products and Services ProductsOrServices=Products or Services -ProductsOnSell=Product for sale or for purchase +ProductsOnSaleOnly=Products for sale only +ProductsOnPurchaseOnly=Product for purchase only ProductsNotOnSell=Product not for sale and not for purchase ProductsOnSellAndOnBuy=Products for sale and for purchase -ServicesOnSell=Services for sale or for purchase -ServicesNotOnSell=Services not for sale +ServicesOnSaleOnly=Services for sale only +ServicesOnPurchaseOnly=Services for purchase only +ServicesNotOnSell=Services not for sale and not for purchase ServicesOnSellAndOnBuy=Services for sale and for purchase LastModifiedProductsAndServices=Latest %s modified products/services LastRecordedProducts=Latest %s recorded products diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 49a80859bd9..a09a8069b9e 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -84,7 +84,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_product']=array('text'=>'ProductOrService'); } - + if (count($listofsearchfields)) { print ''; @@ -100,7 +100,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; $i++; } - print ''; + print ''; print ''; print '
'; } @@ -111,7 +111,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele * Number of products and/or services */ $prodser = array(); -$prodser[0][0]=$prodser[0][1]=$prodser[1][0]=$prodser[1][1]=0; +$prodser[0][0]=$prodser[0][1]=$prodser[0][2]=$prodser[0][3]=0; +$prodser[1][0]=$prodser[1][1]=$prodser[1][2]=$prodser[1][3]=0; $sql = "SELECT COUNT(p.rowid) as total, p.fk_product_type, p.tosell, p.tobuy"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; @@ -120,9 +121,10 @@ $sql.= " GROUP BY p.fk_product_type, p.tosell, p.tobuy"; $result = $db->query($sql); while ($objp = $db->fetch_object($result)) { - $status=2; - if (! $objp->tosell && ! $objp->tobuy) $status=0; // To sell OR to buy - if ((! $objp->tosell && $objp->tobuy) || ($objp->tosell && ! $objp->tobuy)) $status=1; + $status=3; + if (! $objp->tosell && ! $objp->tobuy) $status=0; // Not on sale, not on purchase + if ($objp->tosell && ! $objp->tobuy) $status=1; // On sale only + if (! $objp->tosell && $objp->tobuy) $status=2; // On purchase only $prodser[$objp->fk_product_type][$status]=$objp->total; } @@ -134,10 +136,13 @@ if (! empty($conf->product->enabled)) $statProducts.= ''.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).''; $statProducts.= ""; $statProducts.= ''; - $statProducts.= ''.$langs->trans("ProductsOnSell").''.round($prodser[0][1]).''; + $statProducts.= ''.$langs->trans("ProductsOnSaleOnly").''.round($prodser[0][1]).''; $statProducts.= ""; $statProducts.= ''; - $statProducts.= ''.$langs->trans("ProductsOnSellAndOnBuy").''.round($prodser[0][2]).''; + $statProducts.= ''.$langs->trans("ProductsOnPurchaseOnly").''.round($prodser[0][2]).''; + $statProducts.= ""; + $statProducts.= ''; + $statProducts.= ''.$langs->trans("ProductsOnSellAndOnBuy").''.round($prodser[0][3]).''; $statProducts.= ""; } @@ -147,10 +152,13 @@ if (! empty($conf->service->enabled)) $statServices.= ''.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).''; $statServices.= ""; $statServices.= ''; - $statServices.= ''.$langs->trans("ServicesOnSell").''.round($prodser[1][1]).''; + $statServices.= ''.$langs->trans("ServicesOnSaleOnly").''.round($prodser[1][1]).''; $statServices.= ""; $statServices.= ''; - $statServices.= ''.$langs->trans("ServicesOnSellAndOnBuy").''.round($prodser[1][2]).''; + $statServices.= ''.$langs->trans("ServicesOnPurchaseOnly").''.round($prodser[1][2]).''; + $statServices.= ""; + $statServices.= ''; + $statServices.= ''.$langs->trans("ServicesOnSellAndOnBuy").''.round($prodser[1][3]).''; $statServices.= ""; } @@ -220,7 +228,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS while ($i < $num) { $obj = $db->fetch_object($result); - + print ''.$obj->label.''.$obj->nb.''; $total+=$obj->nb; $i++; @@ -292,7 +300,7 @@ if ($result) } } - + print ''; print ''; $product_static->id=$objp->rowid; @@ -419,7 +427,7 @@ function activitytrim($product_type) $i = 0; $var=true; - + while ($i < $num) { $objp = $db->fetch_object($result); @@ -427,7 +435,7 @@ function activitytrim($product_type) { if ($trim1+$trim2+$trim3+$trim4 > 0) { - + print ''.$tmpyear.''; print ''.price($trim1).''; print ''.price($trim2).''; @@ -461,7 +469,7 @@ function activitytrim($product_type) } if ($trim1+$trim2+$trim3+$trim4 > 0) { - + print ''.$tmpyear.''; print ''.price($trim1).''; print ''.price($trim2).''; From 02781b41ca3ac52a1df93a4badc32bdaacf71d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 11:02:34 +0200 Subject: [PATCH 019/342] Fix several problem with hook printFieldListWhere --- htdocs/core/boxes/box_produits.php | 9 +- .../core/boxes/box_produits_alerte_stock.php | 11 +- htdocs/product/class/product.class.php | 125 +++++++++--------- htdocs/product/class/service.class.php | 9 +- 4 files changed, 91 insertions(+), 63 deletions(-) diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 51ee156fbeb..c495c83f867 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -53,7 +53,7 @@ class box_produits extends ModeleBoxes */ function loadBox($max=5) { - global $user, $langs, $db, $conf; + global $user, $langs, $db, $conf, $hookmanager; $this->max=$max; @@ -69,6 +69,13 @@ class box_produits extends ModeleBoxes $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + // Add where from hooks + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + } $sql.= $db->order('p.datec', 'DESC'); $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 884cf92b52a..c8c856684af 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -55,7 +55,7 @@ class box_produits_alerte_stock extends ModeleBoxes */ function loadBox($max=5) { - global $user, $langs, $db, $conf; + global $user, $langs, $db, $conf, $hookmanager; $this->max=$max; @@ -74,7 +74,14 @@ class box_produits_alerte_stock extends ModeleBoxes $sql.= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; + // Add where from hooks + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + } + $sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity"; $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL","0","s.reel").") < p.seuil_stock_alerte"; $sql.= $db->order('p.seuil_stock_alerte', 'DESC'); $sql.= $db->plimit($max, 0); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 48badb5623e..0f28ffdea30 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -108,7 +108,7 @@ class Product extends CommonObject var $localtax2_tx; var $localtax1_type; var $localtax2_type; - + //! Stock real var $stock_reel; //! Stock virtual @@ -196,7 +196,7 @@ class Product extends CommonObject public $fourn_pu; public $fourn_price_base_type; - + /** * @deprecated * @see ref_supplier @@ -306,7 +306,7 @@ class Product extends CommonObject if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; if (empty($this->localtax1_type)) $this->localtax1_type = '0'; if (empty($this->localtax2_type)) $this->localtax2_type = '0'; - + if (empty($this->price)) $this->price = 0; if (empty($this->price_min)) $this->price_min = 0; @@ -675,7 +675,7 @@ class Product extends CommonObject $org->fetch($this->id); $this->oldcopy=$org; } - + // Test if batch management is activated on existing product // If yes, we create missing entries into product_batch if ($this->hasbatch() && !$this->oldcopy->hasbatch()) @@ -691,7 +691,7 @@ class Product extends CommonObject $qty_batch = 0; foreach ($ObjW->detail_batch as $detail) // Each lines of detail in product_batch of the current $ObjW = product_stock { - if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') + if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') { // We discard this line, we will create it later $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; @@ -703,7 +703,7 @@ class Product extends CommonObject } continue; } - + $qty_batch += $detail->qty; } // Quantities in batch details are not same as stock quantity, @@ -711,7 +711,7 @@ class Product extends CommonObject if ($ObjW->real <> $qty_batch) { $ObjBatch = new Productbatch($this->db); - $ObjBatch->batch = $valueforundefinedlot; + $ObjBatch->batch = $valueforundefinedlot; $ObjBatch->qty = ($ObjW->real - $qty_batch); $ObjBatch->fk_product_stock = $ObjW->id; @@ -738,7 +738,7 @@ class Product extends CommonObject $sql.= ", localtax2_tx = " . $this->localtax2_tx; $sql.= ", localtax1_type = " . ($this->localtax1_type!=''?"'".$this->localtax1_type."'":"'0'"); $sql.= ", localtax2_type = " . ($this->localtax2_type!=''?"'".$this->localtax2_type."'":"'0'"); - + $sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'"); $sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type)); @@ -924,8 +924,8 @@ class Product extends CommonObject if ($result < 0) { $error++; } // End call triggers } - - // Delete from product_batch on product delete + + // Delete from product_batch on product delete if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; @@ -940,7 +940,7 @@ class Product extends CommonObject $this->errors[] = $this->db->lasterror(); } } - + // Delete all child tables if (! $error) { @@ -1038,7 +1038,7 @@ class Product extends CommonObject function setMultiLangs($user) { global $conf, $langs; - + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2); $current_lang = $langs->getDefaultLang(); @@ -1357,7 +1357,7 @@ class Product extends CommonObject $sql.= " WHERE pfp.rowid = ".$prodfournprice; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; - + dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -1487,7 +1487,7 @@ class Product extends CommonObject // If multiprices are enabled, then we check if the current product is subject to price autogeneration // Price will be modified ONLY when the first one is the one that is being modified - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1)) { return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq); } @@ -1555,7 +1555,7 @@ class Product extends CommonObject } if (empty($localtax1)) $localtax1=0; // If = '' then = 0 if (empty($localtax2)) $localtax2=0; // If = '' then = 0 - + $this->db->begin(); // Ne pas mettre de quote sur les numeriques decimaux. @@ -1601,7 +1601,7 @@ class Product extends CommonObject $this->localtax2_tx = $localtax2; $this->localtax1_type = $localtaxtype1; $this->localtax2_type = $localtaxtype2; - + // Price by quantity $this->price_by_qty = $newpsq; @@ -1702,7 +1702,7 @@ class Product extends CommonObject $this->url = $obj->url; $this->note_private = $obj->note_private; $this->note = $obj->note_private; // deprecated - + $this->type = $obj->fk_product_type; $this->status = $obj->tosell; $this->status_buy = $obj->tobuy; @@ -1726,7 +1726,7 @@ class Product extends CommonObject $this->localtax2_tx = $obj->localtax2_tx; $this->localtax1_type = $obj->localtax1_type; $this->localtax2_type = $obj->localtax2_type; - + $this->finished = $obj->finished; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration,0,dol_strlen($obj->duration)-1); @@ -1773,7 +1773,7 @@ class Product extends CommonObject // multilangs if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); - + // Load multiprices array if (! empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -2006,29 +2006,29 @@ class Product extends CommonObject $this->stats_commande['rows']=$obj->nb_rows; $this->stats_commande['qty']=$obj->qty?$obj->qty:0; - // if it's a virtual product, maybe it is in order by extension + // if it's a virtual product, maybe it is in order by extension if (! empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) - { + { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { foreach($TFather as &$fatherData) { $pFather = new Product($this->db); - $pFather->id = $fatherData['id']; + $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; - + if ($fatherData['incdec']) { $pFather->load_stats_commande($socid, $filtrestatut); - + $this->stats_commande['customers']+=$pFather->stats_commande['customers']; $this->stats_commande['nb']+=$pFather->stats_commande['nb']; $this->stats_commande['rows']+=$pFather->stats_commande['rows']; $this->stats_commande['qty']+=$pFather->stats_commande['qty'] * $qtyCoef; - + } } } } - + return 1; } else @@ -2432,7 +2432,7 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_propal"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; @@ -2464,7 +2464,7 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_supplier_proposal"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; @@ -2479,7 +2479,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode); } - + /** * Return nb of units or orders in which product is included * @@ -2526,7 +2526,7 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; @@ -2715,7 +2715,7 @@ class Product extends CommonObject $now=dol_now(); dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); - + if ($ref_fourn) { $sql = "SELECT rowid, fk_product"; @@ -3104,7 +3104,7 @@ class Product extends CommonObject function getChildsArbo($id, $firstlevelonly=0, $level=1) { global $alreadyfound; - + $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."product_association as pa"; @@ -3113,18 +3113,18 @@ class Product extends CommonObject $sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); - + if ($level == 1) $alreadyfound=array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly // Protection against infinite loop if ($level > 30) return array(); - + $res = $this->db->query($sql); if ($res) { $prods = array(); while ($rec = $this->db->fetch_array($res)) { - if (! empty($alreadyfound[$rec['rowid']])) + if (! empty($alreadyfound[$rec['rowid']])) { dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); continue; @@ -3194,7 +3194,7 @@ class Product extends CommonObject $result=''; $newref=$this->ref; if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); - + if ($this->type == Product::TYPE_PRODUCT) $label = '' . $langs->trans("ShowProduct") . ''; if ($this->type == Product::TYPE_SERVICE) $label = '' . $langs->trans("ShowService") . ''; if (! empty($this->ref)) @@ -3217,13 +3217,13 @@ class Product extends CommonObject { // } - if (! empty($this->entity)) + if (! empty($this->entity)) { $tmpphoto = $this->show_photos($conf->product->multidir_output[$this->entity],1,1,0,0,0,80); - if ($this->nbphoto > 0) $label .= '
' . $tmpphoto; + if ($this->nbphoto > 0) $label .= '
' . $tmpphoto; } - + $linkclose=''; if (empty($notooltip)) { @@ -3235,7 +3235,7 @@ class Product extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; $linkclose.=' class="classfortooltip"'; - + if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -3260,7 +3260,7 @@ class Product extends CommonObject $linkstart = ''; $linkend=''; - + if ($withpicto) { if ($this->type == Product::TYPE_PRODUCT) $result.=($linkstart.img_object(($notooltip?'':$label), 'product', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend.' '); if ($this->type == Product::TYPE_SERVICE) $result.=($linkstart.img_object(($notooltip?'':$label), 'service', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend.' '); @@ -3303,7 +3303,7 @@ class Product extends CommonObject function LibStatut($status,$mode=0,$type=0) { global $conf, $langs; - + $langs->load('products'); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); @@ -3473,14 +3473,14 @@ class Product extends CommonObject /** * Load information about stock of a product into stock_reel, stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) - * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. + * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. * If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible. * - * @param string $option '' = Load all stock info, also from closed and internal warehouses, - * 'nobatch' = Do not load batch information, + * @param string $option '' = Load all stock info, also from closed and internal warehouses, + * 'nobatch' = Do not load batch information, * 'novirtual' = Do not load virtual stock, * 'warehouseopen' = Load stock from open warehouses, - * 'warehouseclosed' = Load stock from closed warehouses, + * 'warehouseclosed' = Load stock from closed warehouses, * 'warehouseinternal' = Load stock from warehouses for internal correct/transfer only * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock, getBatchInfo @@ -3488,26 +3488,26 @@ class Product extends CommonObject function load_stock($option='') { global $conf; - + $this->stock_reel = 0; $this->stock_warehouse = array(); $this->stock_theorique = 0; $warehouseStatus = array(); - if (preg_match('/warehouseclosed/', $option)) + if (preg_match('/warehouseclosed/', $option)) { $warehouseStatus[] = Entrepot::STATUS_CLOSED; } - if (preg_match('/warehouseopen/', $option)) + if (preg_match('/warehouseopen/', $option)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_ALL; } - if (preg_match('/warehouseinternal/', $option)) + if (preg_match('/warehouseinternal/', $option)) { $warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL; } - + $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; @@ -3537,7 +3537,7 @@ class Product extends CommonObject } $this->db->free($result); - if (! preg_match('/novirtual/', $option)) + if (! preg_match('/novirtual/', $option)) { $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... } @@ -3553,7 +3553,7 @@ class Product extends CommonObject /** * Load value ->stock_theorique of a product. Property this->id must be defined. - * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. + * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. * * @return int < 0 if KO, > 0 if OK * @see load_stock, getBatchInfo @@ -3790,7 +3790,7 @@ class Product extends CommonObject // Find name of thumb file $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; - + // Get filesize of original file $imgarray=dol_getImageSize($dir.$photo); @@ -3804,9 +3804,9 @@ class Product extends CommonObject else if ($nbbyrow < 0) $return .= '
'; $return.= "\n"; - + $relativefile=preg_replace('/^\//', '', $pdir.$photo); - if (empty($nolink)) + if (empty($nolink)) { $urladvanced=getAdvancedPreviewUrl('product', $relativefile); if ($urladvanced) $return.=''; @@ -3817,7 +3817,7 @@ class Product extends CommonObject // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; - + if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { $return.= ''; @@ -4017,7 +4017,7 @@ class Product extends CommonObject */ function load_state_board() { - global $conf, $user; + global $conf, $user, $hookmanager; $this->nb=array(); @@ -4025,6 +4025,13 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; $sql.= " AND p.fk_product_type <> 1"; + // Add where from hooks + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + } $resql=$this->db->query($sql); if ($resql) @@ -4350,7 +4357,7 @@ class Product extends CommonObject return $user->rights->service; } } - + /** * Load information for tab info * diff --git a/htdocs/product/class/service.class.php b/htdocs/product/class/service.class.php index 2cd785527a5..ed78adb5ee5 100644 --- a/htdocs/product/class/service.class.php +++ b/htdocs/product/class/service.class.php @@ -56,7 +56,7 @@ class Service extends CommonObject */ function load_state_board() { - global $conf, $user; + global $conf, $user, $hookmanager; $this->nb=array(); @@ -64,6 +64,13 @@ class Service extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.fk_product_type = 1"; + // Add where from hooks + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + } $resql=$this->db->query($sql); if ($resql) From 92b7914ef39a40d5dc9845ca4fd9694ab54f57e7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 9 Jun 2017 11:09:06 +0200 Subject: [PATCH 020/342] Fix : button convert was still available even if deposit was already converted --- htdocs/compta/facture.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d7f6a5c7dfd..c19c521ca65 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3938,6 +3938,9 @@ else if ($id > 0 || ! empty($ref)) } } + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + // Reopen a standard paid invoice if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) From 62933e9a267dccc6da52e6f534af58eade3fff53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 11:22:42 +0200 Subject: [PATCH 021/342] Fix sql syntax error in some cases --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 835ad698a1b..d98625db1cc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1335,7 +1335,11 @@ abstract class CommonObject if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; - if (! empty($filter)) $sql.=" AND ".$filter; + if (! empty($filter)) + { + if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility + $sql.=$filter; + } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null From 41586b76c045f44afe6c30710f5db280d8e6f693 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 11:31:08 +0200 Subject: [PATCH 022/342] Fix missing css --- htdocs/admin/perms.php | 2 +- htdocs/theme/eldy/style.css.php | 9 ++++++--- htdocs/theme/md/style.css.php | 13 ++++++++----- htdocs/user/perms.php | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 4302222630c..10d72f88bf0 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -189,7 +189,7 @@ if ($result) $var=!$var; print ''; - print ''.img_object('',$picto).' '.$objMod->getName(); + print ''.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName(); print ' '; $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index dd91fc17d28..8d803160325 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -986,6 +986,9 @@ div.nopadding { margin-: 8px; margin-bottom: 4px; } +.pictoobjectwidth { + width: 14px; +} .pictosubstatus { padding-left: 2px; padding-right: 2px; @@ -2972,16 +2975,16 @@ div.tabBar .noborder { border: 1px solid #CCC; text-align: center; border-radius: 2px; - + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - width: 115px; + width: 115px; } @media only screen and (max-width: 767px) { .boxstats { - width: 100px; + width: 100px; } } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 05b127250cb..a047eabef13 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -756,10 +756,10 @@ div.fiche>form>div.div-table-responsive { width: 20px; object-fit: contain; } - + div.statusref { padding-right: 10px; - } + } } .linkobject { cursor: pointer; } @@ -1010,6 +1010,9 @@ table.noborder tr.liste_titre td { margin-: 8px; margin-bottom: 4px; } +.pictoobjectwidth { + width: 14px; +} .pictosubstatus { padding-left: 2px; padding-right: 2px; @@ -2854,16 +2857,16 @@ div .tdtop { text-align: center; border-radius: 2px; min-height: 38px; - + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - width: 115px; + width: 115px; } @media only screen and (max-width: 767px) { .boxstats { - width: 100px; + width: 100px; } } .boxstats:hover { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 082d6286b8a..694ed013318 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -333,7 +333,7 @@ if ($result) { // On affiche ligne pour modifier droits print ''; - print ''.img_object('',$picto).' '.$objMod->getName(); + print ''.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName(); print ''; print ''; print ''.$langs->trans("All").""; @@ -348,7 +348,7 @@ if ($result) print ''; // Picto and label of permission - print ''.img_object('',$picto).' '.$objMod->getName().''; + print ''.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName().''; // Permission and tick if (! empty($object->admin) && ! empty($objMod->rights_admin_allowed)) // Permission own because admin From 1935de03c719a4128a748cde234730192b2ffc57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 12:01:55 +0200 Subject: [PATCH 023/342] Fix bad consistency of labels --- htdocs/product/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 043327920db..40dcd116ab4 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -158,7 +158,7 @@ $arrayfields=array( 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), - 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Purchases").')', 'checked'=>1, 'position'=>1000) + 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked'=>1, 'position'=>1000) ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -473,8 +473,8 @@ else print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; From 985a9ed8d32f56c17c6611c2918c8e6d4ba73b14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 12:12:12 +0200 Subject: [PATCH 024/342] FIX Redirect to payment page from member subscription page failed if a unique security key was defined. --- htdocs/public/members/new.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b101e656f67..03f24c3ec80 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -300,20 +300,27 @@ if ($action == 'add') { if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { - $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; + $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { - $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; + $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) { - $urlback.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2); + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + } + else + { + $urlback.='&securekey='.urlencode($conf->global->PAYPAL_SECURITY_TOKEN); + } } - + } else { From cc37a7d84823b6db24ae6a09d53451ec0c841a35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 13:11:34 +0200 Subject: [PATCH 025/342] Fix parenthesis --- .../prelevement/class/bonprelevement.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 9b86bd66897..0785efe6b1a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -252,7 +252,7 @@ class BonPrelevement extends CommonObject function getErrorString($error) { global $langs; - + $errors = array(); $errors[1027] = $langs->trans("DateInvalid"); @@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject $dir=$conf->prelevement->dir_output.'/receipts'; if (! is_dir($dir)) dol_mkdir($dir); - + $this->filename = $dir.'/'.$ref.'.xml'; // Create withdraw receipt in database @@ -1028,7 +1028,7 @@ class BonPrelevement extends CommonObject $this->emetteur_bic = $account->bic; $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; - + $this->raison_sociale = $account->proprio; } @@ -1572,7 +1572,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.strtoupper(dolEscapeXML(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")))),70,'right','UTF-8',true).''.$CrLf; + $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).''.$CrLf; $XML_DEBITOR .=' '.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1668,7 +1668,7 @@ class BonPrelevement extends CommonObject * @return string String with SEPA Sender */ function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n') - { + { // SEPA INITIALISATION global $conf; @@ -1687,12 +1687,12 @@ class BonPrelevement extends CommonObject $this->emetteur_number_key = $account->cle_rib; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; - + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; - + $this->raison_sociale = $account->proprio; } - + // Récupération info demandeur $sql = "SELECT rowid, ref"; $sql.= " FROM"; From 9341d5f448476a9a52d3b4cdf914706c882c8fcc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 15:35:27 +0200 Subject: [PATCH 026/342] FIX Line of invoices not inserted when using POS module and VAT NPR. --- htdocs/cashdesk/affContenu.php | 6 +- htdocs/cashdesk/class/Facturation.class.php | 26 ++-- htdocs/cashdesk/facturation.php | 45 ++----- htdocs/cashdesk/facturation_verif.php | 115 +++++++++++------- htdocs/cashdesk/tpl/facturation1.tpl.php | 8 +- htdocs/cashdesk/validation_verif.php | 11 +- htdocs/compta/facture/class/facture.class.php | 11 +- htdocs/main.inc.php | 14 +-- 8 files changed, 125 insertions(+), 111 deletions(-) diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 280f2b81908..bd778f3422e 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -34,8 +34,8 @@ if ( $_GET['id'] == 'NOUV' ) // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); + $obj_facturation = unserialize($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { @@ -43,7 +43,7 @@ else $obj_facturation = new Facturation(); } - +// $obj_facturation contains data for all invoice total + selection of current product $obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart'] diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 240b32e34db..4b0ad0bf101 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -99,17 +99,25 @@ class Facturation $product = new Product($db); $product->fetch($this->id); - + $vatrowid = $this->tva(); - + $tmp = getTaxesFromId($vatrowid); - $vat_rate = $tmp['rate']; + $txtva = $tmp['rate'].(empty($tmp['code'])?'':' ('.$tmp['code'].')'); $vat_npr = $tmp['npr']; - + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -136,7 +144,7 @@ class Facturation $newcartarray[$i]['label']=$product->label; $newcartarray[$i]['price']=$product->price; $newcartarray[$i]['price_ttc']=$product->price_ttc; - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { if (isset($product->multiprices[$societe->price_level])) @@ -148,7 +156,7 @@ class Facturation $newcartarray[$i]['fk_article']=$this->id; $newcartarray[$i]['qte']=$this->qte(); - $newcartarray[$i]['fk_tva']=$this->tva(); + $newcartarray[$i]['fk_tva']=$this->tva(); // Vat rowid $newcartarray[$i]['remise_percent']=$remise_percent; $newcartarray[$i]['remise']=price2num($montant_remise_ht); $newcartarray[$i]['total_ht']=price2num($total_ht,'MT'); @@ -220,7 +228,7 @@ class Facturation $this->prix_total_vat = $total_vat; $this->prix_total_localtax1 = $total_localtax1; $this->prix_total_localtax2 = $total_localtax2; - + $this->montant_tva = $total_ttc - $total_ht; //print $this->prix_total_ttc.'eeee'; exit; } diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index dd722805eb6..f4542ec91f8 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -35,7 +35,7 @@ $form=new Form($db); // Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled) -if ( GETPOST('filtre') ) { +if ( GETPOST('filtre','alpha') ) { // Avec filtre $ret=array(); $i=0; @@ -47,22 +47,23 @@ if ( GETPOST('filtre') ) { $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; - $sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; - if (! empty($conf->barcode->enabled)) { - - $filtre = GETPOST('filtre'); + $sql.= " AND ("; + $sql.= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; + if (! empty($conf->barcode->enabled)) + { + $filtre = GETPOST('filtre','alpha'); //If the barcode looks like an EAN13 format and the last digit is included in it, //then whe look for the 12-digit too //As the twelve-digit string will also hit the 13-digit code, we only look for this one if (strlen($filtre) == 13) { $crit_12digit = substr($filtre, 0, 12); - $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%')"; + $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'"; } else { - $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%')"; + $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%'"; } } - else $sql.= ")"; + $sql.= ")"; $sql.= " ORDER BY label"; dol_syslog("facturation.php", LOG_DEBUG); @@ -154,34 +155,6 @@ global $mysoc; $ret=array(); $i=0; -$sql = "SELECT t.rowid, t.taux"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; -$sql.= ", ".MAIN_DB_PREFIX."c_country as c"; -$sql.= " WHERE t.fk_pays = c.rowid"; -$sql.= " AND t.active = 1"; -$sql.= " AND c.code = '".$mysoc->country_code."'"; -//print $sql; - -$resql = $db->query($sql); -if ($resql) -{ - while ( $tab = $db->fetch_array($resql) ) - { - foreach ( $tab as $cle => $valeur ) - { - $ret[$i][$cle] = $valeur; - } - $i++; - } - $db->free($resql); -} -else -{ - dol_print_error($db); -} -$tab_tva = $ret; - - // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation $obj_facturation->getSetPaymentMode('RESET'); $obj_facturation->montantEncaisse('RESET'); diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 95a129e88a5..ec21de2225d 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -32,12 +32,12 @@ $obj_facturation = unserialize($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']); -switch ( $_GET['action'] ) +switch (GETPOST('action','alpha')) { default: if ( $_POST['hdnSource'] != 'NULL' ) { - $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.recuperableonly"; + $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; @@ -54,7 +54,6 @@ switch ( $_GET['action'] ) } $result = $db->query($sql); - if ($result) { // ... et enregistrement dans l'objet @@ -67,62 +66,90 @@ switch ( $_GET['action'] ) $ret[$key] = $value; } // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function - + $productid = $ret['rowid']; $product = new Product($db); $product->fetch($productid); + $prod = $product; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $societe = new Societe($db); $societe->fetch($thirdpartyid); - $tva_tx = get_default_tva($mysoc,$societe,$productid); - $tva_npr = get_default_npr($mysoc,$societe,$productid); + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $societe, $product->id); + $tva_npr = get_default_npr($mysoc, $societe, $product->id); if (empty($tva_tx)) $tva_npr=0; - dol_syslog('tva_tx='.$tva_tx.'-tva_npr='.$tva_npr); - + + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + + // multiprix if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($societe->price_level)) { - if(isset($product->multiprices[$societe->price_level])) - { - $ret['price'] = $product->multiprices[$societe->price_level]; - $ret['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - // $product->multiprices_min[$societe->price_level]; - // $product->multiprices_min_ttc[$societe->price_level]; - // $product->multiprices_base_type[$societe->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level]; - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level]; - if (empty($tva_tx)) $tva_npr=0; - } - } + $pu_ht = $prod->multiprices[$societe->price_level]; + $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; + $price_min = $prod->multiprices_min[$societe->price_level]; + $price_base_type = $prod->multiprices_base_type[$societe->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx=$prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$societe->price_level]; + } + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $societe->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines [0]->price); + $pu_ttc = price($prodcustprice->lines [0]->price_ttc); + $price_base_type = $prodcustprice->lines [0]->price_base_type; + $tva_tx = $prodcustprice->lines [0]->tva_tx; + } + } + else + { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } + } + + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); + $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); + + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tmpvat != $tmpprodvat) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } } - $ret['tva_tx'] = $tva_tx; - $ret['tva_npr'] = $tva_npr; - //var_dump('tva_tx='.$ret['tva_tx'].'-tva_npr='.$ret['tva_npr'].'-'.$conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL);exit; - $obj_facturation->id($ret['rowid']); $obj_facturation->ref($ret['ref']); $obj_facturation->stock($ret['reel']); $obj_facturation->prix($ret['price']); - - // Use $ret['tva_tx'] / ret['tva_npr'] to find vat id - $vatrowid = null; - $sqlfindvatid = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'c_tva'; - $sqlfindvatid.= ' WHERE taux = '.$ret['tva_tx'].' AND recuperableonly = '.(int) $ret['tva_npr']; - $sqlfindvatid.= ' AND fk_pays = '.$mysoc->country_id; - $resqlfindvatid=$db->query($sqlfindvatid); - if ($resqlfindvatid) - { - $obj = $db->fetch_object($resqlfindvatid); - if ($obj) $vatrowid = $obj->rowid; - } - else dol_print_error($db); - - dol_syslog("save vatrowid=".$vatrowid); - $obj_facturation->tva($vatrowid); // Save vat it for next use + + + $vatrate = $tva_tx; + $obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code) // Definition du filtre pour n'afficher que le produit concerne if ( $_POST['hdnSource'] == 'LISTE' ) @@ -168,11 +195,11 @@ switch ( $_GET['action'] ) { dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); - $obj_facturation->tva($_POST['selTva']); // Save VAT selected so we can use it for next product + $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); $obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart'] // We update prixTotalTtc - + } $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 8f74cf98626..fce4df22c7a 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -125,12 +125,12 @@ $langs->load("cashdesk"); - tva(); // Try to get a previously entered VAT rowid. First time, this will return empty. + vatrate; // To get vat rate we just have selected + $buyer = new Societe($db); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); - - echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):-1), $mysoc, $buyer, 0, 0, '', false, -1); + echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):$vatrate), $mysoc, $buyer, 0, 0, '', false, -1); ?> diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index afe73820568..48d2d9bd0c7 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -165,6 +165,7 @@ switch ($action) $tmp = getTaxesFromId($tab_liste[$i]['fk_tva']); $vat_rate = $tmp['rate']; $vat_npr = $tmp['npr']; + $vat_src_code = $tmp['code']; $invoiceline=new FactureLigne($db); $invoiceline->fk_product=$tab_liste[$i]['fk_article']; @@ -173,15 +174,17 @@ switch ($action) $invoiceline->remise_percent=$tab_liste[$i]['remise_percent']; $invoiceline->price=$tab_liste[$i]['price']; $invoiceline->subprice=$tab_liste[$i]['price']; - + $invoiceline->tva_tx=empty($vat_rate)?0:$vat_rate; // works even if vat_rate is '' $invoiceline->info_bits=empty($vat_npr)?0:$vat_npr; - + $invoiceline->vat_src_code=$vat_src_code; + $invoiceline->total_ht=$tab_liste[$i]['total_ht']; $invoiceline->total_ttc=$tab_liste[$i]['total_ttc']; $invoiceline->total_tva=$tab_liste[$i]['total_vat']; $invoiceline->total_localtax1=$tab_liste[$i]['total_localtax1']; $invoiceline->total_localtax2=$tab_liste[$i]['total_localtax2']; + $invoice->lines[]=$invoiceline; } @@ -205,7 +208,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) @@ -245,7 +248,7 @@ switch ($action) { $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0); if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice - + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0); if ($warehouseidtodecrease > 0) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5eeaa4a725e..6c73746d9af 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -519,9 +519,12 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; - $newinvoiceline->origin = $this->element; // TODO This seems not used. Here we but origin 'facture' but after - $newinvoiceline->origin_id = $this->lines[$i]->id; // we put an id of object ! - if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 + + // TODO This seems not used. Here we put origin 'facture' but after, we put an id of object ! + $newinvoiceline->origin = $this->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; + + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($newinvoiceline->product_type != 9 && empty($newinvoiceline->fk_parent_line)) || $newinvoiceline->product_type == 9) { @@ -558,7 +561,7 @@ class Facture extends CommonInvoice //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; - if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9d97770e48a..82f008c2378 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -300,7 +300,7 @@ if (! defined('NOTOKENRENEWAL')) { // roulement des jetons car cree a chaque appel if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; - + // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; @@ -586,7 +586,7 @@ if (! defined('NOLOGIN')) // We are already into an authenticated session $login=$_SESSION["dol_login"]; $entity=$_SESSION["dol_entity"]; - dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); + dol_syslog("- This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); $resultFetchUser=$user->fetch('',$login,'',1,($entity > 0 ? $entity : -1)); if ($resultFetchUser <= 0) @@ -1051,7 +1051,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $ext='version='.urlencode(DOL_VERSION); if (GETPOST('version')) $ext='version='.GETPOST('version','int'); // usefull to force no cache on css/js if (GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) $ext='testmenuhider='.GETPOST('testmenuhider','int'); - + $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss')?'&optioncss='.GETPOST('optioncss','alpha',1):'').'&userid='.$user->id.'&entity='.$conf->entity; $themeparam.=($ext?'&'.$ext:''); if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; @@ -1060,7 +1060,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (GETPOST('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); } if (GETPOST('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); } if (GETPOST('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); } - + if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { print ''."\n"; @@ -1929,7 +1929,7 @@ if (! function_exists("llxFooter")) }); ' . "\n"; } - + // Wrapper to manage dropdown if ($conf->use_javascript_ajax) { @@ -1960,7 +1960,7 @@ if (! function_exists("llxFooter")) console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul"); $(this).parent().parent().hide(); }); - + $(document).bind(\'click\', function (e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); @@ -1968,7 +1968,7 @@ if (! function_exists("llxFooter")) }); '; } - + // A div for the address popup print "\n\n"; print ''."\n"; From 0f80ee757f6c6dfec4de05febc7d23809801376c Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 9 Jun 2017 16:37:05 +0200 Subject: [PATCH 027/342] Fix can not update extrafields values --- htdocs/comm/card.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index f9d9309a755..61fcc4dc502 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -175,6 +175,21 @@ if (empty($reshook)) $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } + + if ($action == 'update_extras') { + $object->fetch($id); + + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error++; + if (! $error) + { + $result = $object->insertExtraFields(); + if ($result < 0) $error++; + } + if ($error) $action = 'edit_extras'; + } } From c1f3a168cd62d7e9b3bbb5f8a1f37343e3e5ecd0 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 9 Jun 2017 16:57:20 +0200 Subject: [PATCH 028/342] Fix wrong attribute name for loop --- htdocs/core/lib/admin.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 6a0336aab38..ba5f099365c 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -825,7 +825,7 @@ function activateModule($value,$withdeps=1) { // Activation of modules this module depends on // this->depends may be array('modModule1', 'mmodModule2') or array('always'=>"modModule1", 'FR'=>'modModule2') - foreach ($objMod->depend as $key => $modulestring) + foreach ($objMod->depends as $key => $modulestring) { if ((! is_numeric($key)) && $key != 'always' && $key != $mysoc->country_code) { From 3347316d3c00a6bb89f124711ab20ba91b3ceb71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 17:02:05 +0200 Subject: [PATCH 029/342] Fix delete of member --- .../actions_adherentcard_common.class.php | 4 +- htdocs/adherents/card.php | 2 +- htdocs/adherents/class/adherent.class.php | 40 ++-- htdocs/adherents/class/api_members.class.php | 6 +- htdocs/adherents/list.php | 119 ++++++------ htdocs/commande/list.php | 180 +++++++++--------- htdocs/core/actions_massactions.inc.php | 2 +- 7 files changed, 177 insertions(+), 176 deletions(-) diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index a749ff269e5..c768b019d69 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -182,7 +182,7 @@ abstract class ActionsAdherentCardCommon $this->object->old_name = $_POST["old_name"]; $this->object->old_firstname = $_POST["old_firstname"]; - $result = $this->object->delete(); + $result = $this->object->delete(0, $user, 0); if ($result > 0) { header("Location: list.php"); @@ -424,7 +424,7 @@ abstract class ActionsAdherentCardCommon if ($resql) { $obj = $this->db->fetch_object($resql); - + $this->object->country_code = $obj->code; $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 81aa2c7c6ad..fe3bd4f4cfd 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -585,7 +585,7 @@ if (empty($reshook)) if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { - $result=$object->delete($id); + $result=$object->delete($id, $user); if ($result > 0) { if (! empty($backtopage)) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 20f5fa671c9..18e144c363c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -705,11 +705,13 @@ class Adherent extends CommonObject * Fonction qui supprime l'adherent et les donnees associees * * @param int $rowid Id of member to delete + * @param User $user User object + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=nothing to do, >0 if OK */ - function delete($rowid) + function delete($rowid, $user, $notrigger=0) { - global $conf, $langs, $user; + global $conf, $langs; $result = 0; $error=0; @@ -720,6 +722,14 @@ class Adherent extends CommonObject $this->db->begin(); + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('MEMBER_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + // Remove category $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -787,16 +797,6 @@ class Adherent extends CommonObject } } - if (! $error) - { - // Call trigger - $result=$this->call_trigger('MEMBER_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers - } - - - if (! $error) { $this->db->commit(); @@ -1592,7 +1592,7 @@ class Adherent extends CommonObject global $conf, $langs; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; - + $result=''; $label=''; $link=''; $linkstart=''; $linkend=''; @@ -1602,7 +1602,7 @@ class Adherent extends CommonObject $label.= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); $label.= '
'; } - + $label.= '
'; $label.= '' . $langs->trans("Member") . ''; if (! empty($this->ref)) @@ -1610,7 +1610,7 @@ class Adherent extends CommonObject if (! empty($this->firstname) || ! empty($this->lastname)) $label.= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs); $label.='
'; - + if ($option == 'card' || $option == 'category') { $link = ''; $linkend=''; - + //if ($withpictoimg == -1) $result.='
'; $result.=$link; if ($withpictoimg) @@ -1658,7 +1658,7 @@ class Adherent extends CommonObject } $result.=$linkend; //if ($withpictoimg == -1) $result.='
'; - + return $result; } @@ -1883,7 +1883,7 @@ class Adherent extends CommonObject $modele = $conf->global->ADHERENT_ADDON_PDF; } } - + $modelpath = "core/modules/member/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 3defcabd059..4d13b6347ec 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -250,11 +250,7 @@ class Members extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // The Adherent::delete() method uses the global variable $user. - global $user; - $user = DolibarrApiAccess::$user; - - if (! $member->delete($member->id)) { + if (! $member->delete($member->id, DolibarrApiAccess::$user)) { throw new RestException(401,'error when deleting member'); } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 06de3e09f95..949d55020c8 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -31,13 +31,17 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->load("members"); -$langs->load("companies"); +$langs->loadLangs(array("members","companies")); + +$action=GETPOST('action','aZ09'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); // Security check $result=restrictedArea($user,'adherent'); -$action=GETPOST('action','aZ09'); $filter=GETPOST("filter"); $statut=GETPOST("statut"); $search=GETPOST("search"); @@ -53,7 +57,7 @@ $search_country=GETPOST("search_country"); $search_phone=GETPOST("search_phone"); $search_phone_perso=GETPOST("search_phone_perso"); $search_phone_mobile=GETPOST("search_phone_mobile"); -$type=GETPOST("type"); +$search_type=GETPOST("search_type"); $search_email=GETPOST("search_email"); $search_categ = GETPOST("search_categ",'int'); $catid = GETPOST("catid",'int'); @@ -155,7 +159,7 @@ if (empty($reshook)) $search_firstname=""; $search_login=""; $search_company=""; - $type=""; + $search_type=""; $search_email=""; $search_address=""; $search_zip=""; @@ -173,6 +177,14 @@ if (empty($reshook)) $toselect=''; $search_array_options=array(); } + + // Mass actions + $objectclass='Adherent'; + $objectlabel='Members'; + $permtoread = $user->rights->adherent->lire; + $permtodelete = $user->rights->adherent->supprimer; + $uploaddir = $conf->adherent->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -193,8 +205,8 @@ $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.pu $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; $sql.= " t.libelle as type, t.subscription,"; $sql.= " state.code_departement as state_code, state.nom as state_name"; -// Add fields for extrafields -foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook @@ -212,7 +224,7 @@ if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_ca if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); -if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); +if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type); if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_ref) { @@ -298,10 +310,10 @@ elseif ($action == 'search') $titre=$langs->trans("MembersListQualified"); } -if ($type > 0) +if ($search_type > 0) { $membertype=new AdherentType($db); - $result=$membertype->fetch(GETPOST("type")); + $result=$membertype->fetch(GETPOST("type",'int')); $titre.=" (".$membertype->libelle.")"; } @@ -326,7 +338,7 @@ if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); if ($filter) $param.="&filter=".urlencode($filter); -if ($type > 0) $param.="&type=".urlencode($type); +if ($search_type > 0) $param.="&search_type=".urlencode($search_type); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields foreach ($search_array_options as $key => $val) @@ -346,7 +358,7 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->tr //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); -print '
'; +print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -403,32 +415,32 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) } // Ref -if (! empty($arrayfields['d.ref']['checked'])) +if (! empty($arrayfields['d.ref']['checked'])) { print ''; print ''; print ''; } -if (! empty($arrayfields['d.firstname']['checked'])) +if (! empty($arrayfields['d.firstname']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.lastname']['checked'])) +if (! empty($arrayfields['d.lastname']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.company']['checked'])) +if (! empty($arrayfields['d.company']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.login']['checked'])) +if (! empty($arrayfields['d.login']['checked'])) { print ''; print ''; @@ -440,26 +452,26 @@ if (! empty($arrayfields['d.morphy']['checked'])) print ''; } -if (! empty($arrayfields['t.libelle']['checked'])) +if (! empty($arrayfields['t.libelle']['checked'])) { print ''; $listetype=$membertypestatic->liste_array(); - print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32); print ''; } -if (! empty($arrayfields['d.address']['checked'])) +if (! empty($arrayfields['d.address']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.zip']['checked'])) +if (! empty($arrayfields['d.zip']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.town']['checked'])) +if (! empty($arrayfields['d.town']['checked'])) { print ''; print ''; @@ -479,31 +491,31 @@ if (! empty($arrayfields['country.code_iso']['checked'])) print ''; } // Phone pro -if (! empty($arrayfields['d.phone']['checked'])) +if (! empty($arrayfields['d.phone']['checked'])) { print ''; print ''; } // Phone perso -if (! empty($arrayfields['d.phone_perso']['checked'])) +if (! empty($arrayfields['d.phone_perso']['checked'])) { print ''; print ''; } // Phone mobile -if (! empty($arrayfields['d.phone_mobile']['checked'])) +if (! empty($arrayfields['d.phone_mobile']['checked'])) { print ''; print ''; } // Email -if (! empty($arrayfields['d.email']['checked'])) +if (! empty($arrayfields['d.email']['checked'])) { print ''; print ''; } -if (! empty($arrayfields['d.datefin']['checked'])) +if (! empty($arrayfields['d.datefin']['checked'])) { print ''; print ''; @@ -626,7 +638,7 @@ while ($i < min($num, $limit)) $memberstatic->datefin= $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; - + if (! empty($obj->fk_soc)) { $memberstatic->fetch_thirdparty(); $companyname=$memberstatic->thirdparty->name; @@ -635,52 +647,52 @@ while ($i < min($num, $limit)) } print ''; - + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''.($i+1).''; } // Ref - if (! empty($arrayfields['d.ref']['checked'])) + if (! empty($arrayfields['d.ref']['checked'])) { print ""; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref'); print "\n"; - } + } // Firstname - if (! empty($arrayfields['d.firstname']['checked'])) + if (! empty($arrayfields['d.firstname']['checked'])) { print ""; print $obj->firstname; print "\n"; } // Lastname - if (! empty($arrayfields['d.lastname']['checked'])) + if (! empty($arrayfields['d.lastname']['checked'])) { print ""; print $obj->lastname; print "\n"; } // Company - if (! empty($arrayfields['d.company']['checked'])) + if (! empty($arrayfields['d.company']['checked'])) { print ""; print $companyname; print "\n"; } // Login - if (! empty($arrayfields['d.login']['checked'])) + if (! empty($arrayfields['d.login']['checked'])) { print "".$obj->login."\n"; } // Moral/Physique - if (! empty($arrayfields['d.morphy']['checked'])) + if (! empty($arrayfields['d.morphy']['checked'])) { print "".$memberstatic->getmorphylib($obj->morphy)."\n"; } // Type label - if (! empty($arrayfields['t.libelle']['checked'])) + if (! empty($arrayfields['t.libelle']['checked'])) { $membertypestatic->id=$obj->type_id; $membertypestatic->libelle=$obj->type; @@ -727,7 +739,7 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Phone pro - if (! empty($arrayfields['d.phone']['checked'])) + if (! empty($arrayfields['d.phone']['checked'])) { print ''; print $obj->phone; @@ -735,7 +747,7 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Phone perso - if (! empty($arrayfields['d.phone_perso']['checked'])) + if (! empty($arrayfields['d.phone_perso']['checked'])) { print ''; print $obj->phone_perso; @@ -743,7 +755,7 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Phone mobile - if (! empty($arrayfields['d.phone_mobile']['checked'])) + if (! empty($arrayfields['d.phone_mobile']['checked'])) { print ''; print $obj->phone_mobile; @@ -756,7 +768,7 @@ while ($i < min($num, $limit)) print "".dol_print_email($obj->email,0,0,1)."\n"; } // End of subscription date - $datefin=$db->jdate($obj->datefin); + $datefin=$db->jdate($obj->datefin); if (! empty($arrayfields['d.datefin']['checked'])) { if ($datefin) @@ -832,22 +844,15 @@ while ($i < min($num, $limit)) } // Action column print ''; - if ($user->rights->adherent->creer) - { - print "rowid."&action=edit&backtopage=1\">".img_edit().""; - } - print ' '; - if ($user->rights->adherent->supprimer && $obj->statut == -1) - { - print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; - } - if ($user->rights->adherent->supprimer && $obj->statut == 1) - { - print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; - } - print ""; - if (! $i) $totalarray['nbfield']++; - + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; $i++; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index dbfeafc8f94..2f8810333f0 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills')); -$action=GETPOST('action','alpha'); +$action=GETPOST('action','aZ09'); $massaction=GETPOST('massaction','alpha'); $show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); @@ -160,7 +160,7 @@ if (empty($reshook)) { // Selection of new fields 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 { @@ -202,51 +202,51 @@ if (empty($reshook)) // TODO Move this into mass action include if ($massaction == 'confirm_createbills') { - + $orders = GETPOST('toselect'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('valdate_invoices', 'int'); - + $TFact = array(); $TFactThird = array(); - + $nb_bills_created = 0; - + $db->begin(); - + foreach($orders as $id_order) { - + $cmd = new Commande($db); if($cmd->fetch($id_order) <= 0) continue; - + $object = new Facture($db); if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { - + $object->socid = $cmd->socid; $object->type = Facture::TYPE_STANDARD; $object->cond_reglement_id = $cmd->cond_reglement_id; $object->mode_reglement_id = $cmd->mode_reglement_id; $object->fk_project = $cmd->fk_project; - + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); } - + $object->date = $datefacture; $object->origin = 'commande'; $object->origin_id = $id_order; - + $res = $object->create($user); - + if($res > 0) $nb_bills_created++; - + } - + if($object->id > 0) { - + $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql.= "fk_source"; @@ -259,7 +259,7 @@ if (empty($reshook)) $sql.= ", ".$object->id; $sql.= ", '".$object->element."'"; $sql.= ")"; - + if ($db->query($sql)) { $db->commit(); @@ -268,17 +268,17 @@ if (empty($reshook)) { $db->rollback(); } - + $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) { $cmd->fetch_lines(); $lines = $cmd->lines; } - + $fk_parent_line=0; $num=count($lines); - + for ($i=0;$i<$num;$i++) { $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); @@ -367,43 +367,43 @@ if (empty($reshook)) $fk_parent_line = $result; } } - } - + } + } - + $cmd->classifyBilled($user); - + if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; } - + // Build doc with all invoices $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - + if(!empty($validate_invoices)) { - + $massaction = $action = 'builddoc'; - + foreach($TAllFact as &$object) { $object->validate($user); $toselect[] = $object->id; // For builddoc action - + // Fac builddoc $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } - + $objectclass='Facture'; $objectlabel='Invoice'; $permtoread = $user->rights->facture->lire; $permtodelete = $user->rights->facture->supprimer; $uploaddir = $conf->facture->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + } - + if (! $error) { $db->commit(); @@ -418,7 +418,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } + } } @@ -596,9 +596,9 @@ if ($resql) $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $num = $db->num_rows($resql); - + $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; @@ -629,7 +629,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + // List of mass actions available $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), @@ -653,12 +653,12 @@ if ($resql) print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); - + // TODO Move this into an invluce if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new Commande($db); @@ -677,14 +677,14 @@ if ($resql) } } } - + print ''; - + dol_fiche_head(null, '', ''); - + $topicmail="SendOrderRef"; $modelmail="order_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -737,23 +737,23 @@ if ($resql) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } elseif ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; - + print ''; print ''; print ''; print ''; print '
'; @@ -780,7 +780,7 @@ if ($resql) print '
'; - + print '
'; print '
'; print ' '; @@ -788,13 +788,13 @@ if ($resql) print '
'; print '
'; } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $moreforfilter=''; // If the user can view prospects other than his' @@ -828,7 +828,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; @@ -839,27 +839,27 @@ 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); - + print '
'; print ''."\n"; print ''; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (! empty($arrayfields['c.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['c.ref_client']['checked'])) + if (! empty($arrayfields['c.ref_client']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (! empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['c.date_delivery']['checked'])) + if (! empty($arrayfields['c.date_delivery']['checked'])) { print ''; - + print "\n"; // Fields title @@ -1014,9 +1014,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -1033,20 +1033,20 @@ if ($resql) 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 ''."\n"; - + $total=0; $subtotal=0; $productstat_cache=array(); - + $generic_commande = new Commande($db); $generic_product = new Product($db); - + $i=0; $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - + print ''; $notshippable=0; @@ -1054,7 +1054,7 @@ if ($resql) $text_info=''; $text_warning=''; $nbprod=0; - + // Ref if (! empty($arrayfields['c.ref']['checked'])) { @@ -1070,12 +1070,12 @@ if ($resql) $generic_commande->total_ttc = $obj->total_ttc; $generic_commande->lines=array(); $generic_commande->getLinesArray(); - + print '
'; print ''; print ''; print ''; print ''; print ''; @@ -899,7 +899,7 @@ if ($resql) $formother->select_year($orderyear?$orderyear:-1,'orderyear',1, 20, 5); print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; @@ -972,10 +972,10 @@ if ($resql) { print ''; $liststatus=array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); @@ -993,7 +993,7 @@ if ($resql) $searchpicto=$form->showFilterButtons(); print $searchpicto; print '
'; print ''; - + // Show shippable Icon (create subloop, so may be slow) if ($conf->stock->enabled) { @@ -1083,7 +1083,7 @@ if ($resql) if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) { $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig=0; $lig < $numlines; $lig++) + for ($lig=0; $lig < $numlines; $lig++) { if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service { @@ -1107,8 +1107,8 @@ if ($resql) $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel; $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique; $text_info .= '
'; - - if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) + + if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) { $notshippable++; } @@ -1168,7 +1168,7 @@ if ($resql) $text_info = $langs->trans('NonShippable').'
'.$text_info; } } - + print ''; } - + // Warning late icon and note print ''; - + print ''; print '
'; print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$obj->fk_statut)); print ''; if ($nbprod) { @@ -1179,7 +1179,7 @@ if ($resql) } print ''; if ($generic_commande->hasDelay()) { @@ -1192,7 +1192,7 @@ if ($resql) print ''; } print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); @@ -1200,11 +1200,11 @@ if ($resql) print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
'; - + print ''; if (! $i) $totalarray['nbfield']++; } - + // Ref customer if (! empty($arrayfields['c.ref_client']['checked'])) { @@ -1222,7 +1222,7 @@ if ($resql) { print ''; print $companystatic->getNomUrl(1,'customer'); - + // If module invoices enabled and user with invoice creation permissions if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { @@ -1278,7 +1278,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Order date if (! empty($arrayfields['c.date_commande']['checked'])) { @@ -1319,7 +1319,7 @@ if ($resql) if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; $totalarray['totalttc'] += $obj->total_ttc; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1370,7 +1370,7 @@ if ($resql) print ''.yn($obj->billed).''; if (! $i) $totalarray['nbfield']++; } - + // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -1381,9 +1381,9 @@ if ($resql) } print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; - + $total+=$obj->total_ht; $subtotal+=$obj->total_ht; $i++; @@ -1416,14 +1416,14 @@ if ($resql) } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print ''."\n"; print '
'; - + print ''."\n"; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) @@ -1433,18 +1433,18 @@ if ($resql) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->commande->lire; $delallowed=$user->rights->commande->supprimer; - + print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { print '
'.$langs->trans("ShowTempMassFilesArea").''; } - + } else { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index fde828fd6d4..20b3d155a27 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -536,7 +536,7 @@ if (! $error && $massaction == 'delete' && $permtodelete) $result=$objecttmp->fetch($toselectid); if ($result > 0) { - if ($objecttmp->element == 'societe') $result = $objecttmp->delete($objecttmp->id, $user, 1); + if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); if ($result <= 0) { From 0458b7d38f9610bd3e3ef2fae83722b39d48c55f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 17:29:34 +0200 Subject: [PATCH 030/342] Fix css subscription form --- htdocs/adherents/admin/public.php | 13 ++++--------- htdocs/public/members/new.php | 29 +++++++++++++++-------------- htdocs/theme/eldy/style.css.php | 5 ++++- htdocs/theme/md/style.css.php | 5 ++++- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index 141c39d7e9e..940c6c6e457 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -115,16 +115,11 @@ if ($conf->use_javascript_ajax) { if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') { - jQuery("#tramount").hide(); - jQuery("#tredit").hide(); - jQuery("#trpayment").hide(); - jQuery("#tremail").hide(); + jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide(); } if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') { - jQuery("#tramount").show(); - jQuery("#tredit").show(); - jQuery("#trpayment").show(); + jQuery("#trforcetype, #tramount, #tredit, #trpayment").show(); if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide(); else jQuery("#tremail").show(); } @@ -156,9 +151,9 @@ print "\n"; // Force Type $adht = new AdherentType($db); -print ''; +print ''; print $langs->trans("ForceMemberType"); -print ''; +print ''; $listofval = array(-1 => $langs->trans("Undefined")); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index a2cab708281..f174c51cc74 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -115,7 +115,7 @@ function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayo print 'Logo'; print '

'; - print '
'; + print '
'; } /** @@ -407,8 +407,9 @@ print ''; print ''; print ''; +print '
'; -print '
'.$langs->trans("FieldsWithAreMandatory",'*').'
'; +print '
'.$langs->trans("FieldsWithAreMandatory",'*').'
'; //print $langs->trans("FieldsWithIsForPublic",'**').'
'; dol_fiche_head(''); @@ -448,7 +449,7 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) $defaulttype=''; $isempty=1; if (count($listoftype)==1) { $defaulttype=$tmp[0]; $isempty=0; } - print ''.$langs->trans("Type").' *'; + print ''.$langs->trans("Type").' *'; print $form->selectarray("type", $adht->liste_array(), GETPOST('type')?GETPOST('type'):$defaulttype, $isempty); print ''."\n"; } @@ -463,7 +464,7 @@ $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''.$langs->trans('Nature').' *'."\n"; + print ''.$langs->trans('Nature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print ''."\n"; } @@ -473,14 +474,14 @@ else print ''; } // Civility -print ''.$langs->trans('UserTitle').''; +print ''.$langs->trans('UserTitle').''; print $formcompany->select_civility(GETPOST('civility_id'),'civility_id').''."\n"; // Lastname -print ''.$langs->trans("Lastname").' *'."\n"; +print ''.$langs->trans("Lastname").' *'."\n"; // Firstname -print ''.$langs->trans("Firstname").' *'."\n"; +print ''.$langs->trans("Firstname").' *'."\n"; // Company -print ''.$langs->trans("Company").''."\n"; +print ''.$langs->trans("Company").''."\n"; // Address print ''.$langs->trans("Address").''."\n"; print ''."\n"; @@ -491,7 +492,7 @@ print ' / '; print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode','selectcountry_id','state_id'), 0, 1); print ''; // Country -print ''.$langs->trans('Country').''; +print ''.$langs->trans('Country').''; $country_id=GETPOST('country_id'); if (! $country_id && ! empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) $country_id=getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,2,$db,$langs); if (! $country_id && ! empty($conf->geoipmaxmind->enabled)) @@ -517,20 +518,20 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) print ''; } // EMail -print ''.$langs->trans("Email").' *'."\n"; +print ''.$langs->trans("Email").' *'."\n"; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' *'."\n"; - print ''.$langs->trans("Password").' *'."\n"; - print ''.$langs->trans("PasswordAgain").' *'."\n"; + print ''.$langs->trans("Login").' *'."\n"; + print ''.$langs->trans("Password").' *'."\n"; + print ''.$langs->trans("PasswordAgain").' *'."\n"; } // Birthday print ''.$langs->trans("DateToBirth").''; print $form->select_date($birthday,'birth',0,0,1,"newmember",1,0,1); print ''."\n"; // Photo -print ''.$langs->trans("URLPhoto").''."\n"; +print ''.$langs->trans("URLPhoto").''."\n"; // Public print ''.$langs->trans("Public").''."\n"; // Extrafields diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9ba91c33475..320d4f1859b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -792,6 +792,8 @@ div.fiche>form>div.div-table-responsive { /* Force values for small screen 570 */ @media only screen and (max-width: 570px) { + .divmainbodylarge { margin-left: 20px !important; margin-right: 20px !important; } + .tdoverflowonsmartphone { max-width: 0; overflow: hidden; @@ -3077,7 +3079,8 @@ div.titre { #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } #tablepublicpayment tr.liste_total td { border-top: none; } -#divsubscribe { width: 700px; } +.divmainbodylarge { margin-left: 40px; margin-right: 40px; } +#divsubscribe { max-width: 900px; } #tablesubscribe { width: 100%; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a1d26705d46..c21aafd407f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -794,6 +794,8 @@ div.fiche>form>div.div-table-responsive { /* Force values for small screen 570 */ @media only screen and (max-width: 570px) { + .divmainbodylarge { margin-left: 20px; margin-right: 20px; } + .tdoverflowonsmartphone { max-width: 0; overflow: hidden; @@ -3156,7 +3158,8 @@ div.titre { #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } #tablepublicpayment tr.liste_total td { border-top: none; } -#divsubscribe { width: 700px; } +.divmainbodylarge { margin-left: 40px; margin-right: 40px; } +#divsubscribe { max-width: 900px; } #tablesubscribe { width: 100%; } From 884c6c674ddfd7717adea8cc18f16477e1ce7547 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Jun 2017 20:08:23 +0200 Subject: [PATCH 031/342] Fix css --- htdocs/core/class/html.form.class.php | 7 ++----- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- htdocs/user/class/user.class.php | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ac17e1d9e17..7c8efcc8328 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6083,7 +6083,7 @@ class Form } else { - $nophoto='/public/theme/common/nophoto.png'; + $nophoto='/public/theme/common/nophoto.png'; if (in_array($modulepart,array('userphoto','contact'))) // For module that are "physical" users { $nophoto='/public/theme/common/user_anonymous.png'; @@ -6102,10 +6102,7 @@ class Form } else { - if ($conf->browser->layout != 'phone') - { - $ret.='No photo'; - } + $ret.='No photo'; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 320d4f1859b..3b2ba307bbd 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4188,7 +4188,7 @@ dl.dropdown { position:absolute; top:2px; list-style:none; - max-height: 280px; + max-height: 270px; overflow: auto; } .dropdown span.value { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c21aafd407f..927830da51d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4275,7 +4275,7 @@ dl.dropdown { position:absolute; top:2px; list-style:none; - max-height: 280px; + max-height: 270px; overflow: auto; } .dropdown span.value { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a69ed968dfb..6b39158a87b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2096,9 +2096,9 @@ class User extends CommonObject $paddafterimage=''; if (abs($withpictoimg) == 1) $paddafterimage='style="margin-right: 3px;"'; // Only picto - if ($withpictoimg > 0) $picto='
'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'
'; + if ($withpictoimg > 0) $picto='
'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'
'; // Picto must be a photo - else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'
'; + else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'
'; $result.=$picto; } if ($withpictoimg > -2 && $withpictoimg != 2) From 58a407d9f1681f3b60449d9460dd33002afc9e09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 00:05:47 +0200 Subject: [PATCH 032/342] Fix style and align when no permission on widget --- htdocs/admin/defaultvalues.php | 26 ++--- htdocs/admin/ldap.php | 6 +- htdocs/admin/ldap_contacts.php | 8 +- htdocs/admin/ldap_groups.php | 10 +- htdocs/admin/ldap_members.php | 6 +- htdocs/admin/ldap_users.php | 2 +- htdocs/admin/perms.php | 4 +- htdocs/admin/translation.php | 103 +++++++++--------- htdocs/core/boxes/box_actions.php | 6 +- htdocs/core/boxes/box_bookmarks.php | 4 +- htdocs/core/boxes/box_clients.php | 6 +- htdocs/core/boxes/box_commandes.php | 4 +- htdocs/core/boxes/box_comptes.php | 4 +- htdocs/core/boxes/box_contacts.php | 4 +- htdocs/core/boxes/box_contracts.php | 6 +- htdocs/core/boxes/box_factures.php | 4 +- htdocs/core/boxes/box_factures_fourn.php | 4 +- htdocs/core/boxes/box_factures_fourn_imp.php | 4 +- htdocs/core/boxes/box_factures_imp.php | 4 +- htdocs/core/boxes/box_ficheinter.php | 6 +- htdocs/core/boxes/box_fournisseurs.php | 4 +- htdocs/core/boxes/box_goodcustomers.php | 8 +- .../boxes/box_graph_invoices_permonth.php | 8 +- .../box_graph_invoices_supplier_permonth.php | 8 +- .../core/boxes/box_graph_orders_permonth.php | 6 +- .../box_graph_orders_supplier_permonth.php | 6 +- .../boxes/box_graph_product_distribution.php | 24 ++-- .../boxes/box_graph_propales_permonth.php | 6 +- htdocs/core/boxes/box_members.php | 4 +- htdocs/core/boxes/box_produits.php | 4 +- .../core/boxes/box_produits_alerte_stock.php | 4 +- htdocs/core/boxes/box_propales.php | 4 +- htdocs/core/boxes/box_prospect.php | 4 +- htdocs/core/boxes/box_services_contracts.php | 6 +- htdocs/core/boxes/box_services_expired.php | 8 +- htdocs/core/boxes/box_supplier_orders.php | 4 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/theme/eldy/style.css.php | 3 +- htdocs/theme/md/style.css.php | 2 +- 39 files changed, 182 insertions(+), 156 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index bd539becb86..94682cd502f 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -182,29 +182,29 @@ $formadmin = new FormAdmin($db); $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; llxHeader('',$langs->trans("Setup"),$wikihelp); -print load_fiche_titre($langs->trans("DefaultValues"),'','title_setup'); +$param='&mode='.$mode; -print $langs->trans("DefaultValuesDesc")."
\n"; -print "
\n"; - -print $langs->trans("EnableDefaultValues").' '; +$enabledisablehtml.= $langs->trans("EnableDefaultValues").' '; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); - print ''; + $enabledisablehtml.= ''; + $enabledisablehtml.= img_picto($langs->trans("Disabled"),'switch_off'); + $enabledisablehtml.= ''; } else { // Button on, click to disable - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - print ''; + $enabledisablehtml.= ''; + $enabledisablehtml.= img_picto($langs->trans("Activated"),'switch_on'); + $enabledisablehtml.= ''; } -print "

\n"; -$param='&mode='.$mode; +print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup'); + +print $langs->trans("DefaultValuesDesc")."
\n"; +print "
\n"; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($optioncss != '') $param.='&optioncss='.$optioncss; diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 4d8dab035ca..dd084894b3d 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -100,7 +100,7 @@ $form=new Form($db); print '
'; print ''; -dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); +dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1); print ''; @@ -127,7 +127,7 @@ print ''; // Synchro contact active if (! empty($conf->societe->enabled)) { - + print ''; - print ''; - + $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle)); print ''; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 0c4e40948ed..8a6c38ffe46 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -107,7 +107,7 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) if (! $error) { $db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".$db->escape($conf->entity).")"; $result = $db->query($sql); if ($result > 0) @@ -126,7 +126,7 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) { setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); } - else + else { setEventMessages($db->lasterror(), null, 'errors'); } @@ -164,7 +164,25 @@ $formadmin = new FormAdmin($db); $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; llxHeader('',$langs->trans("Setup"),$wikihelp); -print load_fiche_titre($langs->trans("Translation"),'','title_setup'); +$param='&mode='.$mode; + +$enabledisablehtml = $langs->trans("EnableOverwriteTranslation").' '; +if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) +{ + // Button off, click to enable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off'); + $enabledisablehtml.=''; +} +else +{ + // Button on, click to disable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on'); + $enabledisablehtml.=''; +} + +print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup'); print $langs->trans("TranslationDesc")."
\n"; print "
\n"; @@ -175,25 +193,6 @@ print $langs->trans("CurrentUserLanguage").': '.$s.' '.$current_language print '
'; -print $langs->trans("EnableOverwriteTranslation").' '; -if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) -{ - // Button off, click to enable - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); - print ''; -} -else -{ - // Button on, click to disable - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - print ''; -} - -print '

'; - -$param='&mode='.$mode; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($optioncss != '') $param.='&optioncss='.$optioncss; @@ -225,12 +224,12 @@ if ($mode == 'overwrite') print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."
\n"; print '
'; - - + + print ''; print ''; print ''; - + print '
'.$langs->trans("LDAPDnContactActive").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); @@ -139,7 +139,7 @@ if (! empty($conf->societe->enabled)) // Synchro member active if (! empty($conf->adherent->enabled)) { - + print '
'.$langs->trans("LDAPDnMemberActive").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index d5ca994c258..f183c29b5ef 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -39,7 +39,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','aZ09'); - + /* * Actions */ @@ -49,7 +49,7 @@ if ($action == 'setvalue' && $user->admin) $error=0; $db->begin(); - + if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',GETPOST("contactdn"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++; @@ -73,7 +73,7 @@ if ($action == 'setvalue' && $user->admin) $key=GETPOST("key"); if ($key) $valkey=$conf->global->$key; if (! dolibarr_set_const($db, 'LDAP_KEY_CONTACTS',$valkey,'chaine',0,'',$conf->entity)) $error++; - + if (! $error) { $db->commit(); @@ -107,7 +107,7 @@ if (! function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup")); +dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescContact").'
'; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 3f8869de70f..fc68d815439 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -38,7 +38,7 @@ $langs->load("errors"); if (!$user->admin) accessforbidden(); - + $action = GETPOST('action','aZ09'); @@ -50,7 +50,7 @@ if ($action == 'setvalue' && $user->admin) { $error=0; $db->begin(); - + if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',GETPOST("group"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++; @@ -64,7 +64,7 @@ if ($action == 'setvalue' && $user->admin) $key=GETPOST("key"); if ($key) $valkey=$conf->global->$key; if (! dolibarr_set_const($db, 'LDAP_KEY_GROUPS',$valkey,'chaine',0,'',$conf->entity)) $error++; - + if (! $error) { $db->commit(); @@ -96,7 +96,7 @@ if (! function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup")); +dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescGroups").'
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index afbf8da375a..cad37cc4ccc 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -5,7 +5,7 @@ * Copyright (C) 2005 Regis Houssin * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -50,7 +50,7 @@ if ($action == 'setvalue' && $user->admin) $error=0; $db->begin(); - + if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',GETPOST("user"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FILTER',GETPOST("filterconnection"),'chaine',0,'',$conf->entity)) $error++; @@ -126,7 +126,7 @@ if (! function_exists("ldap_connect")) print ''; print ''; -dol_fiche_head($head, 'members', $langs->trans("LDAPSetup")); +dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescMembers").'
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 43a6720a448..a0866c1305a 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -113,7 +113,7 @@ print ''; print ''; -dol_fiche_head($head, 'users', $langs->trans("LDAPSetup")); +dol_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescUsers").'
'; print '
'; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 03b29abc109..eb348869b34 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -187,11 +187,11 @@ if ($result) print '
' + print ''; print img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName(); print ' '; print ''.$perm_libelle. '
'; print ''; print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder); @@ -239,11 +238,11 @@ if ($mode == 'overwrite') //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder); print ''; print "\n"; - - + + // Line to add new record print "\n"; - + print ''."\n"; @@ -270,33 +269,33 @@ if ($mode == 'overwrite') print ''; print "\n"; print ''; - - + + // Show constants $sql = "SELECT rowid, entity, lang, transkey, transvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans"; $sql.= " WHERE 1 = 1"; //$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")"; $sql.= $db->order($sortfield, $sortorder); - + dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - + while ($i < $num) { $obj = $db->fetch_object($result); - + print "\n"; - + print ''; - + print ''."\n"; print ''."\n"; - + // Value print ''; - + print ''; - + print "\n"; print "\n"; $i++; } } - - + + print '
'; print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, 0, 'maxwidthonsmartphone', 1); print '
'.$obj->lang.''.$obj->transkey.''; /*print ''; @@ -306,18 +305,18 @@ if ($mode == 'overwrite') */ print $obj->transvalue; print ''; print ''.img_delete().''; print '
'; } @@ -325,15 +324,15 @@ if ($mode == 'overwrite') if ($mode == 'searchkey') { $langcode=GETPOST('langcode')?GETPOST('langcode'):$langs->defaultlang; - + $newlang=new Translate('',$conf); $newlang->setDefaultLang($langcode); $newlangfileonly=new Translate('',$conf); $newlangfileonly->setDefaultLang($langcode); - + $recordtoshow=array(); - + $nbempty=0; /*var_dump($langcode); var_dump($transkey); @@ -353,9 +352,9 @@ if ($mode == 'searchkey') // Directory of translation files $dir_lang = $searchdir."/langs/".$langcode; $dir_lang_osencoded=dol_osencode($dir_lang); - + $filearray=dol_dir_list($dir_lang_osencoded,'files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1); - + foreach($filearray as $file) { $tmpfile=preg_replace('/.lang/i', '', basename($file['name'])); @@ -364,7 +363,7 @@ if ($mode == 'searchkey') //print 'After loading lang '.$tmpfile.', newlang has '.count($newlang->tab_translate).' records
'."\n"; } } - + // Now search into translation array foreach($newlang->tab_translate as $key => $val) { @@ -373,13 +372,13 @@ if ($mode == 'searchkey') $recordtoshow[$key]=$val; } } - + //print '
'; $nbtotalofrecordswithoutfilters = count($newlang->tab_translate); $nbtotalofrecords = count($recordtoshow); $num = $limit + 1; if (($offset + $num) > $nbtotalofrecords) $num = $limit; - + //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder; $title = $langs->trans("TranslationKeySearch"); if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.')'; @@ -419,19 +418,19 @@ if ($mode == 'searchkey') {*/ print ''; //} - print ''; + print ''; // Action column print ''; $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpicto; print ''; print ''; - + if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') ksort($recordtoshow); if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') krsort($recordtoshow); if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') asort($recordtoshow); if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow); - + // Show result $i=0; foreach($recordtoshow as $key => $val) @@ -444,7 +443,7 @@ if ($mode == 'searchkey') print ''; if (! empty($newlangfileonly->tab_translate[$key])) { - if ($val != $newlangfileonly->tab_translate[$key]) + if ($val != $newlangfileonly->tab_translate[$key]) { $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]); print $form->textwithpicto('', $htmltext, 1, 'info'); diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index e856d52c2b6..0ce87a92c61 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -156,8 +156,8 @@ class box_actions extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -191,7 +191,7 @@ class box_actions extends ModeleBoxes // on affiche que les évènement du jours ou passé // qui ne sont pas à 100% $actioncejour=true; - + // TR $logo=$contents[$line][0]['logo']; $label=$contents[$line][1]['text']; diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index b6df56f52a2..653922c4cd2 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -124,8 +124,8 @@ class box_bookmarks extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 51e4a22d756..5e6f50f5b88 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -146,8 +146,10 @@ class box_clients extends ModeleBoxes } } else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index be9a868109d..c7c6bbb92d3 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -165,8 +165,8 @@ class box_commandes extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 2372a31f035..7d08a643f87 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -158,8 +158,8 @@ class box_comptes extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index c6aaf1ec24a..63b617ffe62 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -151,8 +151,8 @@ class box_contacts extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 7585c5d931c..197425b9a51 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -134,7 +134,7 @@ class box_contracts extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', + 'td' => 'align="center opacitymedium"', 'text'=>$langs->trans("NoRecordedContracts"), ); @@ -148,8 +148,8 @@ class box_contracts extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index b7c9dfa0e91..cf1d70531b3 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -169,8 +169,8 @@ class box_factures extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 4f88d99bb09..9869901c7ab 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -178,8 +178,8 @@ class box_factures_fourn extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->transnoentities("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->transnoentities("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 3313b4cbd50..11361b0aa44 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -168,8 +168,8 @@ class box_factures_fourn_imp extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 14a21d9712d..bba23671c47 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -172,8 +172,8 @@ class box_factures_imp extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 9fcd8ec6cd7..a76715c9474 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -134,8 +134,10 @@ class box_ficheinter extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 530a99c8224..6e11c67c51f 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -127,8 +127,8 @@ class box_fournisseurs extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 6c19b46e468..8a7681fb2b2 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -59,7 +59,7 @@ class box_goodcustomers extends ModeleBoxes // disable box for such cases if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database } /** @@ -148,8 +148,10 @@ class box_goodcustomers extends ModeleBoxes } } else { - $this->info_box_contents[0][0] = array('align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 8d8fea71411..1b90aae701a 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -133,7 +133,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (! $mesg) { $langs->load("bills"); - + $px1->SetData($data1); unset($data1); $px1->SetPrecisionY(0); @@ -255,8 +255,10 @@ class box_graph_invoices_permonth extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index e7ece7a2a53..55866288ef2 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -132,7 +132,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if (! $mesg) { $langs->load("bills"); - + $px1->SetData($data1); unset($data1); $px1->SetPrecisionY(0); @@ -254,8 +254,10 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index ec45cc3dde7..fcc98d368f5 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -253,8 +253,10 @@ class box_graph_orders_permonth extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 28335c79b62..b259cf48604 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -252,8 +252,10 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 44d5d0b0c15..6c178e0c989 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -99,6 +99,10 @@ class box_graph_product_distribution extends ModeleBoxes $nowarray=dol_getdate(dol_now(),true); if (empty($year)) $year=$nowarray['year']; + $nbofgraph=0; + if ($showinvoicenb) $nbofgraph++; + if ($showpropalnb) $nbofgraph++; + if ($showordernb) $nbofgraph++; $text = $langs->trans("BoxProductDistribution",$max).' - '.$langs->trans("Year").': '.$year; $this->info_box_head = array( @@ -113,11 +117,6 @@ class box_graph_product_distribution extends ModeleBoxes ); - $nbofgraph=0; - if ($showinvoicenb) $nbofgraph++; - if ($showpropalnb) $nbofgraph++; - if ($showordernb) $nbofgraph++; - $paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services"); if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services"); if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products"); @@ -250,7 +249,7 @@ class box_graph_product_distribution extends ModeleBoxes if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) { $langs->load("orders"); - + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { @@ -309,6 +308,11 @@ class box_graph_product_distribution extends ModeleBoxes } } + if (empty($nbofgraph)) + { + $langs->load("errors"); + $mesg=$langs->trans("ReadPermissionNotAllowed"); + } if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); @@ -380,9 +384,11 @@ class box_graph_product_distribution extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array( 'td' => 'align="left" class="nohover"', - 'maxlength'=>500, - 'text' => $mesg); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'maxlength'=>500, + 'text' => $mesg + ); } } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index ccce8372d1f..0ad485a115d 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -254,8 +254,10 @@ class box_graph_propales_permonth extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 1bbcec45881..03780eb366d 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -157,8 +157,8 @@ class box_members extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'align' => 'left', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 761fb6013b8..b0c47422806 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -188,8 +188,8 @@ class box_produits extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 69652fde11e..2f323fc5c4b 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -195,8 +195,8 @@ class box_produits_alerte_stock extends ModeleBoxes } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 3f7b37f186a..60bc627005a 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -155,8 +155,8 @@ class box_propales extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index abc99246c4a..7d735136326 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -156,8 +156,8 @@ class box_prospect extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 0151ba24966..b1793a6ca41 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -161,8 +161,10 @@ class box_services_contracts extends ModeleBoxes } } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 2754a4cece6..da1d42af408 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -84,7 +84,7 @@ class box_services_expired extends ModeleBoxes $i = 0; $thirdpartytmp = new Societe($this->db); - + while ($i < $num) { $late=''; @@ -140,8 +140,10 @@ class box_services_expired extends ModeleBoxes } else { - $this->info_box_contents[0][0] = array('td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 29b6009b367..83a34c2c0e5 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -160,8 +160,8 @@ class box_supplier_orders extends ModeleBoxes else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 03af3ddfe88..421b3fae132 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -191,7 +191,7 @@ FeatureAvailableOnlyOnStable=Feature only available on official stable versions Rights=Permissions BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown. -ModulesDesc=Dolibarr modules define which functionality is enabled in software. Some modules require permissions you must grant to users, after enabling module. Click on button on/off to enable a module/feature. +ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after enabling module. Click on button on/off to enable an application/module. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module wil then be visible on the tab %s. ModulesMarketPlaces=Find external modules... @@ -1107,7 +1107,7 @@ WarningAtLeastKeyOrTranslationRequired=A search criteria is required at least fo NewTranslationStringToShow=New translation string to show OriginalValueWas=The original translation is overwritten. Original value was:

%s TransKeyWithoutOriginalValue=You forced a new translation for the translation key '%s' that does not exists in any language files -TotalNumberOfActivatedModules=Activated feature/modules: %s / %s +TotalNumberOfActivatedModules=Activated application/modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path YesInSummer=Yes in summer diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3b2ba307bbd..777121e2acb 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2245,7 +2245,8 @@ div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border } div .tdtop { vertical-align: top !important; - padding-top: 5px !important; + padding-top: 8px !important; + padding-bottom: 2px !important; padding-bottom: 0px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 927830da51d..e1a286d5d7a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2820,7 +2820,7 @@ div.tabBar .noborder { div .tdtop { vertical-align: top !important; padding-top: 5px !important; - padding-bottom: 0px; + padding-bottom: 0px !important; } #tablelines tr.liste_titre td, .paymenttable tr.liste_titre td, .margintable tr.liste_titre td, .tableforservicepart1 tr.liste_titre td { From 605dbd61f265aa78f5f055a090d973f0cf16943c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 00:21:04 +0200 Subject: [PATCH 033/342] Fix phpunit --- test/phpunit/AdherentTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 5db9808c9ab..34ec0a80917 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -79,13 +79,13 @@ class AdherentTest extends PHPUnit_Framework_TestCase global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { + if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n"; die(); } if (! empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); } if (! empty($conf->global->MAIN_MODULE_MAILMANSPIP)) { print "\n".__METHOD__." module MailmanSpip must be disabled.\n"; die(); } - + print __METHOD__."\n"; } @@ -532,7 +532,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $result=$localobject->delete($localobject->id); + $result=$localobject->delete($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); From 9a30e8edc6d6ac718d4c08b0b228b0f06fe6ca09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 00:22:12 +0200 Subject: [PATCH 034/342] Update changelog --- ChangeLog | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7bbaf440ae..5b4f986fbb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,8 @@ English Dolibarr ChangeLog For developers: NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... -NEW: Big refactorization of multicompany transverse mode -NEW: getEntity function use true $shared value by default +NEW: Big refactorization of multicompany transverse mode. +NEW: getEntity function use true $shared value by default. WARNING: @@ -17,7 +17,9 @@ Following changes may create regression for some external modules, but were nece * The page societe/soc.php was renamed into societe/card.php to match page naming conventions. * The page compta/facture.php was renamed into compta/facture/card.php to match page naming conventions. * The signature of method ->delete() of class Product and PriceExpression was changed from - ->delete($id, notrigger) to ->delete(User, notrigger) to match standard dev rules. + ->delete(id, notrigger) to ->delete(User, notrigger) to match standard dev rules. +* The signature of method ->delete() of class Adherent was changed from + ->delete(id) to ->delete(id, User, notrigger) to match standard dev rules. * Removed CommonObject::displayMarginInfos (was deprecated in 3.8). Use same method into html.formmargin.class.php * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. From 87c8659e72a0ae22e083b1170414b443f71a8561 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 00:45:18 +0200 Subject: [PATCH 035/342] Fix responsive --- htdocs/core/lib/functions.lib.php | 6 ++++-- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d3cfac1c41..6f73d504d11 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1226,11 +1226,13 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($ret < 0) $error++; } + $heightforphotref=70; + if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; // Si fichier png PDF d'1 page trouve if (file_exists($fileimage)) { $phototoshow = '
'; - $phototoshow.= ''; + $phototoshow.= ''; $phototoshow.= '
'; } // Si fichier png PDF de plus d'1 page trouve @@ -1238,7 +1240,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { $preview = preg_replace('/\.png/','',$relativepathimage) . "-0.png"; $phototoshow = '
'; - $phototoshow.= '

'; + $phototoshow.= '

'; $phototoshow.= '

'; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 777121e2acb..4fd7120a771 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -857,6 +857,7 @@ div.fiche>form>div.div-table-responsive { div.divphotoref { padding-right: 5px; + padding-bottom: 5px; } img.photoref, div.photoref { border: none; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e1a286d5d7a..dc61977cf5f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -858,6 +858,7 @@ div.fiche>form>div.div-table-responsive { div.divphotoref { padding-right: 5px; + padding-bottom: 5px; } img.photoref, div.photoref { border: none; From 9e33baf0d62dc249b801074e81b051e06a1ccfca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 01:09:11 +0200 Subject: [PATCH 036/342] Prepare package for 6.0beta --- .tx/config | 4 ++-- build/makepack-dolibarr.pl | 2 +- build/rpm/dolibarr_fedora.spec | 2 ++ build/rpm/dolibarr_generic.spec | 2 ++ build/rpm/dolibarr_mandriva.spec | 2 ++ build/rpm/dolibarr_opensuse.spec | 2 ++ 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.tx/config b/.tx/config index 1839523f114..89d123b0362 100644 --- a/.tx/config +++ b/.tx/config @@ -224,13 +224,13 @@ source_file = htdocs/langs/en_US/members.lang source_lang = en_US type = MOZILLAPROPERTIES -[dolibarr.members] +[dolibarr.modulebuilder] file_filter = htdocs/langs//modulebuilder.lang source_file = htdocs/langs/en_US/modulebuilder.lang source_lang = en_US type = MOZILLAPROPERTIES -[dolibarr.members] +[dolibarr.multicurrency] file_filter = htdocs/langs//multicurrency.lang source_file = htdocs/langs/en_US/multicurrency.lang source_lang = en_US diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index b47ae023129..e908fb20d0a 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -591,7 +591,7 @@ if ($nboftargetok) { print "Remove subdir of custom dir\n"; print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n"; - $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to keep dir + $ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files } # Build package for each target diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index a0f981b8c11..33dc951309d 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -194,6 +194,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin +%_datadir/dolibarr/htdocs/modulebuilder %_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/paybox @@ -209,6 +210,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user +%_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/*.ico diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 446e0e0d5f7..42a89675abf 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -274,6 +274,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin +%_datadir/dolibarr/htdocs/modulebuilder %_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/paybox @@ -289,6 +290,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user +%_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/*.ico diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 1fb1b7fcc75..9dd2100b02c 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -190,6 +190,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin +%_datadir/dolibarr/htdocs/modulebuilder %_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/paybox @@ -205,6 +206,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user +%_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/*.ico diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 1bb7ef061e6..d780c47da99 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -202,6 +202,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin +%_datadir/dolibarr/htdocs/modulebuilder %_datadir/dolibarr/htdocs/multicurrency %_datadir/dolibarr/htdocs/opensurvey %_datadir/dolibarr/htdocs/paybox @@ -217,6 +218,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user +%_datadir/dolibarr/htdocs/variants %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/websites %_datadir/dolibarr/htdocs/*.ico From 2a6c21bd038e6c95e2b1ff4c39f7281210f54ea7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 01:13:26 +0200 Subject: [PATCH 037/342] Fix permissions on script file --- htdocs/modulebuilder/template/scripts/myobject.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 htdocs/modulebuilder/template/scripts/myobject.php diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php old mode 100644 new mode 100755 From 660faac0f3a6c5a9e330be76374299a0851cab97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 01:17:48 +0200 Subject: [PATCH 038/342] Prepare package 6.0 --- build/generate_filelist_xml.php | 10 +++++----- build/makepack-dolibarr.pl | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index c1a56beacd7..94df2206579 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -43,7 +43,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); $includecustom=0; $includeconstants=array(); -if (empty($argv[1])) +if (empty($argv[1])) { print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; @@ -56,7 +56,7 @@ while ($i < $argc) if (preg_match('/includeconstant=/',$argv[$i])) { $tmp=explode(':', $includeconstant, 3); - if (count($tmp) != 3) + if (count($tmp) != 3) { print "Error: Bad parameter includeconstant ".$includeconstant."\n"; exit -1; @@ -85,9 +85,9 @@ else } } -print "Release : ".$release."\n"; -print "Include custom : ".$includecustom."\n"; -print "Include constants: "; +print "Release : ".$release."\n"; +print "Include custom in signature : ".$includecustom."\n"; +print "Include constants in signature : "; foreach ($includeconstants as $countrycode => $tmp) { foreach($tmp as $constname => $constvalue) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index e908fb20d0a..9ded8399ccc 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -972,13 +972,12 @@ if ($nboftargetok) { $ret=`$cmd`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/modMyModule.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_api_class.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_card.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_class.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_list.php`; - $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_script.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_webservice_server.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_class.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_api_class.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_list.php`; + $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/scripts/myobject.php`; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; "; $ret=`$cmd`; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.sh' -type f -exec chmod 755 {} \\; "; From 4cf862f03375a4b10ddb39f36088ffc4552e0984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 01:19:20 +0200 Subject: [PATCH 039/342] Prepare package 6.0 --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 9ded8399ccc..c2d983653cb 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -972,7 +972,7 @@ if ($nboftargetok) { $ret=`$cmd`; $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_class.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/class/myobject_api_class.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/core/modules/modMyModule.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/htdocs/modulebuilder/template/myobject_card.php`; From 3d5899edf385c3951981327c8ec39cac558c45d0 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 10 Jun 2017 09:25:32 +0200 Subject: [PATCH 040/342] final blockedlog init --- htdocs/blockedlog/admin/blockedlog.php | 126 +++++ htdocs/blockedlog/admin/fingerprints.php | 126 +++++ htdocs/blockedlog/admin/index.html | 0 htdocs/blockedlog/ajax/authority.php | 45 ++ htdocs/blockedlog/ajax/check_signature.php | 30 + htdocs/blockedlog/class/authority.class.php | 308 +++++++++++ htdocs/blockedlog/class/blockedlog.class.php | 512 ++++++++++++++++++ htdocs/blockedlog/lib/blockedlog.lib.php | 57 ++ htdocs/blockedlog/lib/index.html | 0 .../compta/paiement/class/paiement.class.php | 4 +- htdocs/core/class/blockedlog.class.php | 235 -------- htdocs/core/modules/modBlockedLog.class.php | 2 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 42 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 31 +- .../mysql/tables/llx_blockedlog.key.sql | 6 + .../install/mysql/tables/llx_blockedlog.sql | 19 + .../tables/llx_blockedlog_authority.key.sql | 1 + .../mysql/tables/llx_blockedlog_authority.sql | 7 + 18 files changed, 1291 insertions(+), 260 deletions(-) create mode 100644 htdocs/blockedlog/admin/blockedlog.php create mode 100644 htdocs/blockedlog/admin/fingerprints.php create mode 100644 htdocs/blockedlog/admin/index.html create mode 100644 htdocs/blockedlog/ajax/authority.php create mode 100644 htdocs/blockedlog/ajax/check_signature.php create mode 100644 htdocs/blockedlog/class/authority.class.php create mode 100644 htdocs/blockedlog/class/blockedlog.class.php create mode 100644 htdocs/blockedlog/lib/blockedlog.lib.php create mode 100644 htdocs/blockedlog/lib/index.html delete mode 100644 htdocs/core/class/blockedlog.class.php create mode 100644 htdocs/install/mysql/tables/llx_blockedlog.key.sql create mode 100644 htdocs/install/mysql/tables/llx_blockedlog.sql create mode 100644 htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql create mode 100644 htdocs/install/mysql/tables/llx_blockedlog_authority.sql diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php new file mode 100644 index 00000000000..3c143b70b83 --- /dev/null +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -0,0 +1,126 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/blockedlog/admin/blockedlog.php + * \ingroup system + * \brief Page setup for blockedlog module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("other"); +$langs->load("blockedlog"); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); + +/* + * Actions + */ +if (preg_match('/set_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_del_const($db, $code, 0) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + + +/* + * View + */ + +$block_static = new BlockedLog($db); + +$form=new Form($db); + +llxHeader('',$langs->trans("BlockedLogSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); + +$head=blockedlogadmin_prepare_head(); + +dol_fiche_head($head, 'blockedlog', '', -1); + +print $langs->trans("BlockedLogDesc")."
\n"; + +print '
'; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +print ''; +print ''; + + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; + + +print '
'.$langs->trans("Key").''.$langs->trans("Value").'
'; +print $langs->trans("EntityKey").''; + +print $block_static->getSignature(); + +print '
'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'; + +dol_fiche_end(); + +print '

'; + +llxFooter(); +$db->close(); diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php new file mode 100644 index 00000000000..bdd569d31bc --- /dev/null +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -0,0 +1,126 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/blockedlog/admin/blockedlog.php + * \ingroup system + * \brief Page setup for blockedlog module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("other"); +$langs->load("blockedlog"); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); + + +/* + * View + */ + +$block_static = new BlockedLog($db); + +$blocks = $block_static->getLog('all', 0, GETPOST('all') ? 0 : 50); + +$form=new Form($db); + +llxHeader('',$langs->trans("BlockedLogSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); + +$head=blockedlogadmin_prepare_head(); + +dol_fiche_head($head, 'fingerprints', '', -1); + +print $langs->trans("FingerprintsDesc")."
\n"; + +print '
'; + +echo ''; + + +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; + +foreach($blocks as &$block) { + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + +} + +print '
'.$langs->trans('Date').''.$langs->trans('Ref').''.$langs->trans('Action').''.$langs->trans('Element').''.$langs->trans('Amount').''.$langs->trans('Author').''.$langs->trans('Fingerprint').'
'.dol_print_date($block->tms,'dayhour').''.$block->ref_object.''.$langs->trans('log'.$block->action).''.$block->getObject().''.price($block->amounts).''.$block->getUser().''.$block->signature.''; + + print $block->checkSignature() ? img_picto('OkCheckPaymentValidity', 'on') : img_picto($langs->trans('KoCheckPaymentValidity'), 'off'); + print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); + + print '
'; + +?> + + +
'; + +llxFooter(); +$db->close(); diff --git a/htdocs/blockedlog/admin/index.html b/htdocs/blockedlog/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/blockedlog/ajax/authority.php b/htdocs/blockedlog/ajax/authority.php new file mode 100644 index 00000000000..12584b2bace --- /dev/null +++ b/htdocs/blockedlog/ajax/authority.php @@ -0,0 +1,45 @@ +fetch(1); //TODO conf user authority + + $auth = new BlockedLogAuthority($db); + + $signature = GETPOST('s'); + $newblock = GETPOST('b'); + $hash = GETPOST('h'); + + if($auth->fetch(0, $signature)<=0) { + $auth->signature = $signature; + $auth->create($user); + } + + + if(!empty($hash)) { + + echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; + + } + elseif(!empty($newblock)){ + if($auth->checkBlock($newblock)) { + $auth->addBlock($newblock); + $auth->update($user); + + echo 'blockadded'; + } + else{ + + echo 'blockalreadyadded'; + + } + } + else{ + echo 'idontunderstandwhatihavetodo'; + } + + diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php new file mode 100644 index 00000000000..bb018508a31 --- /dev/null +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -0,0 +1,30 @@ +global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); + + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + + $auth=new BlockedLogAuthority($db); + $auth->syncSignatureWithAuthority(); + + $block_static = new BlockedLog($db); + + $blocks = $block_static->getLog('just_certified', 0, 0, 1) ; + + $auth->signature = $block_static->getSignature(); + + foreach($blocks as &$b) { + $auth->blockchain.=$b->signature; + + } + + $hash = $auth->getBlockchainHash(); + + $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; + + $res = file_get_contents($url); + //echo $url; + echo $res; \ No newline at end of file diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php new file mode 100644 index 00000000000..b7128b28e09 --- /dev/null +++ b/htdocs/blockedlog/class/authority.class.php @@ -0,0 +1,308 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Class to manage certif authority + */ +class BlockedLogAuthority { + + /** + * Id of the log + * @var int + */ + public $id; + + /** + * Unique fingerprint of the blockchain to store + * @var string + */ + public $signature = ''; + + /** + * Entire fingerprints blockchain + * @var string + */ + public $blockchain = ''; + + /** + * timestamp + * @var int + */ + public $tms = 0; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) { + + $this->db = $db; + + } + + /** + * Get hash of the block chain to check + * + * @return string hash md5 of blockchain + */ + public function getBlockchainHash() { + + return md5($this->signature.$this->blockchain); + + } + + /** + * Get hash of the block chain to check + * + * @param string $hash hash md5 of blockchain to test + * @return boolean + */ + public function checkBlockchain($hash) { + + return ($hash === $this->getBlockchainHash() ); + + } + + /** + * Add a new block to the chain + * + * @param string $block new block to chain + */ + public function addBlock($block) { + + $this->blockchain.=$block; + + } + + /** + * hash already exist into chain ? + * + * @param string $block new block to chain + * @return boolean + */ + public function checkBlock($block) { + + if(strlen($block)!=64) return false; + + $blocks = str_split($this->blockchain,64); + + if(!in_array($block,$blocks)) { + return true; + } + else{ + return false; + } + } + + + /** + * Get object from database + * + * @param int $rowid Id of object to load + * @return int >0 if OK, <0 if KO, 0 if not found + */ + public function fetch($id, $signature='') { + + global $langs; + + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); + + if (empty($id) && empty($signature)) + { + $this->error='BadParameter'; + return -1; + } + + $langs->load("blockedlog"); + + $sql = "SELECT b.rowid, b.signature, b.blockchain, b.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; + + if ($id) $sql.= " WHERE b.rowid = ". $id; + else if($signature)$sql.= " WHERE b.signature = '". $this->db->escape( $signature ) ."'" ; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->signature = $obj->signature; + $this->blockchain = $obj->blockchain; + + $this->tms = $this->db->jdate($obj->tms); + + return 1; + } + else + { + $this->error=$langs->trans("RecordNotFound"); + return 0; + } + } + else + { + $this->error=$this->db->error(); + return -1; + } + + } + + /** + * Create authority in database. + * + * @param User $user Object user that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) { + + global $conf,$langs,$hookmanager; + + $langs->load('blockedlog'); + + $error=0; + + dol_syslog(get_class($this).'::create', LOG_DEBUG); + + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog_authority ("; + $sql.= " signature,"; + $sql.= " blockchain"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->signature)."',"; + $sql.= "'".$this->db->escape($this->blockchain)."'"; + $sql.= ")"; + + $res = $this->db->query($sql); + if ($res) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog_authority"); + + if ($id > 0) + { + $this->id = $id; + + $this->db->commit(); + + return $this->id; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + + } + + /** + * Create authority in database. + * + * @param User $user Object user that create + * @return int <0 if KO, >0 if OK + */ + public function update($user) { + + global $conf,$langs,$hookmanager; + + $langs->load('blockedlog'); + + $error=0; + + dol_syslog(get_class($this).'::create', LOG_DEBUG); + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."blockedlog_authority SET "; + $sql.= " blockchain='".$this->db->escape($this->blockchain)."'"; + $sql.= " WHERE rowid=".$this->id; + + $res = $this->db->query($sql); + if ($res) + { + $this->db->commit(); + + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + + } + + /** + * For cron to sync to authority. + * + * @return int <0 if KO, >0 if OK + */ + public function syncSignatureWithAuthority() { + global $conf, $langs; + + //TODO create cron task on activation + + if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { + $this->error = $langs->trans('NoAuthorityURLDefined'); + return -2; + } + + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + + $block_static = new BlockedLog($this->db); + + $blocks = $block_static->getLog('not_certified', 0, 0, 1); + + $signature=$block_static->getSignature(); + + foreach($blocks as &$block) { + + $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; + + $res = file_get_contents($url); + echo $block->signature.' '.$url. ' '.$res.'
'; + if($res === 'blockalreadyadded' || $res === 'blockadded') { + + $block->setCertified(); + + } + else { + + $this->error = $langs->trans('ImpossibleToContactAuthority ',$url); + return -1; + } + + + } + + return 1; + } + +} \ No newline at end of file diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php new file mode 100644 index 00000000000..d41790c63b5 --- /dev/null +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -0,0 +1,512 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Class to manage Blocked Log + */ + +class BlockedLog { + + /** + * Id of the log + * @var int + */ + public $id; + + /** + * Unique fingerprint of the log + * @var string + */ + public $signature = ''; + + /** + * Unique fingerprint of the line log content + * @var string + */ + public $signature_line = ''; + + public $amounts = null; + + public $action = ''; + + public $element = ''; + + public $fk_object = 0; + + public $certified = false; + + public $fk_user = 0; + + public $date_object = 0; + + public $ref_object = ''; + + public $object_data = null; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + + } + + /** + * try to retrieve logged object + * + * @param object|string $object object logged + */ + public function getObject() { + global $langs; + + if($this->element === 'facture') { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $object = new Facture($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + } + else if($this->element === 'payment') { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + + $object = new Paiement($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + } + + return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); + + } + + /** + * try to retrieve user author + * + * @param object|string $object object logged + */ + public function getUser() { + global $langs, $cachedUser; + + if(empty($cachedUser))$cachedUser=array(); + + if(empty($cachedUser[$this->fk_user])) { + $u=new User($this->db); + if($u->fetch($this->fk_user)>0) { + $cachedUser[$this->fk_user] = $u; + } + } + + if(!empty($cachedUser[$this->fk_user])) { + return $cachedUser[$this->fk_user]->getNomUrl(1); + } + + return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user); + } + + /** + * populate log by object + * + * @param payment|facture $object object to store + */ + public function setObjectData(&$object) { + + if($object->element=='payment') { + $this->date_object = $object->datepaye; + } + else{ + $this->date_object = $object->date; + } + + $this->ref_object = $object->ref; + $this->element = $object->element; + $this->fk_object = $object->id; + + $this->object_data=new stdClass(); + + if($this->element === 'facture') { + if(empty($object->thirdparty))$object->fetch_thirdparty(); + $this->object_data->thirdparty=new stdClass(); + + foreach($object->thirdparty as $key=>$value) { + if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; + } + + $this->object_data->total_ht = (double)$object->total_ht; + $this->object_data->total_tva = (double)$object->total_tva; + $this->object_data->total_ttc = (double)$object->total_ttc; + $this->object_data->total_localtax1= (double)$object->total_localtax1; + $this->object_data->total_localtax2= (double)$object->total_localtax2; + $this->object_data->note_public = (double)$object->note_public; + $this->object_data->note_private= (double)$object->note_private; + + } + elseif($this->element==='payment'){ + + $this->object_data->amounts = $object->amounts; + + } + + + } + + /** + * Get object from database + * + * @param int $rowid Id of object to load + * @return int >0 if OK, <0 if KO, 0 if not found + */ + public function fetch($id) { + + global $langs; + + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); + + if (empty($id)) + { + $this->error='BadParameter'; + return -1; + } + + $langs->load("blockedlog"); + + $sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data"; + $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; + if ($id) $sql.= " WHERE b.rowid = ". $id; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->signature = $obj->signature; + $this->amounts = (double)$obj->amounts; + $this->action = $obj->action; + $this->element = $obj->element; + + $this->fk_object = trim($obj->fk_object); + $this->date_object = $this->db->jdate($obj->date_object); + $this->ref_object = $obj->ref_object; + + $this->certified = ($obj->certified == 1); + + $this->fk_user = $obj->fk_user; + + $this->tms = $this->db->jdate($obj->tms); + + $this->object_data = unserialize($obj->object_data); + + return 1; + } + else + { + $this->error=$langs->trans("RecordNotFound"); + return 0; + } + } + else + { + $this->error=$this->db->error(); + return -1; + } + + } + + /** + * Set block certified by authority + * + * @return boolean + */ + public function setCertified() { + + $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); + if($res===false) return false; + + return true; + + + } + + /** + * Create blocked log in database. + * + * @param User $user Object user that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) { + + global $conf,$langs,$hookmanager; + + $langs->load('blockedlog'); + + $error=0; + + dol_syslog(get_class($this).'::create', LOG_DEBUG); + + $this->getSignatureRecursive(); + + + if (is_null($this->amounts)) + { + $this->error=$langs->trans("BlockLogNeedAmountsValue"); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + if(empty($this->element)) { + $this->error=$langs->trans("BlockLogNeedElement"); + dol_syslog($this->error, LOG_WARNING); + return -2; + } + + if(empty($this->action)) { + $this->error=$langs->trans("BlockLogNeedAction"); + dol_syslog($this->error, LOG_WARNING); + return -3; + } + + $this->fk_user = $user->id; + + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; + $sql.= "action,"; + $sql.= " amounts,"; + $sql.= " signature,"; + $sql.= " signature_line,"; + $sql.= " element,"; + $sql.= " fk_object,"; + $sql.= " date_object,"; + $sql.= " ref_object,"; + $sql.= " object_data,"; + $sql.= " certified,"; + $sql.= " fk_user,"; + $sql.= " entity"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->action)."',"; + $sql.= "".$this->amounts.","; + $sql.= "'".$this->db->escape($this->signature)."',"; + $sql.= "'".$this->db->escape($this->signature_line)."',"; + $sql.= "'".$this->db->escape($this->element)."',"; + $sql.= "".$this->fk_object.","; + $sql.= "'".$this->db->idate($this->date_object)."',"; + $sql.= "'".$this->db->escape($this->ref_object)."',"; + $sql.= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql.= "0,"; + $sql.= "".$user->id.","; + $sql.= $conf->entity; + $sql.= ")"; + + $res = $this->db->query($sql); + if ($res) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); + + if ($id > 0) + { + $this->id = $id; + + $this->db->commit(); + + return $this->id; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + + } + + /** + * return crypted value. + * + * @param string $value string to crypt + * @return string crypted string + */ + private function crypt($value) { + + return hash('sha256',$value); + + } + + /** + * check if current signature still correct compare to the chain + * + * @return boolean + */ + public function checkSignature() { + + $signature_to_test = $this->signature; + + $this->getSignatureRecursive(); + + return ($signature_to_test=== $this->signature); + + } + + /** + * set current signatures + */ + private function getSignatureRecursive(){ + + $this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) ); + /*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') { + var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data); + }*/ + $this->signature = $this->signature_line; + + $logs = $this->getLog('all', 0, 0, 1) ; + if($logs!==false) { + foreach($logs as &$b) { + + if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature + + $b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré + + $this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts); + } + } + + } + + /** + * return log object for a element. + * + * @param string $element element to search + * @param int $fk_object id of object to search + * @param int $limit max number of element, 0 for all + * @param string $order sort of query + * @return array array of object log + */ + public function getLog($element, $fk_object, $limit = 0, $order = -1) { + global $conf,$cachedlogs ; + + /* $cachedlogs allow fastest search */ + if(empty($cachedlogs)) $cachedlogs=array(); + + + if($element=='all') { + + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity; + + } + else if($element=='not_certified') { + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity." AND certified = 0"; + + } + else if($element=='just_certified') { + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE entity=".$conf->entity." AND certified = 1"; + + } + else{ + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + WHERE element='".$element."' AND fk_object=".(int)$fk_object; + + } + + $sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC '); + + if($limit > 0 )$sql.=' LIMIT '.$limit; + + $res = $this->db->query($sql); + + if($res) { + + $results=array(); + + while($obj = $this->db->fetch_object($res)) { + + if(!isset($cachedlogs[$obj->rowid])) { + $b=new BlockedLog($this->db); + $b->fetch($obj->rowid); + + $cachedlogs[$obj->rowid] = $b; + } + + $results[] = $cachedlogs[$obj->rowid]; + + } + + return $results; + } + else{ + return false; + } + } + + /** + * set amounts of log from current element value in order to compare signature. + */ + private function getCurrentValue() { + + if($this->action === 'PAYMENT_CUSTOMER_CREATE' + || $this->action === 'PAYMENT_ADD_TO_BANK') { + $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; + + $res = $this->db->query($sql); + + if($res && $obj = $this->db->fetch_object($res)) { + $this->amounts = (double)$obj->amount; + } + } + + } + + /** + * return and set the entity signature included into line signature + * + * @return string current entity signature + */ + public function getSignature() { + global $db,$conf,$mysoc; + + if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint + + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + + $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); + + dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity); + + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; + } + + return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; + } + +} + diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php new file mode 100644 index 00000000000..a7fca40d116 --- /dev/null +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -0,0 +1,57 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/blockedlog/lib/blockedlog.lib.php + * \ingroup system + * \brief Library for common blockedlog functions + */ + +/** + * Define head array for tabs of blockedlog tools setup pages + * + * @return Array of head + */ +function blockedlogadmin_prepare_head() +{ + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php"; + $head[$h][1] = $langs->trans("BlockedLog"); + $head[$h][2] = 'blockedlog'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php"; + $head[$h][1] = $langs->trans("Fingerprints"); + $head[$h][2] = 'fingerprints'; + $h++; + + $object=new stdClass(); + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'blockedlog'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'blockedlog','remove'); + + return $head; +} diff --git a/htdocs/blockedlog/lib/index.html b/htdocs/blockedlog/lib/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 03a7759e52c..c8d7f4d3759 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -196,7 +196,7 @@ class Paiement extends CommonObject $this->db->begin(); - $ref = $this->getNextNumRef(''); + $this->ref = $this->getNextNumRef(''); if ($way == 'dolibarr') { @@ -210,7 +210,7 @@ class Paiement extends CommonObject } $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)"; - $sql.= " VALUES (".$conf->entity.", '".$ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; + $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/blockedlog.class.php b/htdocs/core/class/blockedlog.class.php deleted file mode 100644 index 3e622c42dc4..00000000000 --- a/htdocs/core/class/blockedlog.class.php +++ /dev/null @@ -1,235 +0,0 @@ -db =&$db; - - } - - public function create($user) { - - global $conf,$langs,$hookmanager; - - $langs->load('blockedlog'); - - $error=0; - - dol_syslog(get_class($this).'::create', LOG_DEBUG); - - // Clean parameters - $this->signature = $this->getSignatureRecursive(); - - - if (is_null($this->key_value1)) - { - $this->error=$langs->trans("BlockLogNeedKey1Value"); - dol_syslog($this->error, LOG_WARNING); - return -1; - } - - if(empty($this->element)) { - $this->error=$langs->trans("BlockLogNeedElement"); - dol_syslog($this->error, LOG_WARNING); - return -2; - } - - if(empty($this->action)) { - $this->error=$langs->trans("BlockLogNeedAction"); - dol_syslog($this->error, LOG_WARNING); - return -3; - } - - $this->fk_user = $user->id; - - $this->db->begin(); - - //TODO add fk_user; - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; - $sql.= "action,"; - $sql.= " key_value1,"; - $sql.= " signature,"; - $sql.= " element,"; - $sql.= " fk_object,"; - $sql.= " certified,"; - $sql.= " entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->action)."',"; - $sql.= "".$this->key_value1.","; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->element)."',"; - $sql.= "".$this->fk_object.","; - $sql.= "'".($this->certified ? 1 : 0)."',"; - $sql.= $conf->entity; - $sql.= ")"; - - $res = $this->db->query($sql); - if ($res) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); - - if ($id > 0) - { - $this->id = $id; - - } - else - { - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - - } - - private function crypt($value) { - - return md5($value); - - } - - public function checkSignature() { - - $signature = $this->getSignatureRecursive(); - - return ($signature === $this->signature); - - } - - private function getSignatureRecursive(){ - - $signature = $this->crypt( $this->action . $this->getSignature() . $this->key_value1 ); - - $logs = $this->getLog('payment', 0, 0, 'ASC') ; - if($logs!==false) { - foreach($logs as &$b) { - - if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature - - $b->updateValue(); // on récupère la valeur actuelle en base de l'élément enregistré - - $signature = $this->crypt($signature. $this->action . $b->signature . $b->key_value1); - } - } - return $signature; - - } - - public function getLog($element, $fk_object, $limit = 0, $order = 'DESC') { - global $conf,$cachedlogs ; - - if(empty($cachedlogs)) $cachedlogs=array(); - - - if($element=='payment') { - - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' - ORDER BY tms ".$order; - - } - else if($element=='payments_not_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' AND certified = 0 - ORDER BY tms ".$order; - - } - else if($element=='payments_just_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE entity=".$conf->entity." AND action LIKE '%PAYMENT%' AND certified = 1 - ORDER BY tms ".$order; - - } - else{ - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE element='".$element."' AND fk_object=".(int)$fk_object." - ORDER BY tms ".$order; - - } - - - if($limit > 0 )$sql.=' LIMIT '.$limit; - - $res = $this->db->query($sql); - - if($res) { - - $results=array(); - - while($obj = $this->db->fetch_object($res)) { - - if(!isset($cachedlogs[$obj->rowid])) { - $b=new BlockedLog($this->db); - $b->fetch($obj->rowid); - - $cachedlogs[$obj->rowid] = $b; - } - - $results[] = $cachedlogs[$obj->rowid]; - - } - - return $results; - } - else{ - return false; - } - } - - private function updateValue() { - - if($this->action === 'PAYMENT_CUSTOMER_CREATE' - || $this->action === 'PAYMENT_ADD_TO_BANK') { - $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; - - $res = $this->db->query($sql); - - if($res && $obj = $db->fetch_object($res)) { - $this->key_value1 = (double)$obj->amount; - } - } - - } - - - public function getSignature() { - global $db,$conf,$mysoc; - - if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint - - require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - - $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); - - dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, '',0,'Numeric Unique Fingerprint', $conf->entity); - - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; - } - - return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; - } - -} - diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index c3e2cb6345a..b149471cd20 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -60,7 +60,7 @@ class modBlockedLog extends DolibarrModules // Config pages //------------- - $this->config_page_url = array(); + $this->config_page_url = array('blockedlog.php@blockedlog'); // Dependancies //------------- diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 3307e4216ea..dde792a27d0 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -1,10 +1,5 @@ - * Copyright (C) 2009-2011 Regis Houssin - * Copyright (C) 2011-2014 Juanjo Menent - * Copyright (C) 2013 Cedric GROSS - * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Bahfir Abbes +/* Copyright (C) 2017 ATM Consulting * * 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 @@ -21,13 +16,13 @@ */ /** - * \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php - * \ingroup agenda - * \brief Trigger file for agenda module + * \file htdocs/core/triggers/interface_50_modAgenda_ActionsBlockedLog.class.php + * \ingroup system + * \brief Trigger file for blockedlog module */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; /** * Class of triggered functions for agenda module @@ -56,19 +51,40 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers return 0; } + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED') { + $amounts= (double)$object->total_ttc; + } + else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { + $amounts = 0; + if(!empty($object->amounts)) { + foreach($object->amounts as $amount) { + $amounts+= price2num($amount); + } + } + + + } + else if(strpos($action,'PAYMENT')!==false) { + $amounts= (double)$object->amount; + } + else { + return 0; // not implemented action log + } + $b=new BlockedLog($this->db); - $b->element = $object->element; $b->action = $action; - $b->fk_object = $object->id; - $b->key_value1 = 0; + $b->amounts= $amounts; + $b->setObjectData($object); $res = $b->create($user); + if($res<0) { setEventMessage($b->error,'errors'); return -1; } else { + return 1; } 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 786becac0ba..d5e758eb566 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 @@ -397,19 +397,32 @@ ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup CREATE TABLE llx_blockedlog ( - rowid integer AUTO_INCREMENT, - tms timestamp, + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - key_value1 real NOT NULL, - signature varchar(32) NOT NULL, + amounts real NOT NULL, + signature varchar(100) NOT NULL, + signature_line varchar(100) NOT NULL, element varchar(50), - fk_object integer, + fk_object integer, + ref_object varchar(100), + date_object datetime, + object_data text, + fk_user integer, entity integer, - certified integer, - PRIMARY KEY (rowid), + certified integer, KEY signature (signature), KEY fk_object_element (fk_object,element), - KEY entity (entity), + KEY entity (entity), + KEY fk_user (fk_user), KEY entity_action (entity,action), KEY entity_action_certified (entity,action,certified) -) +) ENGINE=innodb; + +CREATE TABLE llx_blockedlog_authority +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + blockchain longtext NOT NULL, + signature varchar(100) NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_blockedlog.key.sql b/htdocs/install/mysql/tables/llx_blockedlog.key.sql new file mode 100644 index 00000000000..4312a056894 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_blockedlog.key.sql @@ -0,0 +1,6 @@ +ALTER TABLE llx_blockedlog ADD INDEX signature (signature); +ALTER TABLE llx_blockedlog ADD INDEX fk_object_element (fk_object,element); +ALTER TABLE llx_blockedlog ADD INDEX entity (entity); +ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user); +ALTER TABLE llx_blockedlog ADD INDEX entity_action (entity,action); +ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified); diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql new file mode 100644 index 00000000000..769eb34e092 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -0,0 +1,19 @@ + +CREATE TABLE llx_blockedlog +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + action varchar(50), + amounts real NOT NULL, + signature varchar(100) NOT NULL, + signature_line varchar(100) NOT NULL, + element varchar(50), + fk_object integer, + ref_object varchar(100), + date_object datetime, + object_data text, + fk_user integer, + entity integer, + certified integer +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql new file mode 100644 index 00000000000..289b6dbde56 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql @@ -0,0 +1 @@ +ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql new file mode 100644 index 00000000000..eb491f93af4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql @@ -0,0 +1,7 @@ +CREATE TABLE llx_blockedlog_authority +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + blockchain longtext NOT NULL, + signature varchar(100) NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=innodb; From 63b3010c2e33f631b8e515e8c37e60ebf8d3a8f0 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 10 Jun 2017 09:28:07 +0200 Subject: [PATCH 041/342] fix sql --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 d5e758eb566..f4757e2475f 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 @@ -410,15 +410,16 @@ CREATE TABLE llx_blockedlog object_data text, fk_user integer, entity integer, - certified integer, - KEY signature (signature), - KEY fk_object_element (fk_object,element), - KEY entity (entity), - KEY fk_user (fk_user), - KEY entity_action (entity,action), - KEY entity_action_certified (entity,action,certified) + certified integer ) ENGINE=innodb; +ALTER TABLE llx_blockedlog ADD INDEX signature (signature); +ALTER TABLE llx_blockedlog ADD INDEX fk_object_element (fk_object,element); +ALTER TABLE llx_blockedlog ADD INDEX entity (entity); +ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user); +ALTER TABLE llx_blockedlog ADD INDEX entity_action (entity,action); +ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified); + CREATE TABLE llx_blockedlog_authority ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -426,3 +427,5 @@ CREATE TABLE llx_blockedlog_authority signature varchar(100) NOT NULL, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=innodb; + +ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); From 4fd24f6d8c9c2e5c5f154530e052827e8ccf3edb Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 10 Jun 2017 09:58:07 +0200 Subject: [PATCH 042/342] fix travis --- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index dde792a27d0..5a52777cbb9 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -52,7 +52,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers } if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED') { - $amounts= (double)$object->total_ttc; + $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { $amounts = 0; @@ -65,7 +65,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers } else if(strpos($action,'PAYMENT')!==false) { - $amounts= (double)$object->amount; + $amounts= (double) $object->amount; } else { return 0; // not implemented action log From 3cae54c29606bd892dffae11e4eb25201acd9c7f Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 10 Jun 2017 10:10:34 +0200 Subject: [PATCH 043/342] fix travis --- htdocs/blockedlog/class/authority.class.php | 8 +-- htdocs/blockedlog/class/blockedlog.class.php | 53 +++++++++++++------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index b7128b28e09..8d241694b70 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -18,7 +18,8 @@ /** * Class to manage certif authority */ -class BlockedLogAuthority { +class BlockedLogAuthority +{ /** * Id of the log @@ -113,8 +114,9 @@ class BlockedLogAuthority { /** * Get object from database * - * @param int $rowid Id of object to load - * @return int >0 if OK, <0 if KO, 0 if not found + * @param int $id Id of object to load + * @param string $signature Signature of object to load + * @return int >0 if OK, <0 if KO, 0 if not found */ public function fetch($id, $signature='') { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index d41790c63b5..26283d6b08a 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -19,7 +19,8 @@ * Class to manage Blocked Log */ -class BlockedLog { +class BlockedLog +{ /** * Id of the log @@ -41,14 +42,34 @@ class BlockedLog { public $amounts = null; + /** + * trigger action + * @var string + */ public $action = ''; + /** + * Object element + * @var string + */ public $element = ''; + /** + * Object id + * @var int + */ public $fk_object = 0; + /** + * Log certified by remote authority or not + * @var boolean + */ public $certified = false; + /** + * Author + * @var int + */ public $fk_user = 0; public $date_object = 0; @@ -71,8 +92,6 @@ class BlockedLog { /** * try to retrieve logged object - * - * @param object|string $object object logged */ public function getObject() { global $langs; @@ -100,9 +119,7 @@ class BlockedLog { /** * try to retrieve user author - * - * @param object|string $object object logged - */ + */ public function getUser() { global $langs, $cachedUser; @@ -144,19 +161,19 @@ class BlockedLog { if($this->element === 'facture') { if(empty($object->thirdparty))$object->fetch_thirdparty(); - $this->object_data->thirdparty=new stdClass(); + $this->object_data->thirdparty = new stdClass(); foreach($object->thirdparty as $key=>$value) { if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } - $this->object_data->total_ht = (double)$object->total_ht; - $this->object_data->total_tva = (double)$object->total_tva; - $this->object_data->total_ttc = (double)$object->total_ttc; - $this->object_data->total_localtax1= (double)$object->total_localtax1; - $this->object_data->total_localtax2= (double)$object->total_localtax2; - $this->object_data->note_public = (double)$object->note_public; - $this->object_data->note_private= (double)$object->note_private; + $this->object_data->total_ht = (double) $object->total_ht; + $this->object_data->total_tva = (double) $object->total_tva; + $this->object_data->total_ttc = (double) $object->total_ttc; + $this->object_data->total_localtax1= (double) $object->total_localtax1; + $this->object_data->total_localtax2= (double) $object->total_localtax2; + $this->object_data->note_public = (double) $object->note_public; + $this->object_data->note_private= (double) $object->note_private; } elseif($this->element==='payment'){ @@ -171,7 +188,7 @@ class BlockedLog { /** * Get object from database * - * @param int $rowid Id of object to load + * @param int $id Id of object to load * @return int >0 if OK, <0 if KO, 0 if not found */ public function fetch($id) { @@ -203,7 +220,7 @@ class BlockedLog { $this->ref = $obj->rowid; $this->signature = $obj->signature; - $this->amounts = (double)$obj->amounts; + $this->amounts = (double) $obj->amounts; $this->action = $obj->action; $this->element = $obj->element; @@ -434,7 +451,7 @@ class BlockedLog { } else{ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog - WHERE element='".$element."' AND fk_object=".(int)$fk_object; + WHERE element='".$element."' AND fk_object=".(int) $fk_object; } @@ -480,7 +497,7 @@ class BlockedLog { $res = $this->db->query($sql); if($res && $obj = $this->db->fetch_object($res)) { - $this->amounts = (double)$obj->amount; + $this->amounts = (double) $obj->amount; } } From 7c0de18ac18b2c2e8ae78c8f38f7c915e4a1c486 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 12:56:28 +0200 Subject: [PATCH 044/342] Fix code comment --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/journals_list.php | 2 +- htdocs/adherents/card.php | 2 +- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/admin/dict.php | 2 +- htdocs/admin/index.php | 2 +- htdocs/admin/mails_templates.php | 2 +- htdocs/admin/websites.php | 2 +- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/index.php | 2 +- htdocs/comm/action/listactions.php | 2 +- htdocs/comm/action/pertype.php | 2 +- htdocs/comm/action/peruser.php | 2 +- htdocs/comm/card.php | 2 +- htdocs/comm/mailing/advtargetemailing.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/comm/mailing/list.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/list.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/commande/orderstoinvoice.php | 2 +- htdocs/compta/bank/bankentries.php | 2 +- htdocs/compta/bank/index.php | 2 +- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/compta/deplacement/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/list.php | 4 ++-- htdocs/compta/localtax/card.php | 2 +- htdocs/compta/paiement/list.php | 2 +- htdocs/compta/salaries/card.php | 2 +- htdocs/compta/tva/card.php | 2 +- htdocs/contact/agenda.php | 2 +- htdocs/contact/card.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/contrat/list.php | 4 ++-- htdocs/contrat/services.php | 2 +- htdocs/cron/list.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/don/list.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expedition/list.php | 4 ++-- htdocs/expensereport/card.php | 2 +- htdocs/expensereport/list.php | 4 ++-- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/fourn/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/commande/list.php | 4 ++-- htdocs/fourn/commande/orderstoinvoice.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/fourn/facture/list.php | 4 ++-- htdocs/fourn/facture/paiement.php | 2 +- htdocs/livraison/card.php | 2 +- htdocs/main.inc.php | 2 +- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/product/card.php | 2 +- htdocs/product/document.php | 2 +- htdocs/product/fournisseurs.php | 2 +- htdocs/product/info.php | 2 +- htdocs/product/list-with-listview.php | 2 +- htdocs/product/price.php | 2 +- htdocs/product/stats/commande.php | 2 +- htdocs/product/stats/commande_fournisseur.php | 2 +- htdocs/product/stats/contrat.php | 2 +- htdocs/product/stats/facture.php | 2 +- htdocs/product/stats/facture_fournisseur.php | 2 +- htdocs/product/stats/propal.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/product/stock/mouvement.php | 2 +- htdocs/product/stock/product.php | 2 +- htdocs/projet/card.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/projet/tasks.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/projet/tasks/time.php | 2 +- htdocs/public/demo/index.php | 2 +- htdocs/societe/agenda.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/societe/list.php | 4 ++-- htdocs/societe/notify/card.php | 2 +- htdocs/societe/price.php | 2 +- htdocs/societe/project.php | 2 +- htdocs/societe/rib.php | 4 ++-- htdocs/supplier_proposal/card.php | 2 +- htdocs/supplier_proposal/list.php | 4 ++-- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/clicktodial.php | 2 +- htdocs/user/document.php | 2 +- htdocs/user/group/perms.php | 2 +- htdocs/user/index.php | 2 +- htdocs/user/ldap.php | 2 +- htdocs/user/note.php | 2 +- htdocs/user/param_ihm.php | 2 +- htdocs/user/perms.php | 2 +- 103 files changed, 114 insertions(+), 114 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index e63e44b4f80..e22e993796f 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -80,7 +80,7 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->chartofaccount) accessforbidden(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index e78737c3fb9..1bf9a693efd 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -80,7 +80,7 @@ $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id','int'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 1421d71be97..68d5e5af5c0 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -66,7 +66,7 @@ if (empty($sortorder)) $sortorder='ASC'; $error = 0; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index fe3bd4f4cfd..147040fbf67 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -112,7 +112,7 @@ if ($id) $caneditfieldmember=$user->rights->adherent->creer; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('membercard','globalcard')); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 949d55020c8..ec6bb85710c 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -77,7 +77,7 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 21de6e305b5..d1cbcea4864 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -89,7 +89,7 @@ if ($rowid) $caneditfieldmember=$user->rights->adherent->creer; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscription')); // PDF diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index af3174c0b60..628ceb390e3 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -53,7 +53,7 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="c.dateadh"; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('subscriptionlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f2fa12446b3..f0be2ee9fae 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -79,7 +79,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter_x") || GETP } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('membertypecard','globalcard')); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 880c9a9ba1a..f903ce3e8fc 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -80,7 +80,7 @@ $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id','int'); $search_code = GETPOST('search_code','alpha'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index e9d38ad3776..a1ac45244e1 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -29,7 +29,7 @@ $langs->load("companies"); if (!$user->admin) accessforbidden(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('homesetup')); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 9ff909862a3..b25e3a6a2ee 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -71,7 +71,7 @@ $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('emailtemplates')); // Name of SQL tables of dictionaries diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 9aecc4dfb0a..1dc91786ada 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -59,7 +59,7 @@ $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 3a634cc21cd..1bb35fe7fe8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -95,7 +95,7 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); //var_dump($_POST); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('actioncard','globalcard')); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9a1d4db92ae..7d150efe140 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -118,7 +118,7 @@ $langs->load("agenda"); $langs->load("other"); $langs->load("commercial"); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agenda')); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 0e6fbb196a1..7bedc4d8356 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -109,7 +109,7 @@ if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permi $filtert=$user->id; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendalist')); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index c6fe302cf63..23d434742a0 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -140,7 +140,7 @@ $langs->load("agenda"); $langs->load("other"); $langs->load("commercial"); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agenda')); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index ecb30881433..2f1e3735cd2 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -139,7 +139,7 @@ $langs->load("agenda"); $langs->load("other"); $langs->load("commercial"); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agenda')); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 61fcc4dc502..b8906bd1038 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -80,7 +80,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('commcard','globalcard')); diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 0262a50d65c..832cefa5774 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -768,7 +768,7 @@ if ($object->fetch($id) >= 0) { $std_soc = new Societe($db); $action_search = 'query'; - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array ('thirdpartycard')); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 956710e2abc..353117f5fa3 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -52,7 +52,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('mailingcard','globalcard')); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 65e82b8f939..fb513c99b9b 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -45,7 +45,7 @@ $sall=GETPOST('sall', 'alphanohtml'); $sref=GETPOST("sref", "alpha"); $filteremail=GETPOST('filteremail','alpha'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('mailinglist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4e26437fd19..d58f2223adb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -107,7 +107,7 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('', $object->error); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('propalcard','globalcard')); $permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index cb4aa123f12..220422a6404 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -95,7 +95,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='proposallist'; // Security check @@ -113,7 +113,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction=$conf->propal->dir_output . '/temp/massgeneration/'.$user->id; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('propallist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 189d13c3ced..eeea825c1e5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -98,7 +98,7 @@ $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 -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('ordercard','globalcard')); $permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 2f8810333f0..c49c1b18a4a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -96,7 +96,7 @@ if (! $sortorder) $sortorder='DESC'; // Initialize technical object to manage context to save list fields $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'orderlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 95e896160ce..e76adb2a67c 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -89,7 +89,7 @@ if ($action == 'create') } } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($db); $hookmanager->initHooks(array('orderstoinvoice')); diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 5f6d5156b72..5f50bf74c1b 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -131,7 +131,7 @@ if ($id > 0 || ! empty($ref)) $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); //var_dump($contextpage); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('banktransactionlist', $contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 44ecbe6eb6f..0c24d25e064 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -69,7 +69,7 @@ if (! $sortorder) $sortorder='ASC'; // Initialize technical object to manage context to save list fields $contextpage='bankaccountlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index c0481829425..9444c0585f7 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -52,7 +52,7 @@ $result = restrictedArea($user, 'banque', '', '', ''); $object = new PaymentVarious($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('variouscard','globalcard')); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 949a7701698..555ea52b4e0 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -46,7 +46,7 @@ $confirm = GETPOST('confirm','alpha'); $object = new Deplacement($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('tripsandexpensescard','globalcard')); $permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e9be0a0b962..c79beaac4f3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref)) { $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicecard','globalcard')); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index aa5c6103638..221167a485a 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -93,7 +93,7 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicereccard','globalcard')); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 746106b2307..00b18c00759 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -110,7 +110,7 @@ if (! $sortfield) $sortfield='f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='invoicelist'; // Security check @@ -124,7 +124,7 @@ $object=new Facture($db); $now=dol_now(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicelist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 315b89637af..bd1f83d7f43 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -44,7 +44,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); $localtax = new Localtax($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('localtaxvatcard','globalcard')); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index efc9d5e10d2..ec2bbc78fc6 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -68,7 +68,7 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 9abbecd35fc..20079ad18ee 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -48,7 +48,7 @@ $result = restrictedArea($user, 'salaries', '', '', ''); $object = new PaymentSalary($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard','globalcard')); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 4a3ea9ee516..ea26d2c55a8 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -45,7 +45,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); $object = new Tva($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('taxvatcard','globalcard')); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 6c412c146d1..74ec89bf5d1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -100,7 +100,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep, a.id'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactcard','globalcard')); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 67a7d9b31e4..ae13bb44a3a 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -76,7 +76,7 @@ if (! empty($canvas)) if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactcard','globalcard')); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b2f8066367c..1293a258fab 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -114,7 +114,7 @@ else if ($type == "o") $urlfiche=""; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3c644e4260c..4e19d6109b8 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -68,7 +68,7 @@ $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MA if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'contrat',$id); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contractcard','globalcard')); $object = new Contrat($db); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 11a259abce7..29e13412892 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -86,10 +86,10 @@ $staticcontratligne=new ContratLigne($db); if ($search_status == '') $search_status=1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='contractlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 0af99eeed33..3d5db42495a 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -77,7 +77,7 @@ $filter_opcloture=GETPOST('filter_opcloture'); // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'servicelist'.$mode; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 3b830e4801f..620efae0437 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -50,7 +50,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='t.status'; if (! $sortorder) $sortorder='ASC'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='cronjoblist'; $status=GETPOST('status','int'); @@ -62,7 +62,7 @@ $securitykey = GETPOST('securitykey','alpha'); $diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('cronjoblist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 8e1bd00d893..33f2375a1bf 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -60,7 +60,7 @@ $result = restrictedArea($user, 'don', $id); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('doncard','globalcard')); /* diff --git a/htdocs/don/list.php b/htdocs/don/list.php index a4f5f07679f..24ee68eb0f7 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -61,7 +61,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_amount=""; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('orderlist')); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 966f1f95972..e3a1b0bc3fa 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -98,7 +98,7 @@ $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_el // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('expeditioncard','globalcard')); $permissiondellink=$user->rights->expedition->livraison->creer; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 091b5e44bb8..c4a07580a9a 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -64,12 +64,12 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='shipmentlist'; $viewstatut=GETPOST('viewstatut'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('shipmentlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index dff27139581..d9c195f4ca9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -105,7 +105,7 @@ $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 -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('expensereportcard','globalcard')); $permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 9cf47ddea94..8a8014edcb6 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -79,10 +79,10 @@ $optioncss = GETPOST('optioncss','alpha'); if ($search_status == '') $search_status=-1; if ($search_user == '') $search_user=-1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='expensereportlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('expensereportlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 51cd5a62d3f..9e463eb8ac4 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -76,7 +76,7 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('interventioncard','globalcard')); $object = new Fichinter($db); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 68d4e2bef34..0404f976328 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -82,7 +82,7 @@ $search_desc=GETPOST('search_desc','alpha'); $search_status=GETPOST('search_status'); $optioncss = GETPOST('optioncss','alpha'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 7b24ee4f082..e5e42042015 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -58,7 +58,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('suppliercard','globalcard')); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f77eb949c9a..2137e7ca747 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -92,7 +92,7 @@ $datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), G if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('ordersuppliercard','globalcard')); $object = new CommandeFournisseur($db); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 86fb7e5c4f5..9e8d841e976 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -114,10 +114,10 @@ if (! $sortorder) $sortorder='DESC'; if ($search_status == '') $search_status=-1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='supplierorderlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('orderlist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 9fb9a63828d..a503776b653 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -88,7 +88,7 @@ if ($action == 'create') } } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array('orderstoinvoicesupplier')); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0ec657ccdfe..306ad62d69b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -81,7 +81,7 @@ $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicesuppliercard','globalcard')); $object=new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 782a78981ed..0e19c73615b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -116,7 +116,7 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef,f.rowid"; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='supplierinvoicelist'; $diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id; @@ -125,7 +125,7 @@ $object=new FactureFournisseur($db); $now=dol_now(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('supplierinvoicelist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index f51246d8eea..59b6e2a27e9 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -79,7 +79,7 @@ if ($user->societe_id > 0) } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentsupplier')); $extrafields = new ExtraFields($db); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 4bfcc4611e6..bf8dc3e9bed 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -74,7 +74,7 @@ $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_el // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('deliverycard','globalcard')); /* diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 26f455131cd..67458a66445 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -643,7 +643,7 @@ if (! defined('NOLOGIN')) } else { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); // Code for search criteria persistence. diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 3c9e721b3f6..d7257a3cb1d 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -52,7 +52,7 @@ if (! $sortfield) $sortfield="f.datef"; $object = new Societe($db); if ($socid > 0) $object->fetch($socid); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartymargins','globalcard')); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 02ad2f5172c..d42dc87b4b9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -113,7 +113,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productcard','globalcard')); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 2cf2f36b419..2b76fb0a111 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -50,7 +50,7 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productdocuments')); // Get parameters diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a12499e4eac..84532ad219e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -65,7 +65,7 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('pricesuppliercard','globalcard')); $object = new ProductFournisseur($db); diff --git a/htdocs/product/info.php b/htdocs/product/info.php index e6011c7945c..b73883a9aa0 100644 --- a/htdocs/product/info.php +++ b/htdocs/product/info.php @@ -36,7 +36,7 @@ $ref = GETPOST('ref','alpha'); $result=restrictedArea($user,'produit|service',$id,'product&product'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('infoproduct')); $object = new Product($db); diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 947cfaecbc2..8e4218db227 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -93,7 +93,7 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'productser if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; } if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); $form=new Form($db); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 41f5cda1eb7..c1a6568f82b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) // Clean param if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productpricecard','globalcard')); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 94eeb756385..f4c0c66cdec 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -44,7 +44,7 @@ $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatsorder')); $mesg = ''; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 3201e7ed2e8..dafb2b5aafd 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -44,7 +44,7 @@ if (! empty($user->societe_id)) $socid = $user->societe_id; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array ( 'productstatssupplyorder' )); diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index cae9c86104f..b5a8ec2b039 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -41,7 +41,7 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatscontract')); $mesg = ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 92a80cf018e..d4f447128a1 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -45,7 +45,7 @@ $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatsinvoice')); $showmessage=GETPOST('showmessage'); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 8da1a68d9c2..5701b8960e5 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -46,7 +46,7 @@ $socid = ''; if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatssupplyinvoice')); $mesg = ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index ec796422f0b..c9aa8fd85bc 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -43,7 +43,7 @@ $socid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array ('productstatspropal')); $mesg = ''; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 665d340f6f9..28e3f187f13 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -53,7 +53,7 @@ $backtopage=GETPOST("backtopage"); // Security check $result=restrictedArea($user,'stock'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('warehousecard','globalcard')); $object = new Entrepot($db); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 7a8010117a2..a227d62c5d9 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -79,7 +79,7 @@ $pdluoid=GETPOST('pdluoid','int'); // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 81942468ab3..69421aa5624 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -96,7 +96,7 @@ if (! empty($canvas)) $objcanvas->getCanvas('stockproduct','card',$canvas); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('stockproductcard','globalcard')); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 174d93f4aef..e8c48352120 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -51,7 +51,7 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti $mine = GETPOST('mode')=='mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projectcard','globalcard')); $object = new Project($db); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 827719148fe..0c638f8dd6b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -99,7 +99,7 @@ if ($search_status == '') $search_status=-1; // -1 or 1 // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'projectlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 064281633c8..a9e50f96f91 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -64,7 +64,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard','globalcard')); $progress=GETPOST('progress', 'int'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 18f133513b1..47387ec625a 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -70,7 +70,7 @@ $search_eyear = GETPOST('search_eyear','int'); // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'tasklist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 6018b8bef69..2d35be97f4a 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -50,7 +50,7 @@ $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (! $user->rights->projet->lire) accessforbidden(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard','globalcard')); $object = new Task($db); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 08eb429f664..2ace6736889 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -69,7 +69,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard','globalcard')); $object = new Task($db); diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index d5db9866c1f..a24b43b806a 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -45,7 +45,7 @@ $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',0,0,1); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $res=$hookmanager->initHooks(array('demo')); $demoprofiles=array(); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 15ea29e9954..4d1ce4da9c7 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -61,7 +61,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep,a.id'; if (! $sortorder) $sortorder='DESC'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d6710f68c92..e26b4733c84 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -69,7 +69,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycard','globalcard')); if ($action == 'view' && $object->fetch($socid)<=0) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 29bc06ff760..1fcd73f0ddc 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -78,7 +78,7 @@ $langs->load("interventions"); $langs->load("contracts"); $langs->load("products"); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('consumptionthirdparty')); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 422768bce31..3bde7f09967 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -95,7 +95,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='thirdpartylist'; /*if ($search_type == '1,3') { $contextpage='customerlist'; $type='c'; } if ($search_type == '2,3') { $contextpage='prospectlist'; $type='p'; } @@ -105,7 +105,7 @@ if ($type == 'c') { $contextpage='customerlist'; if ($search_type=='') $search_t if ($type == 'p') { $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } if ($type == 'f') { $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index eacd047d93a..8487185ecd5 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -59,7 +59,7 @@ $now=dol_now(); $object = new Societe($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartynotification','globalcard')); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 952a34a9a59..05e39ffc576 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -52,7 +52,7 @@ $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycustomerprice','globalcard')); diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 72c371ce934..df2deb9da0c 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -39,7 +39,7 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projectthirdparty')); diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 36914d74585..cb5dffc3399 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -59,11 +59,11 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartybancard','globalcard')); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartybancard')); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 020473fee59..c7807d8c4e5 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('', $object->error); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('supplier_proposalcard','globalcard')); $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 7eb5d1323ed..e401fdbe710 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -96,7 +96,7 @@ if ($object_statut != '') $search_status=$object_statut; // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage='supplierproposallist'; // Security check @@ -114,7 +114,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction=$conf->supplier_proposal->dir_output . '/temp/massgeneration/'.$user->id; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('supplier_proposallist')); $extrafields = new ExtraFields($db); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index e789a8277f3..255b476eb61 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -67,7 +67,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); /* diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 1500a3be55c..2ba3c67d0b4 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -41,7 +41,7 @@ if ($user->id == $id) // A user can always read its own card } $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); /* diff --git a/htdocs/user/document.php b/htdocs/user/document.php index b15af46bcd8..bc4727feaa8 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -93,7 +93,7 @@ if ($id > 0 || ! empty($ref)) $upload_dir = $conf->user->multidir_output[$entitytouseforuserdir] . "/" . $object->id ; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 77532de7c3e..94a9c9c1883 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -72,7 +72,7 @@ if (! empty($conf->multicompany->enabled)) $entity=(! empty($object->entity) ? $object->entity : $conf->entity); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('groupcard','globalcard')); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index da5ddd99339..f5434f822d5 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -60,7 +60,7 @@ if (! $sortorder) $sortorder="ASC"; // Initialize context for list $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userlist'; -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 252ed9f82b4..96c0ac881be 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -45,7 +45,7 @@ $object = new User($db); $object->fetch($id, '', '', 1); $object->getrights(); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); /* diff --git a/htdocs/user/note.php b/htdocs/user/note.php index b9e8cb69869..1734e7286d4 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -49,7 +49,7 @@ $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); if ($user->id == $id) $feature2=''; // A user can always read its own card $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 9ffeb05f280..8831b56f09a 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -78,7 +78,7 @@ $searchformtitle=array($langs->trans("Companies"),$langs->trans("Contacts"),$lan $form = new Form($db); $formadmin=new FormAdmin($db); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 041213fbe64..5d87232c928 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -79,7 +79,7 @@ if (! empty($conf->multicompany->enabled)) $entity=(! empty($object->entity) ? $object->entity : $conf->entity); } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('usercard','globalcard')); From 5dfb988cb17042971ef9f0cc0b3b6ecab78fd9ba Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 10 Jun 2017 13:34:28 +0200 Subject: [PATCH 045/342] Fix 6944 compatibility PHP7 and missing parameter to call delete function --- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/fourn/facture/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 12fccab91d8..03f3ecb0e21 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -533,7 +533,7 @@ class PaiementFourn extends Paiement * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='') + function getNomUrl($withpicto=0,$option='',$mode='withlistofinvoices') { global $langs; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0ec657ccdfe..813f23cdc88 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -218,7 +218,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fetch_thirdparty(); - $result=$object->delete($id); + $result=$object->delete($user, $id); if ($result > 0) { header('Location: list.php'); From a8e16910c0f22413d78651dde5d8b1e9495026d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 13:44:20 +0200 Subject: [PATCH 046/342] Fix look and feel v6 --- htdocs/comm/action/rapport/index.php | 46 +++++++-- htdocs/core/class/html.formfile.class.php | 116 +++++++++++----------- 2 files changed, 95 insertions(+), 67 deletions(-) diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index f6d01b18ca1..e83506d8206 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -26,6 +26,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php'; @@ -71,6 +72,8 @@ if ($action == 'builddoc') * View */ +$formfile=new FormFile($db); + llxHeader(); $sql = "SELECT count(*) as cc,"; @@ -103,7 +106,7 @@ if ($resql) $param=''; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - + print '
'; if ($optioncss != '') print ''; print ''; @@ -112,23 +115,24 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); $moreforfilter=''; - + $i = 0; print '
'; print ''."\n"; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print "\n"; + $var=true; while ($i < min($num,$limit)) { @@ -136,23 +140,47 @@ if ($resql) if ($obj) { - + print ''; + // Date print "\n"; + + // Nb of events print ''; + // Button to build doc print ''; $name = "actions-".$obj->month."-".$obj->year.".pdf"; $relativepath= $name; $file = $conf->agenda->dir_temp."/".$name; + $modulepart = 'actionsreport'; + $documenturl= DOL_URL_ROOT.'/document.php'; + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper if (file_exists($file)) { - print ''; + print ''; print ''; print ''; } @@ -169,7 +197,7 @@ if ($resql) print "
'.$langs->trans("Date").''.$langs->trans("Period").''.$langs->trans("EventsNb").''.$langs->trans("Action").''.$langs->trans("PDF").''.$langs->trans("PDF").''.$langs->trans("Date").''.$langs->trans("Size").'
".$obj->df."'.$obj->cc.''; - print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('GenerateReport'),'filenew').''; + print 'month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').''; print ''.img_pdf().''; + //print ''.img_pdf().''; + + $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file'); + $out=''; + + // Show file name with link to download + $tmp = $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param); + $out.= ($tmp?$tmp.' ':''); + $out.= 'trans("File").': '.$filearray["name"]).' '.$filearray["name"]; + $out.= ''."\n"; + print $out; + + print ''.dol_print_date(dol_filemtime($file),'dayhour').''.dol_print_size(dol_filesize($file)).'
"; print '
'; print '
'; - + $db->free($resql); } else diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e263efeaa57..89cf70951ad 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -35,7 +35,7 @@ class FormFile { private $db; - + public $error; public $numoffiles; public $infofiles; // Used to return informations by function getDocumentsLink @@ -332,11 +332,11 @@ class FormFile jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Hide")).')"); } return false; - }); + }); }); '; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -593,7 +593,7 @@ class FormFile if (empty($noform)) $out.= '
'; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= '
'; $out.= ''; @@ -682,9 +682,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -706,8 +706,8 @@ class FormFile $out.= ''; $documenturl = DOL_URL_ROOT.'/document.php'; - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper + // Show file name with link to download $out.= ''; @@ -791,7 +791,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.=''; @@ -835,7 +835,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); //if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -876,7 +876,7 @@ class FormFile $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); if ($tmparray && $tmparray['url']) $tmpout.= '
  • '.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'
  • '; } - + // Download $tmpout.= '
  • initHooks(array('formfile')); @@ -983,7 +983,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -992,7 +992,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) { @@ -1003,7 +1003,7 @@ class FormFile } print '
    '; print '
  • '; $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); @@ -774,7 +774,7 @@ class FormFile if (is_array($link_list)) { $colspan=2; - + foreach($link_list as $file) { $out.='
    '.$langs->trans("None").'
    '."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -1017,10 +1017,10 @@ class FormFile if ($relativedir) { $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); - + //var_dump($filearray); //var_dump($filearrayindatabase); - + // Complete filearray with properties found into $filearrayindatabase foreach($filearray as $key => $val) { @@ -1040,7 +1040,7 @@ class FormFile break; } } - + if (! $found) // This happen in transition towerd version 6, or if files were added manually into os dir. { $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position @@ -1053,13 +1053,13 @@ class FormFile dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile=new EcmFiles($this->db); - + // Add entry into database $filename = basename($rel_filename); $rel_dir = dirname($rel_filename); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - + $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; $ecmfile->label = md5_file(dol_osencode($filearray[$key]['fullname'])); // $destfile is a full path to file @@ -1083,21 +1083,21 @@ class FormFile } } } - + /*var_dump($filearray); var_dump($sortfield); var_dump($sortorder);*/ - + if ($sortfield && $sortorder) { $filearray=dol_sort_array($filearray, $sortfield, $sortorder); } //var_dump($filearray); } - + $nboffiles=count($filearray); if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - + $var=true; $i=0; $nboflines = 0; $lastrowid=0; foreach($filearray as $key => $file) // filearray must be only files here { @@ -1105,10 +1105,10 @@ class FormFile && $file['name'] != '..' && ! preg_match('/\.meta$/i',$file['name'])) { - - + + if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; - + $editline=0; $nboflines++; print ''."\n"; @@ -1116,11 +1116,11 @@ class FormFile print ''."\n"; print ''; print ''; - + print ''; - + // Preview if (empty($useinecm)) { @@ -1175,7 +1175,7 @@ class FormFile // Delete or view link // ($param must start with &) print '"; if (empty($disablemove)) { - if ($nboffiles > 1 && empty($conf->browser->phone)) { - print ''; } print "\n"; - + $i++; } } @@ -1260,19 +1260,19 @@ class FormFile } print "
    '; - + $filepath=$relativepath.$file['name']; - + if (! $editline) print $this->showPreview($file,$modulepart,$filepath); - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; - + print ''.dol_print_size($file['size'],1,1).''.dol_print_date($file['date'],"dayhour","tzuser").''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1183,10 +1183,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1195,7 +1195,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1213,15 +1213,15 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "'; + if ($nboffiles > 1 && empty($conf->browser->phone)) { + print ''; if ($i > 0) { print 'id.'">'.img_up('default',0,'imgupforline').''; } @@ -1245,7 +1245,7 @@ class FormFile if (empty($disablemove)) print '
    "; print '
    '; - - if (! $editline && $nboflines > 1) { + + if (! $editline && $nboflines > 1) { if (! empty($conf->use_javascript_ajax) && $permtoeditline) { $table_element_line = 'ecm_files'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - } - + } + if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline) { print ''; } - + return $nboffiles; } } @@ -1449,19 +1449,19 @@ class FormFile if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files - + print ''."\n"; print ''; print ''; if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document'); else print $langs->trans("ObjectDeleted",($id?$id:$ref)); - + $filename=dol_sanitizeFileName($ref); //$filedir=$conf->$modulepart->dir_output . '/' . dol_sanitizeFileName($obj->ref); $filedir=$file['path']; //$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; //print $formfile->getDocumentsLink($modulepart, $filename, $filedir); - + print ''; print ''; //print "XX".$file['name']; //$file['name'] must be utf8 @@ -1471,9 +1471,9 @@ class FormFile print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; print dol_trunc($file['name'],$maxlength,'middle'); print '
    '; - + print $this->getDocumentsLink($modulepart, $filename, $filedir); - + print "\n"; print ''.dol_print_size($file['size'],1,1).''; print ''.dol_print_date($file['date'],"dayhour").''; @@ -1668,11 +1668,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs From 6ab47a845e9c1bcb8df1c792d6cb36121ca2ef07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 13:54:43 +0200 Subject: [PATCH 047/342] Fix look and feel v6 --- htdocs/comm/action/listactions.php | 22 ++++++------ htdocs/core/class/html.formactions.class.php | 37 +++++++++++++------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 7bedc4d8356..01094a78164 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -47,12 +47,12 @@ $status=GETPOST("status",'alpha'); $type=GETPOST('type'); $optioncss = GETPOST('optioncss','alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('actioncode','array')) +if (GETPOST('actioncode','array')) { $actioncode=GETPOST('actioncode','array',3); if (! count($actioncode)) $actioncode='0'; } -else +else { $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } @@ -337,11 +337,11 @@ if ($resql) if ($pid) $nav.=''; if ($usergroup) $nav.=''; print $nav; - + print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $link, $num, -1 * $nbtotalofrecords, '', 0, $nav, '', $limit); $moreforfilter=''; - + $i = 0; print '
    '; print ''."\n"; @@ -369,11 +369,11 @@ if ($resql) print $searchpicto; print ''; print "\n"; - + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); - //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); @@ -392,7 +392,7 @@ if ($resql) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; $caction=new CActionComm($db); $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0)); - + $var=true; while ($i < min($num,$limit)) { @@ -405,15 +405,13 @@ if ($resql) continue; } - - $actionstatic->id=$obj->id; $actionstatic->ref=$obj->id; $actionstatic->type_code=$obj->type_code; $actionstatic->type_label=$obj->type_label; $actionstatic->type_picto=$obj->type_picto; $actionstatic->label=$obj->label; - + print ''; // Action (type) @@ -443,7 +441,7 @@ if ($resql) if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype]; print dol_trunc($labeltype,28); print ''; - + // Start date print ''; print ''; - + print "\n"; $i++; } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 456faa7931e..a6ec8db928a 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -188,9 +188,9 @@ class FormActions print load_fiche_titre($title, $buttontoaddnewevent, ''); $page=0; $param=''; $sortfield='a.datep'; - - $total = 0; - + + $total = 0; + print '
    '; print '
    '; print dol_print_date($db->jdate($obj->dp),"dayhour"); @@ -514,7 +512,7 @@ if ($resql) print ''.$actionstatic->LibStatut($obj->percent,3,1,$datep).'
    '; print ''; @@ -209,12 +209,23 @@ class FormActions { $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); - - + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; $i++; } - print '
    '.$ref.''.$label.''.$action->type.''; + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($action->type_picto) print img_picto('', $action->type_picto); + else { + if ($action->type_code == 'AC_RDV') print img_picto('', 'object_group').' '; + if ($action->type_code == 'AC_TEL') print img_picto('', 'object_phoning').' '; + if ($action->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax').' '; + if ($action->type_code == 'AC_EMAIL') print img_picto('', 'object_email').' '; + } + } + print $action->type; + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { @@ -233,7 +244,7 @@ class FormActions $userstatic->id = $action->author->id; $userstatic->firstname = $action->author->firstname; $userstatic->lastname = $action->author->lastname; - print $userstatic->getNomUrl(1); + print $userstatic->getNomUrl(1, '', 0, 0, 16, 0, '', ''); } print ''; @@ -285,22 +296,22 @@ class FormActions if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); $out=''; - - if (! empty($multiselect)) + + if (! empty($multiselect)) { if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } - else + else { $out.=$form->selectarray($htmlname, $arraylist, $selected); } - - if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) + + if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); } - + if ($nooutput) return $out; else print $out; return ''; From 0d24df9ffcd0762bc732da77bd80badf81f8af80 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 10 Jun 2017 14:40:17 +0200 Subject: [PATCH 048/342] Fix 6939 new path for pictures is not used --- .../supplier_proposal/doc/pdf_aurore.modules.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 3b2812c7b90..c546aad91ad 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -167,9 +167,17 @@ class pdf_aurore extends ModelePDFSupplierProposal $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; - + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } + else + { + $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) { From b6af1f7e6effed2bad4d06b15cb0ba7b8787ee90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 15:21:49 +0200 Subject: [PATCH 049/342] Fix responsive design --- htdocs/public/demo/demo.css | 5 +++++ htdocs/public/demo/index.php | 31 ++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index dd1f7aad7b7..daf4f20e585 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -65,6 +65,11 @@ a:hover { } @media only screen and (max-width: 420px) { + .demomaxoveflow { + max-width: none !important; + overflow: hidden; + text-overflow: ellipsis; + } .csscolumns { -webkit-column-count: 1; /* Chrome, Safari, Opera */ -moz-column-count: 1; /* Firefox */ diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index a24b43b806a..fe8da7ee072 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -316,7 +316,7 @@ foreach ($demoprofiles as $profilearray) { print '
    '; } - + print '
    '."\n"; print ''."\n"; print ''."\n"; @@ -328,34 +328,35 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
    '."\n"; + print '
    '."\n"; + - print '
    '; print ''; print '
    '; - + print 'Demo '.$profilearray['label'].''; - + print '
    '; - + print '
    '; print $langs->trans($profilearray['label']); print '
    '; - + print '
    '; print '
    '; - - + + // Modules if (empty($profilearray['url'])) { - print ''."\n"; $blockvmenuopened=false; } } } - if ($altok) print '
    '; + if ($altok) print '
    '; // End menu block } if (is_array($moredata) && ! empty($moredata['bookmarks'])) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7a1dfcd4ecf..8c83435914b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -445,7 +445,7 @@ function print_end_menu_array() * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' - * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not efined in session. + * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session. * @param array $moredata An array with more data to output * @return int nb of menu entries */ @@ -1023,7 +1023,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $objp = $db->fetch_object($resql); $nature=''; - // Must match array $sourceList defined into journals_list.php + // Must match array $sourceList defined into journals_list.php if ($objp->nature == 2) $nature="sells"; if ($objp->nature == 3) $nature="purchases"; if ($objp->nature == 4) $nature="bank"; @@ -1558,14 +1558,14 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $invert=empty($conf->global->MAIN_MENU_INVERT)?"":"invert"; if (empty($noout)) { - $alt=0; $altok=0; $blockvmenuopened=false; + $altok=0; $blockvmenuopened=false; $lastlevel0=''; $num=count($menu_array); - for ($i = 0; $i < $num; $i++) + for ($i = 0; $i < $num; $i++) // Loop on each menu entry { $showmenu=true; if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false; - $alt++; + // Begin of new left menu block if (empty($menu_array[$i]['level']) && $showmenu) { $altok++; @@ -1585,7 +1585,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } - // Place tabulation + // Add tabulation $tabstring=''; $tabul=($menu_array[$i]['level'] - 1); if ($tabul > 0) @@ -1625,26 +1625,35 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''."\n"; - // Menu niveau 0 + // Menu level 0 if ($menu_array[$i]['level'] == 0) { - if ($menu_array[$i]['enabled']) + if ($menu_array[$i]['enabled']) // Enabled so visible { print '
    '."\n"; + $lastlevel0='enabled'; } - else if ($showmenu) + else if ($showmenu) // Not enabled but visible (so greyed) { print ''."\n"; + $lastlevel0='greyed'; + } + else + { + $lastlevel0='hidden'; } if ($showmenu) + { print ''."\n"; + } } - // Menu niveau > 0 + // Menu level > 0 if ($menu_array[$i]['level'] > 0) { - if ($menu_array[$i]['enabled']) + if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled. { print ''."\n"; } - else if ($showmenu) + else if ($showmenu && $lastlevel0 == 'enabled') // Not enabled but visible (so greyed), except if parent was not enabled. { print ''."\n"; } } // If next is a new block or if there is nothing after - if (empty($menu_array[$i+1]['level'])) + if (empty($menu_array[$i+1]['level'])) // End menu block { if ($showmenu) print ''."\n"; @@ -1669,7 +1678,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } - if ($altok) print '
    '; + if ($altok) print '
    '; // End menu block } return count($menu_array); diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 9750811ffa5..b0b7f95c27b 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -105,7 +105,7 @@ class MenuManager $menuArbo = new Menubase($this->db,'eldy'); $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); $this->tabMenu=$tabMenu; - + //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } } @@ -149,13 +149,13 @@ class MenuManager print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output return $this->menu->getNbOfVisibleMenuEntries(); } - + if ($mode == 'jmobile') { print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu // $this->menu->liste is top menu - //var_dump($this->menu->liste);exit; + //var_dump($this->menu->liste);exit; print ''."\n"; foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { @@ -168,12 +168,12 @@ class MenuManager $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); $relurl=preg_replace('/__USERID__/',$user->id,$relurl); - + print '
    '; - + // Add font-awesome if ($val['level'] == 0 && $val['mainmenu'] == 'home') print ''; - + print $val['titre']; print ''."\n"; // Search submenu fot this mainmenu entry @@ -184,7 +184,7 @@ class MenuManager //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } $nexturl=dol_buildpath($submenu->liste[0]['url'],1); - + $canonrelurl=preg_replace('/\?.*$/','',$relurl); $canonnexturl=preg_replace('/\?.*$/','',$nexturl); //var_dump($canonrelurl); @@ -198,16 +198,16 @@ class MenuManager print ''; - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation { if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); - else print $langs->trans("Dashboard"); + else print $langs->trans("Dashboard"); } else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); print ''; print ''."\n"; } - + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'] { $showmenu=true; diff --git a/htdocs/public/demo/demo.css b/htdocs/public/demo/demo.css index daf4f20e585..c4624f2d943 100644 --- a/htdocs/public/demo/demo.css +++ b/htdocs/public/demo/demo.css @@ -32,16 +32,15 @@ a:hover { background: -webkit-linear-gradient(bottom, rgb(255,255,255) 85%, rgb(255,255,255) 100%); } .csscolumns { - margin-left: 8px; margin-top: 6px; margin-bottom: 5px; - -webkit-column-count: 4; /* Chrome, Safari, Opera */ - -moz-column-count: 4; /* Firefox */ - column-count: 3; + -webkit-column-count: 2; /* Chrome, Safari, Opera */ + -moz-column-count: 2; /* Firefox */ + column-count: 2; text-align: left; } .demomaxoveflow { - max-width: 100px; + max-width: 120px; overflow: hidden; text-overflow: ellipsis; } diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index fe8da7ee072..be844c8a2da 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -328,7 +328,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
    '."\n"; + print '
    '."\n"; print '
    '; From 039130c6943f4ba3f47d74ca09481a262f9a7c58 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sat, 10 Jun 2017 16:19:33 +0200 Subject: [PATCH 052/342] Fix travis --- htdocs/fourn/class/paiementfourn.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 03f3ecb0e21..25639bfd3f9 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -531,6 +531,7 @@ class PaiementFourn extends Paiement * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option Sur quoi pointe le lien + * @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$option='',$mode='withlistofinvoices') From ce470b8dd5aee2bc6ffdccb003bbe51d1046c004 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 16:23:24 +0200 Subject: [PATCH 053/342] Fix css fot liste_total lines --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4fd7120a771..bee5aac9d36 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2692,7 +2692,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - height: 32px; + /* height: 32px; */ } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { color: #552266; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index dc61977cf5f..9ec18cca050 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2775,7 +2775,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - height: 32px; + /* height: 32px; */ } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { /* border-top: 1px solid #f4f4f4; */ From 75452e6d19ee04dcfa802752dbc414bfd90e9db7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 16:29:25 +0200 Subject: [PATCH 054/342] Fix compatibility php 5.5- --- htdocs/main.inc.php | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 67458a66445..15934a32f86 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -300,7 +300,7 @@ if (! defined('NOTOKENRENEWAL')) { // roulement des jetons car cree a chaque appel if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; - + // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] $token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; @@ -659,7 +659,7 @@ if (! defined('NOLOGIN')) unset($_SESSION['lastsearch_values_tmp_'.$relativepathstring]); } } - + $action = ''; $reshook = $hookmanager->executeHooks('updateSession', array(), $user, $action); if ($reshook < 0) { @@ -667,7 +667,7 @@ if (! defined('NOLOGIN')) } } } - + // Is it a new session that has started ? // If we are here, this means authentication was successfull. if (! isset($_SESSION["dol_login"])) @@ -981,7 +981,7 @@ if (! function_exists("llxHeader")) { top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); } - + if (empty($conf->dol_hide_leftmenu)) { left_menu('', $help_url, '', '', 1, $title, 1); @@ -1011,13 +1011,13 @@ function top_httphead($contenttype='text/html') if (! empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) { // For example, to restrict script, object, frames or img to some domains - // script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; child-src https://youtube.com; img-src: https://static.example.com + // script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; child-src https://youtube.com; img-src: https://static.example.com // For example, to restrict everything to one domain, except object, ... // default-src https://cdn.example.net; object-src 'none' header("Content-Security-Policy: ".$conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY); } - - + + // On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1. /*if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); @@ -1085,7 +1085,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $ext='version='.urlencode(DOL_VERSION); if (GETPOST('version','int')) $ext='version='.GETPOST('version','int'); // usefull to force no cache on css/js if (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) $ext.='&testmenuhider='.(GETPOST('testmenuhider','int')?GETPOST('testmenuhider','int'):$conf->global->MAIN_TESTMENUHIDER); - + $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss','aZ09')?'&optioncss='.GETPOST('optioncss','aZ09',1):'').'&userid='.$user->id.'&entity='.$conf->entity; $themeparam.=($ext?'&'.$ext:''); if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; @@ -1094,7 +1094,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (GETPOST('dol_optimize_smallscreen','int')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen','int'); } if (GETPOST('dol_no_mouse_hover','int')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover','int'); } if (GETPOST('dol_use_jmobile','int')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile','int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile','int'); } - + if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { print ''."\n"; @@ -1122,13 +1122,13 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } } - + if (! defined('DISABLE_FONT_AWSOME')) { print ''."\n"; print ''."\n"; } - + print ''."\n"; // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php' $themepath=dol_buildpath($conf->css,1); @@ -1293,7 +1293,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; print ''."\n"; } - + // Browser notifications if (! defined('DISABLE_BROWSER_NOTIF')) { @@ -1306,7 +1306,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } } - + // Global js function print ''."\n"; print ''."\n"; @@ -1316,7 +1316,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { print ''."\n"; } - + // JS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) { @@ -1391,7 +1391,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $toprightmenu=''; // For backward compatibility with old modules - if (empty($conf->headerdone)) + if (empty($conf->headerdone)) { top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); print ''; @@ -1403,7 +1403,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (empty($conf->dol_hide_topmenu) && (! defined('NOREQUIREMENU') || ! constant('NOREQUIREMENU'))) { print "\n".''."\n"; - + print '
    '; // Show menu entries @@ -1461,7 +1461,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $toprightmenu.='
    '; $toprightmenu.='
    '; //unset($form); - + print '
    '; print "\n\n"; } @@ -1693,7 +1693,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra if (preg_match('/de/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.de'; if (preg_match('/it/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.it'; if (preg_match('/gr/i',$langs->defaultlang)) $doliurl='https://www.dolibarr.gr'; - + $appli=constant('DOL_APPLICATION_TITLE'); if (! empty($conf->global->MAIN_APPLICATION_TITLE)) { @@ -1778,7 +1778,7 @@ function main_area($title='') print "\n"; print ''."\n".'
    '."\n"; - + if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); } @@ -1908,7 +1908,7 @@ if (! function_exists("llxFooter")) { if (empty($val['sortfield'])) unset($val['sortfield']); if (empty($val['sortorder'])) unset($val['sortorder']); - dol_syslog('Save lastsearch_values_tmp_'.$key.'='.json_encode($val, 0, 1)." (systematic recording of last search criteria)"); + dol_syslog('Save lastsearch_values_tmp_'.$key.'='.json_encode($val, 0)." (systematic recording of last search criteria)"); $_SESSION['lastsearch_values_tmp_'.$key]=json_encode($val); unset($_SESSION['lastsearch_values_'.$key]); } @@ -1935,7 +1935,7 @@ if (! function_exists("llxFooter")) } print "\n\n"; - + print '
    '."\n"; // End div fiche if (empty($conf->dol_hide_leftmenu)) print '
    '; // End div id-right @@ -1970,7 +1970,7 @@ if (! function_exists("llxFooter")) }); ' . "\n"; } - + // Wrapper to manage document_preview if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) { @@ -1985,7 +1985,7 @@ if (! function_exists("llxFooter")) }); ' . "\n"; } - + // Wrapper to manage dropdown if ($conf->use_javascript_ajax) { @@ -2016,7 +2016,7 @@ if (! function_exists("llxFooter")) console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul"); $(this).parent().parent().hide(); }); - + $(document).bind(\'click\', function (e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); @@ -2024,7 +2024,7 @@ if (! function_exists("llxFooter")) }); '; } - + // A div for the address popup print "\n\n"; print ''."\n"; From 890ac81e4de89f1080e7a3d5e445f421f1a0136a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 19:16:42 +0200 Subject: [PATCH 055/342] Fix menu entried must be greyed, sub menus not visible fi not allowed on parent. --- htdocs/core/lib/functions.lib.php | 5 +- htdocs/core/menus/standard/auguria_menu.php | 88 ++++++++++++++++++--- htdocs/core/menus/standard/eldy_menu.php | 76 +++++++++++++++--- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 2 +- 5 files changed, 145 insertions(+), 27 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6f73d504d11..3157348062a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5949,8 +5949,9 @@ function printCommonFooter($zone='private') print ''."\n"; print 'jQuery(".menuhider").click(function() {'; print ' console.log("We click on .menuhider");'."\n"; - print " $('.side-nav').toggle();"; - print " $('.login_block').toggle();"; + //print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md + print " $('.side-nav').toggle()\n"; + print " $('.login_block').toggle()\n"; print '});'."\n"; } diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index 4b19ffd5f3b..bd762083d2f 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -115,7 +115,7 @@ class MenuManager /** * Show menu * - * @param string $mode 'top', 'left', 'jmobile' + * @param string $mode 'top', 'left', 'jmobile' (used to get full xml ul/li menu) * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ @@ -136,17 +136,20 @@ class MenuManager if ($mode == 'top') print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); if ($mode == 'left') print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); - + if ($mode == 'topnb') { print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); return $this->menu->getNbOfVisibleMenuEntries(); } - - if ($mode == 'jmobile') + + if ($mode == 'jmobile') // Used to get menu in xml ul/li { print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); + // $this->menu->liste is top menu + //var_dump($this->menu->liste);exit; + $lastlevel = array(); print ''."\n"; foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { @@ -157,9 +160,17 @@ class MenuManager $relurl=dol_buildpath($val['url'],1); $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); $relurl=preg_replace('/__USERID__/',$user->id,$relurl); + $canonurl=preg_replace('/\?.*$/','',$val['url']); - print ''.$val['titre'].''."\n"; - // Search submenu fot this entry + print ''; + + // Add font-awesome + if ($val['level'] == 0 && $val['mainmenu'] == 'home') print ''; + + print $val['titre']; + print ''."\n"; + + // Search submenu fot this mainmenu entry $tmpmainmenu=$val['mainmenu']; $tmpleftmenu='all'; $submenu=new Menu(); @@ -177,21 +188,50 @@ class MenuManager // We add sub entry print str_pad('',1).'
  • '; // ui-btn to highlight on clic print ''; - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation { - if ($val['mainmenu'] == 'cashdesk') print $langs->trans("Access"); - else print $langs->trans("Dashboard"); + if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); + else print $langs->trans("Dashboard"); } else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); print ''; print '
  • '."\n"; } - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + + if ($val['level']==0) + { + if ($val['enabled']) + { + $lastlevel[0]='enabled'; + } + else if ($showmenu) // Not enabled but visible (so greyed) + { + $lastlevel[0]='greyed'; + } + else + { + $lastlevel[0]='hidden'; + } + } + + $lastlevel2 = array(); + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { $showmenu=true; if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) + // If at least one parent is not enabled, we do not show any menu of all children + if ($val2['level'] > 0) + { + $levelcursor = $val2['level']-1; + while ($levelcursor >= 0) + { + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; + $levelcursor--; + } + } + + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) { $relurl2=dol_buildpath($val2['url'],1); $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); @@ -199,8 +239,17 @@ class MenuManager $canonurl2=preg_replace('/\?.*$/','',$val2['url']); //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; - if ($val2['level']==0) print str_pad('',$val2['level']+1).'
  • '; // ui-btn to highlight on clic - else print str_pad('',$val2['level']+1).'
  • '; // ui-btn to highlight on clic + + $disabled=''; + if (! $val2['enabled']) + { + $disabled=" vsmenudisabled"; + } + + print str_pad('',$val2['level']+1); + print '
  • '; // ui-btn to highlight on clic if ($relurl2) { if ($val2['enabled']) // Allowed @@ -208,12 +257,25 @@ class MenuManager print ''; + $lastlevel2[$val2['level']]='enabled'; } else // Not allowed but visible (greyed) { print ''; + $lastlevel2[$val2['level']]='greyed'; } } + else + { + if ($val2['enabled']) // Allowed + { + $lastlevel2[$val2['level']]='enabled'; + } + else + { + $lastlevel2[$val2['level']]='greyed'; + } + } print $val2['titre']; if ($relurl2) { diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index b0b7f95c27b..d8f90cb912f 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -113,7 +113,7 @@ class MenuManager /** * Show menu * - * @param string $mode 'top', 'topnb', 'left', 'jmobile' + * @param string $mode 'top', 'topnb', 'left', 'jmobile' (used to get full xml ul/li menu) * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ @@ -125,7 +125,7 @@ class MenuManager if ($this->type_user == 1) { - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=0; + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; } @@ -150,12 +150,13 @@ class MenuManager return $this->menu->getNbOfVisibleMenuEntries(); } - if ($mode == 'jmobile') + if ($mode == 'jmobile') // Used to get menu in xml ul/li { print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu // $this->menu->liste is top menu //var_dump($this->menu->liste);exit; + $lastlevel = array(); print ''."\n"; foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { @@ -167,7 +168,7 @@ class MenuManager $relurl=dol_buildpath($val['url'],1); $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); $relurl=preg_replace('/__USERID__/',$user->id,$relurl); - + $canonurl=preg_replace('/\?.*$/','',$val['url']); print ''; @@ -176,6 +177,7 @@ class MenuManager print $val['titre']; print ''."\n"; + // Search submenu fot this mainmenu entry $tmpmainmenu=$val['mainmenu']; $tmpleftmenu='all'; @@ -195,9 +197,7 @@ class MenuManager { // We add sub entry print str_pad('',1).'
  • '; // ui-btn to highlight on clic - print ''; + print ''; if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation { if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access"); @@ -208,11 +208,39 @@ class MenuManager print '
  • '."\n"; } - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'] + if ($val['level']==0) + { + if ($val['enabled']) + { + $lastlevel[0]='enabled'; + } + else if ($showmenu) // Not enabled but visible (so greyed) + { + $lastlevel[0]='greyed'; + } + else + { + $lastlevel[0]='hidden'; + } + } + + $lastlevel2 = array(); + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { $showmenu=true; if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; + // If at least one parent is not enabled, we do not show any menu of all children + if ($val2['level'] > 0) + { + $levelcursor = $val2['level']-1; + while ($levelcursor >= 0) + { + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; + $levelcursor--; + } + } + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) { $relurl2=dol_buildpath($val2['url'],1); @@ -221,8 +249,17 @@ class MenuManager $canonurl2=preg_replace('/\?.*$/','',$val2['url']); //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; - if ($val2['level']==0) print str_pad('',$val2['level']+1).'
  • '; // ui-btn to highlight on clic - else print str_pad('',$val2['level']+1).'
  • '; // ui-btn to highlight on clic + + $disabled=''; + if (! $val2['enabled']) + { + $disabled=" vsmenudisabled"; + } + + print str_pad('',$val2['level']+1); + print '
  • '; // ui-btn to highlight on clic if ($relurl2) { if ($val2['enabled']) // Allowed @@ -230,13 +267,28 @@ class MenuManager print ''; + $lastlevel2[$val2['level']]='enabled'; } else // Not allowed but visible (greyed) { print ''; + $lastlevel2[$val2['level']]='greyed'; } } - print $val2['titre']; + else + { + if ($val2['enabled']) // Allowed + { + $lastlevel2[$val2['level']]='enabled'; + } + else + { + $lastlevel2[$val2['level']]='greyed'; + } + } + //var_dump($val2['level']); + //var_dump($lastlevel2); + print $val2['titre']; if ($relurl2) { if ($val2['enabled']) // Allowed @@ -246,6 +298,8 @@ class MenuManager } print '
  • '."\n"; } + + } //var_dump($submenu); print ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index bee5aac9d36..8e0a9b856ea 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1790,6 +1790,7 @@ a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font.vsmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; } a.vsmenu:link, a.vsmenu:visited { color: #; white-space: nowrap; } font.vsmenudisabledmargin { margin: 1px 1px 1px 6px; } +li a.vsmenudisabled, li.vsmenudisabled { color: #aaa !important; } a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; text-decoration: none; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9ec18cca050..e98c631c758 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1678,7 +1678,7 @@ div.login_block { vertical-align: middle; background: #FFF; width: 228px; - height: 42px; + height: 43px; display: none; From b62da4bb7aa669409f84aadfea3eb2116b99e5f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 20:04:24 +0200 Subject: [PATCH 056/342] Fix a parameter is required to know what we share. --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/adherents/index.php | 16 ++++++++-------- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 8 ++++---- htdocs/adherents/type.php | 4 ++-- htdocs/core/lib/functions.lib.php | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 18e144c363c..65f9de24496 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1097,7 +1097,7 @@ class Adherent extends CommonObject $sql.= " WHERE d.fk_adherent_type = t.rowid"; if ($rowid) $sql.= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql.= " AND d.entity IN (".getEntity().")"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'"; elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc; } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 76368fc5673..2614a27d509 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -64,8 +64,8 @@ $sql.= " d.statut, count(d.rowid) as somme"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; -$sql.= " AND d.entity IN (".getEntity().")"; -$sql.= " WHERE t.entity IN (".getEntity().")"; +$sql.= " AND d.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); @@ -100,7 +100,7 @@ $now=dol_now(); // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) $sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " WHERE d.entity IN (".getEntity().")"; +$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; //$sql.= " AND d.statut = 1 AND ((t.subscription = 0 AND d.datefin IS NULL) OR d.datefin >= '".$db->idate($now)."')"; $sql.= " AND d.statut = 1 AND d.datefin >= '".$db->idate($now)."'"; $sql.= " AND t.rowid = d.fk_adherent_type"; @@ -133,7 +133,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_member']=array('text'=>'Member'); } - + if (count($listofsearchfields)) { print ''; @@ -149,7 +149,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '
    '; + print ''; print ''; print '
    '; } @@ -211,7 +211,7 @@ $numb=0; $sql = "SELECT c.subscription, c.dateadh as dateh"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE d.entity IN (".getEntity().")"; +$sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $sql.= " AND d.rowid = c.fk_adherent"; if(isset($date_select) && $date_select != '') { @@ -275,7 +275,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, $sql.= " a.tms as datem, datefin as date_end_subscription,"; $sql.= " ta.rowid as typeid, ta.libelle, ta.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; -$sql.= " WHERE a.entity IN (".getEntity().")"; +$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; $sql.= " AND a.fk_adherent_type = ta.rowid"; $sql.= $db->order("a.tms","DESC"); $sql.= $db->plimit($max, 0); @@ -336,7 +336,7 @@ $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, $sql.= " datefin as date_end_subscription,"; $sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE a.entity IN (".getEntity().")"; +$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; $sql.= " AND c.fk_adherent = a.rowid"; $sql.= $db->order("c.tms","DESC"); $sql.= $db->plimit($max, 0); diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 6f896e186bb..f067b27b3d4 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -67,7 +67,7 @@ $tab='byproperties'; $data = array(); $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; -$sql.=" WHERE d.entity IN (".getEntity().")"; +$sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY d.morphy"; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 8e3d0862490..1f9ff189068 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -79,7 +79,7 @@ if ($mode) $data = array(); $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code"; //print $sql; @@ -96,7 +96,7 @@ if ($mode) $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, c.nom"; //print $sql; @@ -112,7 +112,7 @@ if ($mode) $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, r.nom"; //+ //print $sql; @@ -127,7 +127,7 @@ if ($mode) $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql.=" WHERE d.entity IN (".getEntity().")"; + $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code, d.town"; //print $sql; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f0be2ee9fae..50c464596fd 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -173,7 +173,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity().")"; + $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; $result = $db->query($sql); if ($result) @@ -380,7 +380,7 @@ if ($rowid > 0) $sql.= " t.libelle as type, t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; - $sql.= " AND d.entity IN (".getEntity().")"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; $sql.= " AND t.rowid = ".$object->id; if ($sall) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3157348062a..8a9bd1e88b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -113,7 +113,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only * @return mixed Entity id(s) to use */ -function getEntity($element=false, $shared=1) +function getEntity($element, $shared=1) { global $conf, $mc; From d037515e37938161982583d866c598fc03061c9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 May 2017 09:57:05 +0200 Subject: [PATCH 057/342] FIX SQL injection on user/index.php parameter search_statut. Conflicts: htdocs/user/index.php --- htdocs/core/lib/functions.lib.php | 3 ++ htdocs/user/index.php | 58 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3ced09db552..a212b82c18f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -250,6 +250,9 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) case 'int': if (! is_numeric($out)) { $out=''; } break; + case 'intcomma': + if (preg_match('/[^0-9,]+/i',$out)) $out=''; + break; case 'alpha': $out=trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 5d8f02e1c32..669152cb145 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -100,7 +100,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } @@ -116,9 +116,9 @@ $search_gender=GETPOST('search_gender','alpha'); $search_employee=GETPOST('search_employee','alpha'); $search_accountancy_code=GETPOST('search_accountancy_code','alpha'); $search_email=GETPOST('search_email','alpha'); -$search_statut=GETPOST('search_statut','alpha'); +$search_statut=GETPOST('search_statut','intcomma'); $search_thirdparty=GETPOST('search_thirdparty','alpha'); -$search_supervisor=GETPOST('search_supervisor','alpha'); +$search_supervisor=GETPOST('search_supervisor','intcomma'); $search_previousconn=GETPOST('search_previousconn','alpha'); $optioncss = GETPOST('optioncss','alpha'); @@ -131,7 +131,7 @@ if ($mode == 'employee') $search_employee=1; /* * Actions */ - + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -196,8 +196,8 @@ else } if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); -if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$search_supervisor; -if ($search_thirdparty != '') $sql.=natural_search(array('s.nom'), $search_thirdparty); +if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$db->escape($search_supervisor); +if ($search_thirdparty != '') $sql.= natural_search(array('s.nom'), $search_thirdparty); if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); @@ -206,9 +206,9 @@ if (is_numeric($search_employee) && $search_employee >= 0) { $sql .= ' AND u.employee = '.(int) $search_employee; } if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); -if ($search_email != '') $sql.= natural_search("u.email", $search_email); -if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_email != '') $sql.= natural_search("u.email", $search_email); +if ($search_statut != '' && $search_statut >= 0) $sql.= " AND u.statut IN (".$db->escape($search_statut).")"; +if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields foreach ($search_array_options as $key => $val) { @@ -217,7 +217,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -265,27 +265,27 @@ if ($result) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - + } + + print '
    '."\n"; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $moreforfilter=''; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print ''; print ''; if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); @@ -303,9 +303,9 @@ if ($result) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -340,7 +340,7 @@ if ($result) { print ''; } if (! empty($arrayfields['u.employee']['checked'])) @@ -380,9 +380,9 @@ if ($result) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; @@ -428,7 +428,7 @@ if ($result) $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print ''; - + print "\n"; $user2=new User($db); @@ -451,7 +451,7 @@ if ($result) $userstatic->lastname=$obj->lastname; $userstatic->employee=$obj->employee; $userstatic->photo=$obj->photo; - + $li=$userstatic->getNomUrl(-1,'',0,0,24,1,'login'); print ""; @@ -564,8 +564,8 @@ if ($result) } } print ''; - } - + } + // Date last login if (! empty($arrayfields['u.datelastlogin']['checked'])) { @@ -576,13 +576,13 @@ if ($result) { print ''; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); From 9c482b9f2a021604e29b7321e2e18eed60d08932 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 21:37:27 +0200 Subject: [PATCH 058/342] FIX CVE-2017-7886 --- htdocs/core/datepicker.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/lib/functions.lib.php | 106 +++++++++++++++--------------- htdocs/core/search_page.php | 8 +-- htdocs/externalsite/frames.php | 2 +- htdocs/install/inc.php | 6 +- htdocs/main.inc.php | 4 +- htdocs/master.inc.php | 2 +- htdocs/support/inc.php | 2 +- htdocs/theme/eldy/style.css.php | 12 ++-- htdocs/theme/md/style.css.php | 52 +++++++-------- 11 files changed, 99 insertions(+), 99 deletions(-) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 63b765fbadb..99bf9b15a80 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -39,7 +39,7 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); require_once '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang')); // If language was forced on URL by the main.inc.php +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php $langs->load("main"); $langs->load("agenda"); $right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 655e10afd67..f8b3a652e08 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -35,7 +35,7 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); require_once '../main.inc.php'; -if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang')); // If language was forced on URL by the main.inc.php +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php $langs->load("main"); $right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); $left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a212b82c18f..c4674fbe5a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -191,7 +191,7 @@ function getBrowserInfo($user_agent) elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } - + if ($tablet) { $layout = 'tablet'; } elseif ($phone) { @@ -269,7 +269,7 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) break; case 'aZ09': $out=trim($out); - if (preg_match('/[^a-z0-9]+/i',$out)) $out=''; + if (preg_match('/[^a-z0-9_\-]+/i',$out)) $out=''; break; case 'array': if (! is_array($out) || empty($out)) $out=array(); @@ -290,13 +290,13 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) * This prefix is unique for instance and avoid conflict between multi-instances, * even when having two instances with one root dir or two instances in virtual servers * - * @param string $mode '' or 'email' + * @param string $mode '' or 'email' * @return string A calculated prefix */ function dol_getprefix($mode='') { global $conf; - + // If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { @@ -378,15 +378,15 @@ function dol_buildpath($path, $type=0) if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value if ($type == 3) $res = DOL_URL_ROOT.'/'.$path; - + foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) { - if ($key == 'main') + if ($key == 'main') { if ($type == 3) { global $dolibarr_main_url_root; - + // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -413,12 +413,12 @@ function dol_buildpath($path, $type=0) if ($type == 3) { global $dolibarr_main_url_root; - + // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - + $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax } break; @@ -957,7 +957,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); if ($conf->browser->phone) $maxvisiblephotos=1; if ($showimage) $morehtmlleft.='
    '.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
    '; - else + else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { $nophoto=''; @@ -967,17 +967,17 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $nophoto='/public/theme/common/nophoto.png'; $morehtmlleft.='
    No photo
    '; } - + } } - else + else { if ($showimage) $morehtmlleft.='
    '.$form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos).'
    '; } if ($showbarcode) $morehtmlleft.='
    '.$form->showbarcode($object).'
    '; if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); - } + } elseif ($object->element == 'product') { //$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; @@ -999,7 +999,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r } if (! empty($object->name_alias)) $morehtmlref.='
    '.$object->name_alias.'
    '; // For thirdparty if (! empty($object->label)) $morehtmlref.='
    '.$object->label.'
    '; // For product - if ($object->element != 'product') + if ($object->element != 'product') { $morehtmlref.='
    '; $morehtmlref.=$object->getBannerAddress('refaddress',$object); @@ -1184,9 +1184,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0; $formatwithoutreduce = preg_replace('/reduceformat/','',$format); if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day - + // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. - // TODO Add format daysmallyear and dayhoursmallyear + // TODO Add format daysmallyear and dayhoursmallyear if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); @@ -1957,7 +1957,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', print '
    '.$langs->trans("NotEnoughDataYet").'
    '; return; } - + if (empty($conf->use_javascript_ajax)) return; $jsgraphlib='flot'; $datacolor=array(); @@ -2126,7 +2126,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo global $conf; if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - + if (empty($stringencoding)) $stringencoding='UTF-8'; // reduce for small screen if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); @@ -3076,7 +3076,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois * @param string $options parametres complementaires lien ('' par defaut) * @param string $sortfield champ de tri ('' par defaut) * @param string $sortorder ordre de tri ('' par defaut) - * @param string $center chaine du centre ('' par defaut). We often find here string $massaction comming from $form->selectMassAction() + * @param string $center chaine du centre ('' par defaut). We often find here string $massaction comming from $form->selectMassAction() * @param int $num number of records found by select with limit+1 * @param int $totalnboflines Total number of records/lines for all pages (if known). Use a negative value to no show number. * @param string $picto Icon to use before title (should be a 32x32 transparent png file) @@ -3090,11 +3090,11 @@ function load_fiche_titre($titre, $mesg='', $picto='title_generic.png', $pictois function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) { global $conf,$langs; - + $savlimit = $limit; $savtotalnboflines = $totalnboflines; $totalnboflines=abs($totalnboflines); - + if ($picto == 'setup') $picto='title_setup.png'; if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; if ($limit < 0) $limit = $conf->liste_limit; @@ -3107,7 +3107,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $nextpage = 0; } //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage; - + print "\n"; print "\n"; print '
    '; $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print '
    '.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").'
    '; @@ -3206,7 +3206,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported //$pagesizechoices.=',2:2'; if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES; - + print '
    '; // Check parameter main_dir @@ -552,7 +552,7 @@ if (! $error && $db->connected && $action == "set") if ($db->connected) { $resultbis = 1; - + // Create user $result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); // Create user bis @@ -563,7 +563,7 @@ if (! $error && $db->connected && $action == "set") $resultbis=$db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); } } - + if ($result > 0 && $resultbis > 0) { diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index baceee5f7eb..ae5adc4e471 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -86,7 +86,7 @@ if (! is_writable($conffile)) if ($action == "set") { - print '

    '.$langs->trans("Database").'

    '; + print '

    Database '.$langs->trans("Database").'

    '; print '
    '; $error=0; diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 875fd9378f2..b4bf7987547 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -174,13 +174,13 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) { $numrows=$db->num_rows($resql); if ($numrows == 0) dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1",'chaine',0,'',$conf->entity); - } - + } + // Create user used to create the admin user $createuser=new User($db); $createuser->id=0; $createuser->admin=1; - + // Set admin user $newuser = new User($db); $newuser->lastname='SuperAdmin'; @@ -216,10 +216,15 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) { $db->begin(); + dolibarr_install_syslog('step5: set MAIN_VERSION_FIRST_INSTALL const to ' . $targetversion, LOG_DEBUG); + $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_FIRST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when first install',0)"); + //if (! $resql) dol_print_error($db,'Error in setup program'); // We ignore errors. Key may already exists + $conf->global->MAIN_VERSION_FIRST_INSTALL=$targetversion; + dolibarr_install_syslog('step5: set MAIN_VERSION_LAST_INSTALL const to ' . $targetversion, LOG_DEBUG); $resql=$db->query("DELETE FROM ".MAIN_DB_PREFIX."const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'"); if (! $resql) dol_print_error($db,'Error in setup program'); - $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when install',0)"); + $resql=$db->query("INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when last install',0)"); if (! $resql) dol_print_error($db,'Error in setup program'); $conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion; From acfaec684d71bcd85635ce8efecc43d8afd9b5b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 22:31:22 +0200 Subject: [PATCH 060/342] FIX CVE-2017-7888 --- htdocs/core/login/functions_dolibarr.php | 3 ++- htdocs/install/step5.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 190d779d90b..d8cf78747b8 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -60,7 +60,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= $sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; $sql.=' AND statut = 1'; // Required to first found the user into entity, then the superadmin. - // For the case (TODO and that we must avoid) a user has renamed its login with same value than a user in entity 0. + // For the case (TODO and that we must avoid) a user has renamed its login with same value than a user in entity 0. $sql.=' ORDER BY entity DESC'; $resql=$db->query($sql); @@ -78,6 +78,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= // Check crypted password $cryptType=''; if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED; + // By default, we used MD5 if (! in_array($cryptType,array('md5'))) $cryptType='md5'; // Check crypted password according to crypt algorithm diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index b4bf7987547..78d29584a30 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -162,18 +162,23 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) { $conf->setValues($db); - // Create user + // Create admin user include_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; - // Set default encryption to yes if there is no user yet into database + // Set default encryption to yes, generate a salt and set default encryption algorythm (but only if there is no user yet into database) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - //$sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value $resql=$db->query($sql); if ($resql) { $numrows=$db->num_rows($resql); - if ($numrows == 0) dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1",'chaine',0,'',$conf->entity); + if ($numrows == 0) + { + // Define default setup for password encryption + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + } } // Create user used to create the admin user From 4683ef41be54012bfd3d06ea2fc59b3be97d89a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 22:49:16 +0200 Subject: [PATCH 061/342] Fix hide search label on computed field into lists --- htdocs/core/class/extrafields.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 754a8300366..4b5f151ec72 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -759,7 +759,11 @@ class ExtraFields $list=$this->attribute_list[$key]; $hidden=$this->attribute_hidden[$key]; - if ($computed) return ''.$langs->trans("AutomaticallyCalculated").''; + if ($computed) + { + if ($keysuffix != 'search_') return ''.$langs->trans("AutomaticallyCalculated").''; + else return ''; + } if (empty($showsize)) { From a74d008ff25d497f7a68a8c8356e5ccfb94bcbf4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 22:57:25 +0200 Subject: [PATCH 062/342] Fix missing translation --- htdocs/holiday/class/holiday.class.php | 34 ++++++++++++++------------ htdocs/holiday/view_log.php | 30 +++++++++++------------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e6a3d3d2f0e..15a565b04f9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -37,7 +37,7 @@ class Holiday extends CommonObject protected $isnolinkedbythird = 1; // No field fk_soc protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'holiday'; - + /** * @deprecated * @see id @@ -128,7 +128,7 @@ class Holiday extends CommonObject if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameter"; return -1; } if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameter"; return -1; } if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameter"; return -1; } - + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; $sql.= "fk_user,"; @@ -290,7 +290,7 @@ class Holiday extends CommonObject $sql = "SELECT"; $sql.= " cp.rowid,"; - + $sql.= " cp.fk_user,"; $sql.= " cp.date_create,"; $sql.= " cp.description,"; @@ -312,13 +312,13 @@ class Holiday extends CommonObject $sql.= " uu.login as user_login,"; $sql.= " uu.statut as user_statut,"; $sql.= " uu.photo as user_photo,"; - + $sql.= " ua.lastname as validator_lastname,"; $sql.= " ua.firstname as validator_firstname,"; $sql.= " ua.login as validator_login,"; $sql.= " ua.statut as validator_statut,"; $sql.= " ua.photo as validator_photo"; - + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -379,13 +379,13 @@ class Holiday extends CommonObject $tab_result[$i]['user_login'] = $obj->user_login; $tab_result[$i]['user_statut'] = $obj->user_statut; $tab_result[$i]['user_photo'] = $obj->user_photo; - + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; $tab_result[$i]['validator_login'] = $obj->validator_login; $tab_result[$i]['validator_statut'] = $obj->validator_statut; $tab_result[$i]['validator_photo'] = $obj->validator_photo; - + $i++; } @@ -437,13 +437,13 @@ class Holiday extends CommonObject $sql.= " uu.login as user_login,"; $sql.= " uu.statut as user_statut,"; $sql.= " uu.photo as user_photo,"; - + $sql.= " ua.lastname as validator_lastname,"; $sql.= " ua.firstname as validator_firstname,"; $sql.= " ua.login as validator_login,"; $sql.= " ua.statut as validator_statut,"; $sql.= " ua.photo as validator_photo"; - + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -504,13 +504,13 @@ class Holiday extends CommonObject $tab_result[$i]['user_login'] = $obj->user_login; $tab_result[$i]['user_statut'] = $obj->user_statut; $tab_result[$i]['user_photo'] = $obj->user_photo; - + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; $tab_result[$i]['validator_login'] = $obj->validator_login; $tab_result[$i]['validator_statut'] = $obj->validator_statut; $tab_result[$i]['validator_photo'] = $obj->validator_photo; - + $i++; } // Retourne 1 et ajoute le tableau à la variable @@ -817,7 +817,7 @@ class Holiday extends CommonObject if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5'); if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5'); } - + return $statut; } @@ -905,11 +905,11 @@ class Holiday extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)"; $sql.= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; $result = $this->db->query($sql); - if ($result) + if ($result) { return $createifnotfound; } - else + else { $this->error=$this->db->lasterror(); return -2; @@ -920,7 +920,7 @@ class Holiday extends CommonObject return ''; } } - else + else { return $obj->value; } @@ -948,12 +948,14 @@ class Holiday extends CommonObject if (empty($userID) && empty($nbHoliday) && empty($fk_type)) { + $langs->load("holiday"); + // Si mise à jour pour tout le monde en début de mois $now=dol_now(); $month = date('m',$now); $newdateforlastupdate = dol_print_date($now, '%Y%m%d%H%M%S'); - + // Get month of last update $lastUpdate = $this->getConfCP('lastUpdate', $newdateforlastupdate); $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 7fcf6a48a97..17b374e5f4a 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -57,7 +57,8 @@ llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year. // Recent changes are more important than old changes $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year,1,1))."' AND '".$db->idate(dol_get_last_day($year,12,1))."'"); // Load $cp->logs -print load_fiche_titre($langs->trans('LogCP'), '', 'title_hrm.png'); +$pagination=''; +print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png'); print '
    '.$langs->trans('LastUpdateCP').': '."\n"; $lastUpdate = $cp->getConfCP('lastUpdate'); @@ -77,6 +78,18 @@ print '
    '; print '
    '."\n"; print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + print ''; print_liste_field_titre($langs->trans('ID')); print_liste_field_titre($langs->trans('Date'), $_SERVER["PHP_SELF"], '', '', '', 'align="center"'); @@ -88,24 +101,9 @@ print_liste_field_titre($langs->trans('PrevSoldeCP'), $_SERVER["PHP_SELF"], '', print_liste_field_titre($langs->trans('NewSoldeCP'), $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - -$var=true; foreach($cp->logs as $logs_CP) { - - $user_action = new User($db); $user_action->fetch($logs_CP['fk_user_action']); From 542a72c684c989137788efba087edc8698e61bbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 23:50:02 +0200 Subject: [PATCH 063/342] NEW custom dir is enabled dy default on first install. Fix modulebuilder when custom dir not defined. --- htdocs/admin/modules.php | 70 +++++++------- htdocs/install/step1.php | 10 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/modulebuilder/README.md | 16 +--- htdocs/modulebuilder/index.php | 168 ++++++++++++++++++++------------- 5 files changed, 150 insertions(+), 116 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index fe735cb2499..57ed97c9b20 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -278,7 +278,7 @@ foreach ($modulesdir as $dir) try { - $res=include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. + $res=include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error. if (class_exists($modName)) { try { @@ -352,7 +352,7 @@ foreach ($modulesdir as $dir) { $arrayofwarningsext[$modName]=$objMod->warnings_activation_ext; } - + $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
    '; @@ -436,7 +436,7 @@ if ($mode == 'common') print ''; print ''; print ''; - + dol_fiche_head($head, $mode, '', -1); $moreforfilter = ''; @@ -473,12 +473,12 @@ if ($mode == 'common') $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; } - - + + print '

    '; $moreforfilter=''; - + // Show list of modules $oldfamily=''; @@ -564,13 +564,13 @@ if ($mode == 'common') if ($familykey!=$oldfamily) { if ($oldfamily) print '

    '; - + $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label']; print_fiche_titre($familytext, '', ''); - + print '
    '; print ''."\n"; - + $atleastoneforfamily=0; } @@ -582,9 +582,9 @@ if ($mode == 'common') $oldfamily=$familykey; } - - + + // Version (with picto warning or not) $version=$objMod->getVersion(0); $versiontrans=''; @@ -592,14 +592,14 @@ if ($mode == 'common') if (preg_match('/experimental/i', $version)) $versiontrans.=img_warning($langs->trans("Experimental"), 'style="float: left"'); if (preg_match('/deprecated/i', $version)) $versiontrans.=img_warning($langs->trans("Deprecated"), 'style="float: left"'); $versiontrans.=$objMod->getVersion(1); - + // Define imginfo $imginfo="info"; if ($objMod->isCoreOrExternalModule() == 'external') { $imginfo="info_black"; } - + print ''."\n"; // Picto + Name of module @@ -756,32 +756,32 @@ if ($mode == 'common') print "\n"; } print "\n"; - + // Link config print ''; } print "\n"; } - + if ($oldfamily) { print "
    '.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'
    \n"; print '
    '; } - + dol_fiche_end(); - + // Show warning about external users print info_admin(showModulesExludedForExternal($modules))."\n"; - + print ''; } if ($mode == 'marketplace') { dol_fiche_head($head, $mode, '', -1); - + // Marketplace print "\n"; print "\n"; @@ -790,7 +790,7 @@ if ($mode == 'marketplace') print ''; print ''; - + print "\n"; $url='https://www.dolistore.com'; print ''; @@ -798,7 +798,7 @@ if ($mode == 'marketplace') print ''; print ''; - + print "\n"; $url='https://partners.dolibarr.org'; print ''; @@ -813,23 +813,23 @@ if ($mode == 'marketplace') // Install external module - + if ($mode == 'deploy') { dol_fiche_head($head, $mode, '', -1); - + $allowonlineinstall=true; $allowfromweb=1; if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false; - + $fullurl=''.$urldolibarrmodules.''; $message=''; if (! empty($allowonlineinstall)) { if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt))) { - $message=info_admin($langs->trans("ConfFileMuseContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); $allowfromweb=-1; } else @@ -845,7 +845,7 @@ if ($mode == 'deploy') } else { - + $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); $allowfromweb=0; } @@ -856,7 +856,7 @@ if ($mode == 'deploy') $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock')); $allowfromweb=0; } - + if ($allowfromweb < 1) { print $langs->trans("SomethingMakeInstallFromWebNotPossible"); @@ -864,15 +864,15 @@ if ($mode == 'deploy') //print $langs->trans("SomethingMakeInstallFromWebNotPossible2"); print '
    '; } - - + + if ($allowfromweb >= 0) { - if ($allowfromweb == 1) + if ($allowfromweb == 1) { //print $langs->trans("ThisIsProcessToFollow").'
    '; } - else + else { print $langs->trans("ThisIsAlternativeProcessToFollow").'
    '; print ''.$langs->trans("StepNb",1).': '; @@ -881,7 +881,7 @@ if ($mode == 'deploy') print $langs->trans("DownloadPackageFromWebSite",$fullurl).'
    '; print ''.$langs->trans("StepNb",3).': '; } - + if ($allowfromweb == 1) { print $langs->trans("UnpackPackageInModulesRoot",$dirins).'
    '; @@ -899,12 +899,12 @@ if ($mode == 'deploy') print $langs->trans("SetupIsReadyForUse").'
    '; } } - - + + if (! empty($result['return'])) { print '
    '; - + foreach($result['return'] as $value) { echo $value.'
    '; diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index a57ffd0c674..631ac79752f 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -57,14 +57,14 @@ $db_user=GETPOST('db_user','alpha'); $db_pass=GETPOST('db_pass'); $db_port=GETPOST('db_port','int'); $db_prefix=GETPOST('db_prefix','alpha'); -$db_create_database = GETPOST('db_create_database'); -$db_create_user = GETPOST('db_create_user'); +$db_create_database = GETPOST('db_create_database','none'); +$db_create_user = GETPOST('db_create_user','none'); // Force https -$main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1)) ? '1' : '0'); +$main_force_https = ((GETPOST("main_force_https",'alpha') && (GETPOST("main_force_https",'alpha') == "on" || GETPOST("main_force_https",'alpha') == 1)) ? '1' : '0'); // Use alternative directory -$main_use_alt_dir = ((GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1)) ? '' : '//'); +$main_use_alt_dir = ((GETPOST("main_use_alt_dir",'alpha') == '' || (GETPOST("main_use_alt_dir",'alpha') == "on" || GETPOST("main_use_alt_dir",'alpha') == 1)) ? '' : '//'); // Alternative root directory name -$main_alt_dir_name = ((GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '') ? GETPOST("main_alt_dir_name") : 'custom'); +$main_alt_dir_name = ((GETPOST("main_alt_dir_name",'alpha') && GETPOST("main_alt_dir_name",'alpha') != '') ? GETPOST("main_alt_dir_name",'alpha') : 'custom'); session_start(); // To be able to keep info into session (used for not losing password during navigation. The password must not transit through parameters) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 421b3fae132..695373e22b5 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1619,7 +1619,7 @@ BackupDumpWizard=Wizard to build database backup dump file SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason: SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is only manual steps a privileged user can do. InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file %s to allow this feature. -ConfFileMuseContainCustom=Installing an external module from application need to save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to add the 2 directive lines:
    $dolibarr_main_url_root_alt='/custom';
    $dolibarr_main_document_root_alt='%s/custom'; +ConfFileMustContainCustom=Installing or building an external module from application need to save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to add the 2 directive lines:
    $dolibarr_main_url_root_alt='/custom';
    $dolibarr_main_document_root_alt='%s/custom'; HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (keep empty for no highlight) TextTitleColor=Color of page title diff --git a/htdocs/modulebuilder/README.md b/htdocs/modulebuilder/README.md index 5e2af06a430..548e87b7912 100644 --- a/htdocs/modulebuilder/README.md +++ b/htdocs/modulebuilder/README.md @@ -9,26 +9,26 @@ If you're not a module developer you have no use for this. Documentation ------------- -[Module tutorial](http://wiki.dolibarr.org/index.php/Module_development) +[Module tutorial](https://wiki.dolibarr.org/index.php/Module_development) -[Dolibarr development](http://wiki.dolibarr.org/index.php/Developer_documentation) +[Dolibarr development](https://wiki.dolibarr.org/index.php/Developer_documentation) ### Translations -Dolibarr uses [Transifex](http://transifex.com) to manage it's translations. +Dolibarr uses [Transifex](https://transifex.com) to manage it's translations. This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory. For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation). -There is a [Transifex project](http://transifex.com/projects/p/dolibarr-module-template) for this module. +There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module. Install ------- ### Manually -- Make sure Dolibarr (>= 3.3.x) is already installed and configured on your workstation or development server. +- Make sure Dolibarr is already installed and configured on your workstation or development server. - In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file @@ -60,8 +60,6 @@ Install For more information about the ```conf.php``` file take a look at the conf.php.example file. -*Note that for Dolibarr versions before 3.5, the ```$dolibarr_main_url_root_alt``` has to be an absolute path* - - Clone the repository in ```$dolibarr_main_document_root_alt/mymodule``` *(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)* @@ -187,10 +185,6 @@ The de-facto standard for publishing and marketing modules for Dolibarr is the [ Templates for required images and texts are [provided](dev/dolistore). Check the dedicated [README](dev/dolistore/README.md) for more informations. -Contributions -------------- - -Feel free to contribute and report defects on our [issue tracker](http://github.com/Dolibarr/dolibarr-module-template/issues). Licenses -------- diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b3b2c8dac77..17599e922aa 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -45,7 +45,7 @@ if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessfor // Dir for custom dirs $tmp=explode(',', $dolibarr_main_document_root_alt); -$dircustom = $tmp[0]; +$dirins = $tmp[0]; $FILEFLAG='modulebuilder.txt'; @@ -54,16 +54,16 @@ $FILEFLAG='modulebuilder.txt'; * Actions */ -if ($dircustom && $action == 'initmodule' && $modulename) +if ($dirins && $action == 'initmodule' && $modulename) { $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dircustom.'/'.strtolower($modulename); + $destdir = $dirins.'/'.strtolower($modulename); $arrayreplacement=array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename ); - + $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); //dol_mkdir($destfile); if ($result <= 0) @@ -94,17 +94,17 @@ if ($dircustom && $action == 'initmodule' && $modulename) 'My module'=>$modulename, 'htdocs/modulebuilder/template/'=>'', ); - - + + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); if ($result < 0) { setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); } - } + } } - + if (! $error) { setEventMessages('ModuleInitialized', null); @@ -113,15 +113,15 @@ if ($dircustom && $action == 'initmodule' && $modulename) } } -if ($dircustom && $action == 'generatepackage') +if ($dirins && $action == 'generatepackage') { $modulelowercase=strtolower($module); - + // Dir for module - $dir = $dircustom.'/'.$modulelowercase; + $dir = $dirins.'/'.$modulelowercase; // Zip file to build $FILENAMEZIP=''; - + // Load module dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); $class='mod'.$module; @@ -144,13 +144,13 @@ if ($dircustom && $action == 'generatepackage') dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); exit; } - + $arrayversion=explode('.',$moduleobj->version,3); if (count($arrayversion)) { $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; - + $result = dol_compress_dir($dir, $outputfile, 'zip'); if ($result > 0) { @@ -176,6 +176,14 @@ if ($dircustom && $action == 'generatepackage') * View */ +// Set dir where external modules are installed +if (! dol_is_dir($dirins)) +{ + dol_mkdir($dirins); +} +$dirins_ok=(dol_is_dir($dirins)); + + llxHeader("",$langs->trans("ModuleBuilder"),""); @@ -193,8 +201,8 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En { foreach ($dolibarr_main_document_root_alt as $diralt) {*/ - $dirsincustom=dol_dir_list($dircustom, 'directories'); - + $dirsincustom=dol_dir_list($dirins, 'directories'); + if (is_array($dirsincustom) && count($dirsincustom) > 0) { foreach ($dirsincustom as $dircustomcursor) @@ -224,8 +232,40 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En // Show description of content +$newdircustom=$dirins; +if (empty($newdircustom)) $newdircustom=img_warning(); print $langs->trans("ModuleBuilderDesc").'
    '; -print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'
    '; +print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'
    '; + +$message=''; +if (! $dirins) +{ + $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $allowfromweb=-1; +} +else +{ + if ($dirins_ok) + { + if (! is_writable(dol_osencode($dirins))) + { + $langs->load("errors"); + $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); + $allowfromweb=0; + } + } + else + { + + $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + $allowfromweb=0; + } +} +if ($message) +{ + print $message; +} + print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
    '; //print '
    '; @@ -237,7 +277,7 @@ $moduleobj = null; if (! empty($module) && $module != 'initmodule') { $modulelowercase=strtolower($module); - + // Load module dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); $class='mod'.$module; @@ -261,7 +301,7 @@ if (! empty($module) && $module != 'initmodule') } } -print '
    '; +print '
    '; // Tabs for all modules @@ -272,7 +312,7 @@ $head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule'; $head[$h][1] = $langs->trans("NewModule"); $head[$h][2] = 'initmodule'; $h++; - + foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) { $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase; @@ -292,11 +332,11 @@ if ($module == 'initmodule') print ''; print ''; print ''; - + print $langs->trans("EnterNameOfModuleDesc").'

    '; - + print ''; - print ''; + print ''; print ''; } elseif (! empty($module)) @@ -310,53 +350,53 @@ elseif (! empty($module)) $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); if (! empty($conf->$module->enabled)) { - $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); + $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); } - + foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) { $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("Description"); $head2[$h][2] = 'description'; $h++; - + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; - $h++; - + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("Menus"); $head2[$h][2] = 'menus'; $h++; - + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("Permissions"); $head2[$h][2] = 'permissions'; - $h++; - + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("Triggers"); $head2[$h][2] = 'triggers'; - $h++; + $h++; $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$tmpmodulewithcase; $head2[$h][1] = $langs->trans("BuildPackage"); $head2[$h][2] = 'buildpackage'; - $h++; + $h++; } print $modulestatusinfo.'

    '; - + dol_fiche_head($head2, $tab, '', -1, ''); print $langs->trans("ModuleBuilderDesc".$tab).'

    '; - + if ($tab == 'description') { print '
    '; print '
    '; - + print '
    '.$langs->trans("URL").'
    '.$url.'
    '; print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print '
    '; print $langs->trans("Parameter"); @@ -369,90 +409,90 @@ elseif (! empty($module)) print ''; print $moduleobj->numero; print '
    '; print $langs->trans("Name"); print ''; print $moduleobj->getName(); print '
    '; print $langs->trans("Version"); print ''; print $moduleobj->getVersion(); print '
    '; print $langs->trans("Family"); print "
    'crm','financial','hr','projects','products','ecm','technic','interface','other'"; print '
    '; print $moduleobj->family; print '
    '; print $langs->trans("EditorName"); print ''; print $moduleobj->editor_name; print '
    '; print $langs->trans("EditorUrl"); print ''; print $moduleobj->editor_url; print '
    '; print $langs->trans("Description"); print ''; print $moduleobj->getDesc(); print '
    '; print $langs->trans("LongDescription"); print ''; print $moduleobj->getDescLong(); print '
    '; - + print '
    '; - + print '

    '; print '
    '; print ''; print ''; print ''; - print ''; + print ''; print '
    '; } - + if ($tab == 'objects') { print $langs->trans("FeatureNotYetAvailable"); - - + + } - + if ($tab == 'menus') { print $langs->trans("FeatureNotYetAvailable"); - - + + } - + if ($tab == 'permissions') { print $langs->trans("FeatureNotYetAvailable"); - + } - + if ($tab == 'triggers') { require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - + $interfaces = new Interfaces($db); $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); - + print '
    '; print ' @@ -461,11 +501,11 @@ elseif (! empty($module)) '; - + $var=True; foreach ($triggers as $trigger) { - + print ''; print ''; print ''; @@ -478,7 +518,7 @@ elseif (! empty($module)) print ''; print ''; } - + print '
     
    '.$trigger['picto'].''.$trigger['file'].'
    '; print '
    '; } @@ -490,15 +530,15 @@ elseif (! empty($module)) print img_warning().' '.$langs->trans("ErrNoZipEngine"); print '
    '; } - + print '
    '; print ''; print ''; print ''; - print ''; + print ''; print '
    '; } - + dol_fiche_end(); } } From 3f9c7db4c1ac9413bfdb1701a8efc52ccb08dc6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Jun 2017 23:56:43 +0200 Subject: [PATCH 064/342] Fix duplicate tabs --- htdocs/modulebuilder/index.php | 51 ++++++++++++++++------------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 17599e922aa..5b3a33c9d41 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -353,38 +353,35 @@ elseif (! empty($module)) $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); } - foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) - { - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("Description"); - $head2[$h][2] = 'description'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module; + $head2[$h][1] = $langs->trans("Description"); + $head2[$h][2] = 'description'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("Objects"); - $head2[$h][2] = 'objects'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module; + $head2[$h][1] = $langs->trans("Objects"); + $head2[$h][2] = 'objects'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("Menus"); - $head2[$h][2] = 'menus'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module; + $head2[$h][1] = $langs->trans("Menus"); + $head2[$h][2] = 'menus'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("Permissions"); - $head2[$h][2] = 'permissions'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module; + $head2[$h][1] = $langs->trans("Permissions"); + $head2[$h][2] = 'permissions'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("Triggers"); - $head2[$h][2] = 'triggers'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module; + $head2[$h][1] = $langs->trans("Triggers"); + $head2[$h][2] = 'triggers'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$tmpmodulewithcase; - $head2[$h][1] = $langs->trans("BuildPackage"); - $head2[$h][2] = 'buildpackage'; - $h++; - } + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module; + $head2[$h][1] = $langs->trans("BuildPackage"); + $head2[$h][2] = 'buildpackage'; + $h++; print $modulestatusinfo.'

    '; From 11d2a5538bb233bf419bdf053559c27ecfafabc4 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sun, 11 Jun 2017 00:03:01 +0200 Subject: [PATCH 065/342] fix entity default value and add link to download blockchain --- htdocs/blockedlog/admin/fingerprints.php | 18 ++++++++++++- htdocs/blockedlog/class/authority.class.php | 25 ++++++++++++++++++- htdocs/blockedlog/class/blockedlog.class.php | 2 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../install/mysql/tables/llx_blockedlog.sql | 2 +- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index bdd569d31bc..29cd2a3f73b 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); @@ -34,6 +35,21 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +if($action === 'downloadblockchain') { + + $auth = new BlockedLogAuthority($db); + + $bc = $auth->getLocalBlockChain(); + + header('Content-Type: application/octet-stream'); + header("Content-Transfer-Encoding: Binary"); + header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + + echo $bc; + + exit; +} + /* * View @@ -58,7 +74,7 @@ print $langs->trans("FingerprintsDesc")."
    \n"; print '
    '; -echo ''; +echo ''; print ''; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 8d241694b70..b422fb130d7 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -18,7 +18,7 @@ /** * Class to manage certif authority */ -class BlockedLogAuthority +class BlockedLogAuthority { /** @@ -56,6 +56,29 @@ class BlockedLogAuthority } + /** + * Get the blockchain + * + * @return string blockchain + */ + public function getLocalBlockChain() { + + $block_static = new BlockedLog($this->db); + + $this->signature = $block_static->getSignature(); + + $blocks = $block_static->getLog('all', 0, 0, 1) ; + + $this->blockchain = ''; + + foreach($blocks as &$b) { + $this->blockchain.=$b->signature; + + } + + return $this->blockchain; + } + /** * Get hash of the block chain to check * diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 26283d6b08a..1f93eb3cc26 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -19,7 +19,7 @@ * Class to manage Blocked Log */ -class BlockedLog +class BlockedLog { /** 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 f4757e2475f..0f9ef8ee3ca 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 @@ -409,7 +409,7 @@ CREATE TABLE llx_blockedlog date_object datetime, object_data text, fk_user integer, - entity integer, + entity integer DEFAULT 1, certified integer ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index 769eb34e092..afc0f0d4375 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -13,7 +13,7 @@ CREATE TABLE llx_blockedlog date_object datetime, object_data text, fk_user integer, - entity integer, + entity integer DEFAULT 1, certified integer ) ENGINE=innodb; From b19e0e3cae12cac65c5b9e06ee61e3c19796bcbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 00:31:58 +0200 Subject: [PATCH 066/342] Create card.php --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 813f23cdc88..5471b3111f7 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -218,7 +218,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fetch_thirdparty(); - $result=$object->delete($user, $id); + $result=$object->delete($user); if ($result > 0) { header('Location: list.php'); From 074c43920ad168c66931fcd08cc9b4fee1540440 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 00:35:03 +0200 Subject: [PATCH 067/342] Create projects.php --- htdocs/projet/ajax/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index ae4c412f6e3..991cae22aa3 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -61,7 +61,7 @@ $idprod = (! empty($match[0]) ? $match[0] : ''); if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; // When used from jQuery, the search term is added as GET param "term". -$searchkey=(!empty($idprod) && GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); +$searchkey=((!empty($idprod) && GETPOST($idprod))?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); $form = new FormProjets($db); $arrayresult=$form->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); From e93cefbbf01aa5ad992605123cd05ece1b17bd02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 10:37:58 +0200 Subject: [PATCH 068/342] FIX #6985 --- htdocs/adherents/card.php | 2 + htdocs/adherents/type.php | 2 + htdocs/categories/card.php | 3 +- htdocs/categories/edit.php | 1 + htdocs/comm/action/card.php | 6 +- htdocs/comm/mailing/advtargetemailing.php | 3 +- htdocs/comm/mailing/card.php | 2 + htdocs/comm/propal/card.php | 1 + htdocs/commande/card.php | 1 + htdocs/commande/orderstoinvoice.php | 1 + htdocs/compta/bank/card.php | 2 + htdocs/compta/bank/various_payment/card.php | 1 + htdocs/compta/deplacement/card.php | 2 + htdocs/compta/facture/card.php | 1 + htdocs/compta/localtax/card.php | 2 + htdocs/compta/salaries/card.php | 2 + htdocs/compta/tva/card.php | 2 + htdocs/contact/card.php | 2 + htdocs/contrat/card.php | 1 + htdocs/core/tpl/extrafields_view.tpl.php | 1 + htdocs/don/card.php | 2 + htdocs/expedition/card.php | 1 + htdocs/expensereport/card.php | 198 +++++++++--------- htdocs/fichinter/card.php | 45 ++-- htdocs/fourn/commande/card.php | 1 + htdocs/fourn/commande/orderstoinvoice.php | 1 + htdocs/fourn/facture/card.php | 1 + htdocs/product/card.php | 2 + htdocs/product/document.php | 1 + htdocs/product/fournisseurs.php | 43 ++-- htdocs/product/stats/commande.php | 15 +- htdocs/product/stats/commande_fournisseur.php | 18 +- htdocs/product/stats/contrat.php | 21 +- htdocs/product/stats/facture.php | 23 +- htdocs/product/stats/facture_fournisseur.php | 13 +- htdocs/product/stats/propal.php | 19 +- htdocs/product/stock/product.php | 17 +- htdocs/projet/card.php | 2 + htdocs/projet/tasks.php | 53 ++--- htdocs/projet/tasks/task.php | 1 + htdocs/resource/add.php | 1 + htdocs/resource/card.php | 1 + htdocs/societe/commerciaux.php | 3 +- htdocs/supplier_proposal/card.php | 1 + htdocs/user/card.php | 1 + htdocs/user/group/card.php | 2 + 46 files changed, 293 insertions(+), 231 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 147040fbf67..78969a8df14 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -943,6 +943,7 @@ else // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -1185,6 +1186,7 @@ else // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit',$parameters); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 50c464596fd..f54c89ffeba 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -278,6 +278,7 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$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'); @@ -668,6 +669,7 @@ if ($rowid > 0) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$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'); diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index ed497cbbb7f..55bf400ea3a 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -268,7 +268,8 @@ if ($user->rights->categorie->creer) $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index c2f93c17ccd..59bee88b75b 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -175,6 +175,7 @@ print ''; $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'); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1bb35fe7fe8..60486ac6f01 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -833,7 +833,8 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } @@ -1164,7 +1165,8 @@ if ($id > 0) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 832cefa5774..81c29f687ce 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -777,8 +777,9 @@ if ($object->fetch($id) >= 0) { if (! empty($advTarget->id)) { $parameters = array('array_query' => $advTarget->filtervalue); } - // Module extrafield feature + // Other attributes $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); + print $hookmanager->resPrint; } // State Contact diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 353117f5fa3..17d4d066569 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -718,6 +718,7 @@ if ($action == 'create') // 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'); @@ -1153,6 +1154,7 @@ else // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d58f2223adb..3e8580d5350 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1527,6 +1527,7 @@ if ($action == 'create') // 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'); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eeea825c1e5..e2db47a6c9d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1609,6 +1609,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Other attributes $parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index e76adb2a67c..fa9f810b036 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -471,6 +471,7 @@ if ($action == 'create' && !$error) // Other attributes $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); $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)) { $object=new Facture($db); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 7267769379e..06918ff2846 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -409,6 +409,7 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit',$parameters); @@ -946,6 +947,7 @@ else // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 9444c0585f7..e19deca91c9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -284,6 +284,7 @@ if ($action == 'create') // 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; print '
    '; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 555ea52b4e0..979ef5960e0 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -300,6 +300,7 @@ if ($action == 'create') // 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; print ''; @@ -396,6 +397,7 @@ else if ($id) // 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; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c79beaac4f3..fa9bdf60dc5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2591,6 +2591,7 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="2"', 'cols'=>2); $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'); } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index bd1f83d7f43..317d3ae813d 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -202,6 +202,7 @@ if ($action == 'create') // 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; print ''; @@ -271,6 +272,7 @@ if ($id) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print ''; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 20079ad18ee..45bde4bcd32 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -302,6 +302,7 @@ if ($action == 'create') // 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; print ''; @@ -389,6 +390,7 @@ if ($id) // 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; print ''; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ea26d2c55a8..6f7e250f4f5 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -284,6 +284,7 @@ if ($action == 'create') // 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; print ''; @@ -351,6 +352,7 @@ if ($id) // 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; print ''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ae13bb44a3a..fbd27b0d841 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -666,6 +666,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"','cols'=>3); $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'); @@ -934,6 +935,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $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'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4e19d6109b8..58b1608f44b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1211,6 +1211,7 @@ if ($action == 'create') // Other attributes $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; // Other attributes if (empty($reshook) && ! empty($extrafields->attribute_label)) { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9c9813e18ca..0f1d581c99f 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -34,6 +34,7 @@ if (! empty($cols)) $parameters['cols'] = $cols; if (! empty($object->fk_soc)) $parameters['socid'] = $object->fk_soc; $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); +print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 33f2375a1bf..3f58982624d 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -373,6 +373,7 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit',$parameters); @@ -498,6 +499,7 @@ if (! empty($id) && $action == 'edit') // 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'); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e3a1b0bc3fa..72044d68fcf 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -774,6 +774,7 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $expe->showOptionals($extrafields, 'edit'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d9c195f4ca9..c4aa6caccd8 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -125,7 +125,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { $action=''; $fk_projet=''; @@ -158,7 +158,7 @@ if (empty($reshook)) { // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - + $result=$object->createFromClone(GETPOST('fk_user_author','int')); if ($result > 0) { @@ -174,7 +174,7 @@ if (empty($reshook)) } } } - + if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer) { $object = new ExpenseReport($db); @@ -190,20 +190,20 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == 'add' && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); - + $object->date_debut = $date_start; $object->date_fin = $date_end; - + $object->fk_user_author = GETPOST('fk_user_author','int'); if (! ($object->fk_user_author > 0)) $object->fk_user_author = $user->id; - + $fuser=new User($db); $fuser->fetch($object->fk_user_author); - + $object->fk_statut = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_user_validator = GETPOST('fk_user_validator','int'); @@ -215,20 +215,20 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error++; } - + if ($object->periode_existe($fuser,$object->date_debut,$object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); $action='create'; } - + if (! $error) { $db->begin(); - + $id = $object->create($user); - + if ($id > 0) { $db->commit(); @@ -243,25 +243,25 @@ if (empty($reshook)) } } } - + if ($action == 'update' && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); - + $object->date_debut = $date_start; $object->date_fin = $date_end; - + if($object->fk_statut < 3) { $object->fk_user_validator = GETPOST('fk_user_validator','int'); } - + $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->note_public = GETPOST('note_public'); $object->note_private = GETPOST('note_private'); $object->fk_user_modif = $user->id; - + $result = $object->update($user); if ($result > 0) { @@ -273,14 +273,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -296,17 +296,17 @@ if (empty($reshook)) } else if ($reshook < 0) $error++; } - + if ($error) $action = 'edit_extras'; } - + if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); $result = $object->setValidate($user); - + if ($result > 0) { // Define output language @@ -322,51 +322,51 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0 && $object->fk_user_validator > 0) { $langs->load("mails"); - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_validator); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); $emailFrom = $expediteur->email; - + if ($emailTo && $emailFrom) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportWaitingForApproval"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); - + // Rebuild pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); - + if($resultPDF): // ATTACHMENT array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf"); array_push($mimetype,"application/pdf"); */ - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -411,13 +411,13 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); $result = $object->set_save_from_refuse($user); - + if ($result > 0) { // Define output language @@ -433,11 +433,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail @@ -446,7 +446,7 @@ if (empty($reshook)) $destinataire = new User($db); $destinataire->fetch($object->fk_user_validator); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_author); @@ -455,10 +455,10 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportWaitingForReApproval"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $dateRefusEx = explode(" ",$object->date_refuse); @@ -481,7 +481,7 @@ if (empty($reshook)) // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -526,15 +526,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + // Approve if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) { $object = new ExpenseReport($db); $object->fetch($id); - + $result = $object->setApproved($user); - + if ($result > 0) { // Define output language @@ -550,11 +550,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail @@ -576,19 +576,19 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportApproved"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -600,7 +600,7 @@ if (empty($reshook)) */ $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -673,7 +673,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -686,28 +686,28 @@ if (empty($reshook)) $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_refuse); $emailFrom = $expediteur->email; - + if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportRefused"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -796,7 +796,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -814,23 +814,23 @@ if (empty($reshook)) $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; - + if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportCanceled"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); - + // Rebuilt pdf /* $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + if($resultPDF { // ATTACHMENT @@ -840,10 +840,10 @@ if (empty($reshook)) array_push($mimetype,"application/pdf"); } */ - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -881,7 +881,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); $action=''; - } + } } else { @@ -918,7 +918,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -961,7 +961,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -983,7 +983,7 @@ if (empty($reshook)) if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); - + // SUBJECT $subject = $langs->transnoentities("ExpenseReportPaid"); @@ -1154,7 +1154,7 @@ if (empty($reshook)) { $object = new ExpenseReport($db); $object->fetch($id); - + $object_ligne = new ExpenseReportLine($db); $object_ligne->fetch(GETPOST("rowid")); $total_ht = $object_ligne->total_ht; @@ -1178,11 +1178,11 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + $object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); exit; @@ -1244,13 +1244,13 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + $result = $object->recalculer($id); - + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } @@ -1296,7 +1296,7 @@ if ($action == 'create') print ''; print ''; - + // Date start print ''; print ''; @@ -1304,7 +1304,7 @@ if ($action == 'create') $form->select_date($date_start?$date_start:-1,'date_debut',0,0,0,'',1,1); print ''; print ''; - + // Date end print ''; print ''; @@ -1312,7 +1312,7 @@ if ($action == 'create') $form->select_date($date_end?$date_end:-1,'date_fin',0,0,0,'',1,1); print ''; print ''; - + print ''; print ''; print ''; print ''; - + // Payment mode if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { @@ -1376,7 +1376,7 @@ if ($action == 'create') // Other attributes $parameters = array('colspan' => ' colspan="3"'); $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'); } @@ -1400,7 +1400,7 @@ else $result = $object->fetch($id, $ref); $res = $object->fetch_optionals($object->id, $extralabels); - + if ($result > 0) { if (! in_array($object->fk_user_author, $user->getAllChildIds(1))) @@ -1698,7 +1698,7 @@ else $userfee=new User($db); $result = $userfee->fetch($object->fk_user_validator); if ($result > 0) print $userfee->getNomUrl(-1); - if (empty($userfee->email) || ! isValidEmail($userfee->email)) + if (empty($userfee->email) || ! isValidEmail($userfee->email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); @@ -1902,9 +1902,9 @@ else { print ''; print ''; - + $remaintopay = $object->total_ttc - $totalpaid; - + print ''; print ''; } @@ -1984,7 +1984,7 @@ else if ($action != 'editline' || $objp->rowid != GETPOST('rowid')) { print ''; - + print ''; @@ -2006,7 +2006,7 @@ else print ''; print ''; print ''; - + if ($action != 'editline') { print ''; @@ -2034,7 +2034,7 @@ else if ($action == 'editline' && $objp->rowid == GETPOST('rowid')) { print ''; - + print ''; // Select date @@ -2049,7 +2049,7 @@ else $formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 1, 1); print ''; } - + // Select type print ''; - + print ''; } // Fin si c'est payé/validé print '
    '.$langs->trans("DateStart").'
    '.$langs->trans("DateEnd").'
    '.$langs->trans("User").''; @@ -1341,7 +1341,7 @@ if ($action == 'create') } print '
    '.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
    '.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
    '.$langs->trans("RemainderToPay").':'.price($remaintopay).'
    '; print img_picto($langs->trans("Document"), "object_generic"); print ' '.$piece_comptable.''.vatrate($objp->vatrate,true).''.price($objp->value_unit).''.$objp->qty.''.price($objp->total_ht).'
    '; select_type_fees_id($objp->type_fees_code,'fk_c_type_fees'); @@ -2168,13 +2168,13 @@ else } print '
    '; print '
    '; - + print ''; } else @@ -2290,7 +2290,7 @@ if ($action != 'create' && $action != 'edit') // If status is Appoved // -------------------- - + if ($user->rights->expensereport->approve && $object->fk_statut == 5) { print ''; @@ -2309,7 +2309,7 @@ if ($action != 'create' && $action != 'edit') print ''; } } - + // If bank module is not used if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) { @@ -2319,26 +2319,26 @@ if ($action != 'create' && $action != 'edit') print '"; } } - + if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == 5) { // Cancel print ''; } - + // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == 6) { // Cancel print ''; } - + // Clone if ($user->rights->expensereport->creer) { print ''; } - - /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ + + /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut <= 4) { // Delete @@ -2389,7 +2389,7 @@ if ($action != 'create' && $action != 'edit' && ($id || $ref)) $object->fetch_thirdparty(); $result = $object->add_object_linked('fichinter', GETPOST('LinkedFichinter')); } - + // Show links to link elements $linktoelements=array(); if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9e463eb8ac4..c084806c4a6 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -581,7 +581,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + /* * Mise a jour d'une ligne d'intervention */ @@ -997,7 +997,8 @@ if ($action == 'create') // Other attributes $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } @@ -1147,11 +1148,11 @@ else if ($id > 0 || ! empty($ref)) // Print form confirm print $formconfirm; - + // Intervention card $linkback = ''.$langs->trans("BackToList").''; - - + + $morehtmlref='
    '; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1); @@ -1191,16 +1192,16 @@ else if ($id > 0 || ! empty($ref)) } } $morehtmlref.='
    '; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
    '; print '
    '; print '
    '; - + print ''; - + if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) { // Date Start @@ -1279,14 +1280,14 @@ else if ($id > 0 || ! empty($ref)) include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
    '; - + print '
    '; print '
    '; print '
    '; print '
    '; - + print ''; - + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { // Duration @@ -1294,15 +1295,15 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + print "
    '.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
    "; - + print '
    '; print '
    '; print '
    '; - + print '

    '; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { @@ -1367,7 +1368,7 @@ else if ($id > 0 || ! empty($ref)) while ($i < $num) { $objp = $db->fetch_object($resql); - + // Ligne en mode visu if ($action != 'editline' || GETPOST('line_id','int') != $objp->rowid) @@ -1488,7 +1489,7 @@ else if ($id > 0 || ! empty($ref)) // Add new line if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) { - if (! $num) + if (! $num) { print '
    '; @@ -1501,7 +1502,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print "\n"; } - + print ''."\n"; print '
     
    '; // editeur wysiwyg @@ -1655,7 +1656,7 @@ else if ($id > 0 || ! empty($ref)) { print ''; } - + // Clone if ($user->rights->ficheinter->creer) { print ''; @@ -1698,7 +1699,7 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
    '; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2137e7ca747..dda4a0d7254 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1572,6 +1572,7 @@ if ($action=='create') // Other options $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)) { diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index a503776b653..86c177c4313 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -370,6 +370,7 @@ if ($action == 'create' && !$error) { 'cols'=>2 ); $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)) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 306ad62d69b..e67cb74d1ea 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1824,6 +1824,7 @@ if ($action == 'create') // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; // Bouton "Create Draft" print "
    \n"; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d42dc87b4b9..dc75ee54bb5 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1047,6 +1047,7 @@ else // Other attributes $parameters=array('cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit',$parameters); @@ -1366,6 +1367,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $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'); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 2b76fb0a111..a7c7b4f22be 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -193,6 +193,7 @@ if ($object->id) $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Construit liste des fichiers diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 84532ad219e..46db7f69b91 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -98,7 +98,7 @@ if (empty($reshook)) if ($id) { $result=$object->fetch($id); - $object->cost_price = price2num($cost_price); + $object->cost_price = price2num($cost_price); $result=$object->update($object->id, $user); if ($result > 0) { @@ -112,7 +112,7 @@ if (empty($reshook)) } } } - + if ($action == 'confirm_remove_pf') { if ($rowid) // id of product supplier price to remove @@ -299,21 +299,21 @@ if ($id > 0 || $ref) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id . '&rowid=' . $rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); echo $formconfirm; } - + if ($action <> 'edit' && $action <> 're-edit') { $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); - + dol_fiche_head($head, 'suppliers', $titre, -1, $picto); - + $linkback = ''.$langs->trans("BackToList").''; - $object->next_prev_filter=" fk_product_type = ".$object->type; + $object->next_prev_filter=" fk_product_type = ".$object->type; dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print ''; @@ -338,14 +338,14 @@ if ($id > 0 || $ref) print ''; - + print '
    '; print $form->editfieldval($text,'cost_price',$object->cost_price,$object,$user->rights->produit->creer||$user->rights->service->creer,'amount:6'); print '
    '; print '
    '; print '
    '; - + dol_fiche_end(); - + // Form to add or update a price if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -365,7 +365,7 @@ if ($id > 0 || $ref) print '
    '; print ''; print ''; - + dol_fiche_head(); print ''; @@ -450,11 +450,11 @@ if ($id > 0 || $ref) $default_vat=get_default_tva($mysoc2, $mysoc, $object->id, 0); $default_npr=get_default_npr($mysoc2, $mysoc, $object->id, 0); if (empty($default_vat)) $default_npr=$default_vat; - + print ''; print '
    '.$langs->trans("VATRateForSupplierProduct").''; //print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country - if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price + if (! empty($rowid)) // If we have a supplier, it is an update, we must show the vat of current supplier price { $tmpproductsupplier=new ProductFournisseur($db); $tmpproductsupplier->fetch_product_fournisseur_price($rowid, 1); @@ -463,7 +463,7 @@ if ($id > 0 || $ref) } else { - if (empty($default_vat)) + if (empty($default_vat)) { $default_vat=$object->tva_tx; } @@ -546,6 +546,7 @@ if ($id > 0 || $ref) { $parameters=array('id_fourn'=>$id_fourn,'prod_id'=>$object->id); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); + print $hookmanager->resPrint; } print '
    '; @@ -589,7 +590,7 @@ if ($id > 0 || $ref) $product_fourn_list = $product_fourn->list_product_fournisseur_price($object->id, $sortfield, $sortorder); $nbtotalofrecords = count($product_fourn_list); print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($product_fourn_list), $nbtotalofrecords, 'title_accountancy.png'); - + // Suppliers list title print '
    '; print ''; @@ -608,7 +609,7 @@ if ($id > 0 || $ref) print_liste_field_titre($langs->trans("DiscountQtyMin"),$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("NbDaysToDelivery"),$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ReputationForThisProduct"),$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); - + // Charges ???? if ($conf->global->PRODUCT_CHARGES) { @@ -623,13 +624,13 @@ if ($id > 0 || $ref) foreach($product_fourn_list as $productfourn) { - + print ''; // Supplier print ''; - + // Supplier print ''; @@ -675,8 +676,8 @@ if ($id > 0 || $ref) // Reputation print ''; // Charges ???? diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index f4c0c66cdec..fe6f92bffec 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -82,7 +82,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,14 +97,15 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print '
    '.$productfourn->getSocNomUrl(1,'supplier').''.$productfourn->fourn_ref.''; if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) { - print $object->reputations[$productfourn->supplier_reputation]; - } + print $object->reputations[$productfourn->supplier_reputation]; + } print'
    '; @@ -114,9 +115,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
    '; - + dol_fiche_end(); - + if ($user->rights->commande->lire) { @@ -211,7 +212,7 @@ if ($id > 0 || ! empty($ref)) while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - + print ''; print ''; - -// Example with a yes / no select -$var=!$var; -print ''; -print ''; -print ''; - +if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { + // Example with a yes / no select + $var=!$var; + print ''; + print ''; + print ''; +} print '
    '; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index dafb2b5aafd..2d9bccbcca4 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -88,7 +88,7 @@ if ($id > 0 || ! empty($ref)) { $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) @@ -96,7 +96,7 @@ if ($id > 0 || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct" . $product->type)); - if ($result > 0) + if ($result > 0) { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct" . $product->type); @@ -104,15 +104,15 @@ if ($id > 0 || ! empty($ref)) { dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print ''; @@ -122,9 +122,9 @@ if ($id > 0 || ! empty($ref)) { print ''; print '
    '; - + dol_fiche_end(); - + if ($user->rights->fournisseur->commande->lire) { diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index b5a8ec2b039..c4421aa21f3 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -87,14 +87,15 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print '
    '; @@ -104,9 +105,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
    '; - + dol_fiche_end(); - + $now=dol_now(); @@ -141,7 +142,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -151,7 +152,7 @@ if ($id > 0 || ! empty($ref)) print ''; $option .= '&page=' . $page; } - + print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); $i = 0; @@ -177,7 +178,7 @@ if ($id > 0 || ! empty($ref)) while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - + print ''; print '
    '.img_object($langs->trans("ShowContract"),"contract").' '; @@ -197,7 +198,7 @@ if ($id > 0 || ! empty($ref)) $i++; } } - + print '
    '; print '
    '; print ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index d4f447128a1..3b3cfb37b1d 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -83,9 +83,9 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - + $object = $product; - + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -114,14 +114,15 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print ''; @@ -131,14 +132,14 @@ if ($id > 0 || ! empty($ref)) print ''; print '
    '; - + dol_fiche_end(); if ($showmessage && $nboflines > 1) { print $langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")); } - elseif ($user->rights->facture->lire) + elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,"; @@ -164,13 +165,13 @@ if ($id > 0 || ! empty($ref)) $total_ht=0; $total_qty=0; $totalrecords=0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - if ($result) + if ($result) { $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) + while ($objp = $db->fetch_object($result)) { $total_ht+=$objp->total_ht; $total_qty+=$objp->qty; @@ -234,7 +235,7 @@ if ($id > 0 || ! empty($ref)) while ($i < min($num,$conf->liste_limit)) { $objp = $db->fetch_object($result); - + print ''; print ''; // Disable - + print ''; // Separator - + print ''; // Method - + print ''; // Host server - + print ''; // Port - + print ''; // STARTTLS - + print ''; // Separator - + print ''; - + // From - + print ''; print ''; // Default from type - + $liste = array(); $liste['user'] = $langs->trans('UserEmail'); $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; @@ -424,17 +424,17 @@ if ($action == 'edit') print ''; // Separator - + print ''; - + // From - + print ''; print ''; // Autocopy to - + print ''; print ''; @@ -442,7 +442,7 @@ if ($action == 'edit') print '
    '; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 5701b8960e5..ba17b1b3265 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -99,14 +99,15 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print ''; @@ -116,9 +117,9 @@ if ($id > 0 || ! empty($ref)) print ''; print '
    '; - + dol_fiche_end(); - + if ($user->rights->fournisseur->facture->lire) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index c9aa8fd85bc..616a54f67ff 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -82,7 +82,7 @@ if ($id > 0 || ! empty($ref)) $result = $product->fetch($id, $ref); $object = $product; - + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,14 +97,15 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'referers', $titre, -1, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
    '; - + print '
    '; print '
    '; @@ -114,11 +115,11 @@ if ($id > 0 || ! empty($ref)) print ''; print '
    '; - - dol_fiche_end(); - - if ($user->rights->propale->lire) + dol_fiche_end(); + + + if ($user->rights->propale->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; $sql .= " p.ref_client,"; @@ -239,7 +240,7 @@ if ($id > 0 || ! empty($ref)) } } } - + print ''; print ''; print ''; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 69421aa5624..b7b2b98baa8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -568,7 +568,7 @@ if ($id > 0 || $ref) // Minimum Price print ''; - print ''; // Hook formObject - $parameters=array('cols'=>2); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; // Desired stock print ''; @@ -707,7 +708,7 @@ if ($id > 0 || $ref) { dol_print_error($db); } - print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index e8c48352120..7b0b448ef59 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -610,6 +610,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Other options $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'); @@ -834,6 +835,7 @@ elseif ($object->id > 0) // Other options $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'); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index a9e50f96f91..41ae6d28364 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -42,7 +42,7 @@ $backtopage=GETPOST('backtopage','alpha'); $cancel=GETPOST('cancel'); $search_user_id = GETPOST('search_user_id', 'int'); - + //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); @@ -97,7 +97,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) //$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); $date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); $date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); - + if (! $cancel) { if (empty($taskref)) @@ -139,7 +139,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) $task->date_start = $date_start; $task->date_end = $date_end; $task->progress = $progress; - + // Fill array 'array_options' with data from add form $ret = $extrafields_task->setOptionalsFromPost($extralabels_task,$task); @@ -224,26 +224,26 @@ if ($id > 0 || ! empty($ref)) if ($search_user_id > 0) $param.='&search_user_id='.dol_escape_htmltag($search_user_id); // Project card - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
    '; // Title $morehtmlref.=$object->title; // Thirdparty - if ($object->thirdparty->id > 0) + if ($object->thirdparty->id > 0) { $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
    '; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
    '; @@ -286,7 +286,7 @@ if ($id > 0 || ! empty($ref)) print ($end?$end:'?'); if ($object->hasDelay()) print img_warning("Late"); print ''; - + // Budget print '
    ' . $langs->trans('Total') . '
    '.$langs->trans("BuyingPriceMin").''; + print ''; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { @@ -611,17 +611,18 @@ if ($id > 0 || $ref) } // Stock alert threshold - print '
    '.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; + print '
    '.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); print '
    '.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); - print ''; + print ''; print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer,'string'); print '
    '.$langs->trans("LastMovement").''; + print '
    '.$langs->trans("LastMovement").''; if ($lastmovementdate) { print dol_print_date($lastmovementdate,'dayhour').' '; @@ -800,7 +801,11 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) print ''.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'
    '.$langs->trans("Budget").''; if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); @@ -295,16 +295,16 @@ if ($id > 0 || ! empty($ref)) // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
    '; - + print '
    '; print '
    '; print '
    '; print '
    '; - + print ''; - + // Description print '"; } - + print '
    '.$langs->trans("Description").''; print nl2br($object->description); @@ -316,13 +316,13 @@ if ($id > 0 || ! empty($ref)) print $form->showCategories($object->id,'project',1); print "
    '; - + print '
    '; print '
    '; print ''; - + print '
    '; @@ -341,7 +341,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''; if (! empty($object->id)) print ''; - + dol_fiche_head(''); print ''; @@ -413,6 +413,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Other options $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_task->attribute_label)) { print $object->showOptionals($extrafields_task,'edit'); @@ -460,7 +461,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - + print ''; if ($optioncss != '') print ''; print ''; @@ -470,12 +471,12 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $title=$langs->trans("ListOfTasks"); $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title,$linktotasks,'title_generic.png'); - + // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; @@ -483,7 +484,7 @@ else if ($id > 0 || ! empty($ref)) // We load also tasks limited to a particular user $tmpuser=new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); - + $tasksrole=($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); @@ -494,7 +495,7 @@ else if ($id > 0 || ! empty($ref)) } print '
    '; - + if (count($tasksarray) > 0) { // Link to switch in "my task" / "all task" @@ -509,7 +510,7 @@ else if ($id > 0 || ! empty($ref)) print $searchpicto; print ''; } - + print ''; // print ''; print ''; @@ -522,7 +523,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print "\n"; - + if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) @@ -533,11 +534,11 @@ else if ($id > 0 || ! empty($ref)) { print ''; } - + print "
    '.$langs->trans("Project").''.$langs->trans("RefTask").''.$langs->trans("ProgressDeclared").' 
    '.$langs->trans("NoTasks").'
    "; print ''; - + // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'
    '; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2d35be97f4a..df89cac3e83 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -408,6 +408,7 @@ if ($id > 0 || ! empty($ref)) // Other options $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'); diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index 2e988d16025..a294dfb94db 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -177,6 +177,7 @@ if (! $action) // Other attributes $parameters=array('objectsrc' => $objectsrc); $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'); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index a286eb60097..02d38c2b924 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -203,6 +203,7 @@ if ( $object->fetch($id) > 0 ) // Other attributes $parameters=array('objectsrc' => $objectsrc); $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'); diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index da9b7c4a8f3..e972aaa1091 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -174,7 +174,8 @@ if (! empty($socid)) $parameters=array('socid'=>$object->id); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$obj,$action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $tmpuser->id = $obj->rowid; $tmpuser->firstname = $obj->firstname; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index c7807d8c4e5..72c9793b40b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1150,6 +1150,7 @@ if ($action == 'create') // Other attributes $parameters = array('colspan' => ' colspan="3"'); $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'); } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9e9e2b09e28..8400a95d370 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1112,6 +1112,7 @@ if ($action == 'create' || $action == 'adduserldap') // Other attributes $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); $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'); diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 8be0276e6ee..e53080cea73 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -272,6 +272,7 @@ if ($action == 'create') // Other attributes $parameters=array('object' => $object, 'colspan' => ' colspan="2"'); $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'); @@ -562,6 +563,7 @@ else // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); From bb091c3b8bc7fd21ebc0efcae271e8c0c10d8521 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 10:45:45 +0200 Subject: [PATCH 069/342] FIX The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow hook specifications so you must return output into "resprint". --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5b4f986fbb1..766efb9c02a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,9 @@ Following changes may create regression for some external modules, but were nece exists, but if an external module need action on it, it must provides itself its trigger file. * Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') +* The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output +content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow +hook specifications so you must return output into "resprint". ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty From 57f99ba7a1e69371d3996bbcc2e084b25cd641ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 11:09:05 +0200 Subject: [PATCH 070/342] Update README --- README-FR.md | 19 +++++++++---------- README.md | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README-FR.md b/README-FR.md index 1c097e7914e..4129e2b7452 100644 --- a/README-FR.md +++ b/README-FR.md @@ -103,25 +103,24 @@ Voir fichier ChangeLog. ### Divers: -- Application multi-utilisateurs avec différents niveaux de permissions par module. +- Multi-langue. +- Multi-utilisateurs avec différents niveaux de permissions par module. +- Multi-devise. - Peux être multi-société par ajout du module externe multi-société. -- Peux-être multi-devise par ajout du module externe multi-devise. -- Plusieurs gestionnaires de menus (possibilité de différencier les menus pour les utilisateurs internes ou externes comme les clients ou fournisseurs). -- Application simple à utiliser. - Plusieurs thèmes visuels. -- Code simple et facilement personnalisable. -- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur http://wiki.dolibarr.org/index.php/Prérequis). +- Application simple à utiliser. +- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur https://wiki.dolibarr.org/index.php/Prérequis). - Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP. -- Export PDF de tous les éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) +- Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers). +- APIs. +- Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) ## CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE) Voici un liste de fonctionnalites pas encore gérées par Dolibarr: -- Pas encore de compta analytique double-partie (uniquement gestion de trésorerie). -- Dolibarr ne gère qu'une seule monnaie à la fois (mono-devise). - Dolibarr ne contient pas de module de Gestion de la paie. -- Les tâches du module de gestion de projets n'ont pas de dépendance entre elle. +- Les tâches du module de gestion de projets n'ont pas de dépendances entre elle. - Dolibarr ne contient pas de Webmail. - Dolibarr ne fait pas le café (pas encore). diff --git a/README.md b/README.md index eda6b8b642e..f091bb6c952 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ## FEATURES -### Main modules (all optional) +### Main application/modules (all optional) - Customers, Prospects and/or Suppliers directory - Products and/or Services catalog @@ -107,7 +107,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Point of Sale - … -### Other modules +### Other application/modules - Bookmarks management - Donations management @@ -124,15 +124,17 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - … ### Other general features -- Multi-Users and groups with finely grained rights -- Localization in most major languages -- Can manage several companies by adding external module multi-company. -- Can manage several currencies by adding external module multi-currency. -- Very user friendly and easy to use + +- Localization in most major languages. +- Multi-Users and groups with finely grained rights. +- Multi-currency. +- Multi-company by adding of an external module. +- Very user friendly and easy to use. - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](http://wiki.dolibarr.org/index.php/Prerequisite)) +- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. -- An easy to understand, maintain and code interfaces with your own information system (PHP with no heavy framework; trigger and hook architecture) +- APIs +- An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) - Support for country specific features: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) @@ -150,7 +152,6 @@ Dolibarr can be extended with a lot of other external modules from third party d These are features that Dolibarr does **not** yet fully support: -- Double-entry bookkeeping yet (only bank and treasury management) - Tasks dependencies in projects - Payroll module - Webmail From 965e3e514047c438a9b346a658e4d81596da4e4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 11:21:17 +0200 Subject: [PATCH 071/342] Update doc --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f091bb6c952..29a7d4f9545 100644 --- a/README.md +++ b/README.md @@ -133,20 +133,21 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) - Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. -- APIs +- APIs. - An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) - Support for country specific features: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) - Canadian double taxes (federal/province) and other countries using cumulative VAT - Tunisian tax stamp + - Argentina invoice numbering using A,B,C... - Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - PDF or ODT generation for invoice, proposals, orders... - … ### Extending -Dolibarr can be extended with a lot of other external modules from third party developers available at the [DoliStore](https://www.dolistore.com). +Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). ## FUTURE From a96362e2f94808304165e6ea6b9c29dd139a4405 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 11:40:01 +0200 Subject: [PATCH 072/342] Fix #formmailbeforetitle not supported everywhere --- htdocs/admin/mails.php | 89 ++++++++++--------- htdocs/comm/mailing/card.php | 3 +- htdocs/comm/propal/card.php | 3 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 3 +- htdocs/contrat/card.php | 1 + htdocs/expedition/card.php | 3 +- htdocs/fichinter/card.php | 3 +- htdocs/fourn/commande/card.php | 3 +- htdocs/fourn/facture/card.php | 5 +- .../modulebuilder/template/myobject_card.php | 3 + htdocs/societe/card.php | 4 +- htdocs/supplier_proposal/card.php | 3 +- htdocs/user/card.php | 1 + 14 files changed, 71 insertions(+), 55 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 03cce1dff09..6b8126bd977 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -229,11 +229,11 @@ if ($action == 'edit') print ''; dol_fiche_head($head, 'common', '', -1); - + print $langs->trans("EMailsDesc")."
    \n"; print "
    \n"; - - + + clearstatcache(); $var=true; @@ -241,17 +241,17 @@ if ($action == 'edit') print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_DISABLE_ALL_MAILS").''; print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print '
     
    '.$langs->trans("MAIN_MAIL_SENDMODE").''; // SuperAdministrator access only @@ -270,7 +270,7 @@ if ($action == 'edit') print '
    '; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { @@ -303,7 +303,7 @@ if ($action == 'edit') print '
    '; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { @@ -338,7 +338,7 @@ if ($action == 'edit') // ID if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - + $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:''); print '
    '.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only @@ -358,7 +358,7 @@ if ($action == 'edit') // PW if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - + $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); print '
    '.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only @@ -376,7 +376,7 @@ if ($action == 'edit') } // TLS - + print '
    '.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { @@ -390,7 +390,7 @@ if ($action == 'edit') print '
    '.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { @@ -404,17 +404,17 @@ if ($action == 'edit') print '
     
    '.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'
     
    '.$langs->trans("MAIN_MAIL_ERRORS_TO").'
    '.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'
    '; dol_fiche_end(); - + print '
    '; print ''; print '     '; @@ -454,26 +454,26 @@ if ($action == 'edit') else { dol_fiche_head($head, 'common', '', -1); - + print $langs->trans("EMailsDesc")."
    \n"; print "
    \n"; - - + + $var=true; print ''; print ''; // Disable - + print ''; // Separator - + print ''; // Method - + print ''; // Host server - + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -492,7 +492,7 @@ else } // Port - + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -503,21 +503,21 @@ else } // SMTPS ID - + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // TLS - + print ''; // STARTTLS - + print ''; // Separator - + print ''; // From - + print ''; print ''; // Default from type - + print ''; print ''; // Separator - + print ''; // Errors To - + print ''; print ''; // Autocopy to - + print ''; print ''; - + print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'
     
    '.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -481,7 +481,7 @@ else print '
    '.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
    '.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
    '.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
    '.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).'
    '.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -531,7 +531,7 @@ else print '
    '.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -545,18 +545,18 @@ else print '
     
    '.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print '
    '.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; if($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user'){ @@ -567,18 +567,18 @@ else print '
     
    '.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print '
    '.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) @@ -591,12 +591,12 @@ else print ' '; } print '
    '; dol_fiche_end(); - - + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) { print '
    '; @@ -614,7 +614,7 @@ else print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); } - + // Boutons actions print '
    '; @@ -647,7 +647,7 @@ else $text = $langs->trans("WarningPHPMail"); print info_admin($text); } - + // Run the test to connect if ($action == 'testconnect') { @@ -673,6 +673,7 @@ else // Show email send test form if ($action == 'test' || $action == 'testhtml') { + print '
    '; print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend")); // Cree l'objet formulaire mail diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 17d4d066569..8f4deb53edf 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1010,7 +1010,8 @@ else // Affichage formulaire de TEST if ($action == 'test') { - print load_fiche_titre($langs->trans("TestMailing")); + print '
    '; + print load_fiche_titre($langs->trans("TestMailing")); // Create l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3e8580d5350..67dbca101f8 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2281,7 +2281,7 @@ if ($action == 'create') // Send if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) { - print ''; + print ''; } else print ''; } @@ -2412,6 +2412,7 @@ if ($action == 'create') $file = $fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendPropalByMail')); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e2db47a6c9d..83135a8c0f5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2443,7 +2443,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Send if ($object->statut > Commande::STATUS_DRAFT) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { - print ''; + print ''; } else print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fa9bdf60dc5..c4bf83293de 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4071,7 +4071,7 @@ else if ($id > 0 || ! empty($ref)) print '
    ' . $langs->trans('SendByMail') . '
    '; } else { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send) { - print ''; + print ''; } else print ''; } @@ -4328,6 +4328,7 @@ else if ($id > 0 || ! empty($ref)) $file = $fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans($titreform)); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 58b1608f44b..b2ab3bf3cb8 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2162,6 +2162,7 @@ else $file = $fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendContractByMail')); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 72044d68fcf..efc64d84396 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2037,7 +2037,7 @@ else if ($id || $ref) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) { - print ''.$langs->trans('SendByMail').''; + print ''.$langs->trans('SendByMail').''; } else print ''.$langs->trans('SendByMail').''; } @@ -2162,6 +2162,7 @@ else if ($id || $ref) $file=$fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendShippingByEMail')); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index c084806c4a6..108aaf7a23a 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1598,7 +1598,7 @@ else if ($id > 0 || ! empty($ref)) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) { - print ''; + print ''; } else print ''; } @@ -1753,6 +1753,7 @@ else if ($id > 0 || ! empty($ref)) $file=$fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendInterventionByMail')); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index dda4a0d7254..4deca7ea836 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2174,6 +2174,7 @@ elseif (! empty($object->id)) $file=$fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendOrderByMail')); @@ -2572,7 +2573,7 @@ elseif (! empty($object->id)) { if ($user->rights->fournisseur->commande->commander) { - print ''.$langs->trans('SendByMail').''; + print ''.$langs->trans('SendByMail').''; } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1078999b89e..db017cc004a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2660,7 +2660,7 @@ else { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) { - print ''; + print ''; } else print '
    '.$langs->trans('SendByMail').'
    '; } @@ -2836,7 +2836,8 @@ else $file=$fileparams['fullname']; } - print '
    '; + print '
    '; + print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendBillByMail')); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 56e0ea1d3ed..03dfd62f5d3 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -426,6 +426,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { + // Send + print ''."\n"; + if ($user->rights->mymodule->write) { print ''."\n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e26b4733c84..b5afba996b8 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2462,7 +2462,9 @@ else $action='send'; $modelmail='thirdparty'; - //print '
    '; + print '
    '; + print '
    '; + print '
    '; print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 72c9793b40b..d7d967d24b8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1740,7 +1740,7 @@ if ($action == 'create') // Send if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { - print ''; + print ''; } else print ''; } @@ -1854,6 +1854,7 @@ if ($action == 'create') $file = $fileparams['fullname']; } + print '
    '; print '
    '; print '
    '; print load_fiche_titre($langs->trans('SendAskByMail')); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8400a95d370..9d9684371a9 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1669,6 +1669,7 @@ else $action='send'; $modelmail='user'; + print '
    '; print '
    '; print load_fiche_titre($langs->trans($titreform)); From 946e72f269a3ec7aede35fedf42a0c38ecf713fd Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sun, 11 Jun 2017 12:26:51 +0200 Subject: [PATCH 073/342] Fix 6982 missing parameter to get more informations about files --- htdocs/core/lib/files.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7d8f29f7681..a4680ca81e2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1361,11 +1361,12 @@ function dol_uncompress($inputfile,$outputdir) * @param string $regexfilter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function * @param int $nohook Disable all hooks + * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @return string Full path to most recent file */ -function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview\.png)$','^\.'),$nohook=false) +function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta|_preview\.png)$','^\.'),$nohook=false,$mode='') { - $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,'',$nohook); + $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC,$mode,$nohook); return $tmparray[0]; } From 51579817517c8ef8159702f81cea9a6aa883bb9b Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sun, 11 Jun 2017 12:59:54 +0200 Subject: [PATCH 074/342] Fix 6962 wrong permission check --- htdocs/expedition/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 0077338aae5..a7f4043fcd1 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -73,7 +73,12 @@ $ref=GETPOST('ref','alpha'); // Security check $socid=''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user, $origin, $origin_id); + +if ($origin == 'expedition') $result=restrictedArea($user, $origin, $id); +else { + $result=restrictedArea($user, 'expedition'); + if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); +} $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); From 248c5acff29a1662e9ac54dcbee9fc1e480883ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 16:18:21 +0200 Subject: [PATCH 075/342] Fix remove a FIXME tag. --- htdocs/compta/paiement/cheque/list.php | 44 ++++++------- .../compta/paiement/class/paiement.class.php | 66 ++++++++++--------- 2 files changed, 58 insertions(+), 52 deletions(-) diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 63a2884e5bf..aeed72d93d1 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -139,24 +139,14 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', '', '', $limit); - + $moreforfilter=''; - + print '
    '; print ''."\n"; - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bc.ref","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NbOfCheques"),$_SERVER["PHP_SELF"],"bc.nbcheque","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"bc.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"bc.statut","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre(''); - print "\n"; - // Lignes des champs de filtre print ''; print ''; print "\n"; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bc.ref","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("NbOfCheques"),$_SERVER["PHP_SELF"],"bc.nbcheque","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"bc.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"bc.statut","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); + print "\n"; + if ($num > 0) { $var=true; while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; - + // Num ref cheque print ''; - + // Date print ''; // TODO Use date hour - + // Bank print ''; - + // Number of cheques print ''; - + // Amount print ''; - + // Statut print ''; - + print ''; - + print "\n"; $i++; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index c8d7f4d3759..f4e61380a9c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -38,7 +38,7 @@ class Paiement extends CommonObject public $element='payment'; public $table_element='paiement'; public $picto = 'payment'; - + var $facid; var $datepaye; /** @@ -65,7 +65,7 @@ class Paiement extends CommonObject // fk_paiement dans llx_paiement_facture est le rowid du paiement var $fk_paiement; // Type of paiment - + /** * Constructor * @@ -153,14 +153,14 @@ class Paiement extends CommonObject $error = 0; $way = $this->getWay(); - + $now=dol_now(); - + // Clean parameters $totalamount = 0; $totalamount_converted = 0; $atleastonepaymentnotnull = 0; - + if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -171,22 +171,22 @@ class Paiement extends CommonObject $amounts = &$this->multicurrency_amounts; $amounts_to_update = &$this->amounts; } - + foreach ($amounts as $key => $value) // How payment is dispatch { $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way); $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); - + $newvalue = price2num($value,'MT'); $amounts[$key] = $newvalue; $totalamount += $newvalue; if (! empty($newvalue)) $atleastonepaymentnotnull++; } - + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); - + // Check parameters if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays { @@ -211,7 +211,7 @@ class Paiement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)"; $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; - + dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -227,7 +227,7 @@ class Paiement extends CommonObject $amount = price2num($amount); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)'; $sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')'; - + dol_syslog(get_class($this).'::Create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -245,21 +245,27 @@ class Paiement extends CommonObject //var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit; - // If there is withdrawals request to do and not done yet, we wait before closing. + /* Why this ? We can remove i think. + // If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing. $mustwait=0; + $sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande"; + $sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0"; + ... + $listofpayments=$invoice->getListOfPayments(); foreach($listofpayments as $paym) { - // This payment might be this one or a previous one + // This payment on invoice $invoice might be the one we record or another one if ($paym['type']=='PRE') { if (! empty($conf->prelevement->enabled)) { - // FIXME Check if this invoice has a withdraw request // if not, $mustwait++; // This will disable automatic close on invoice to allow to process + } } } + */ //Invoice types that are eligible for changing status to paid $affected_types = array( @@ -272,14 +278,14 @@ class Paiement extends CommonObject if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more."); else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more."); - else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); + //else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); else { // If invoice is a down payment, we also convert down payment to discount if ($invoice->type == Facture::TYPE_DEPOSIT) { $amount_ht = $amount_tva = $amount_ttc = array(); - + // Loop on each vat rate $i = 0; foreach ($invoice->lines as $line) @@ -292,20 +298,20 @@ class Paiement extends CommonObject $i ++; } } - + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($this->db); $discount->description = '(DEPOSIT)'; $discount->fk_soc = $invoice->socid; $discount->fk_facture_source = $invoice->id; - + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); - + $result = $discount->create($user); if ($result < 0) { @@ -313,14 +319,14 @@ class Paiement extends CommonObject break; } } - + if ($error) { setEventMessages($discount->error, $discount->errors, 'errors'); $error++; - } + } } - + // Set invoice to paid if (! $error) { @@ -520,13 +526,13 @@ class Paiement extends CommonObject $acc = new Account($this->db); $result=$acc->fetch($this->fk_account); - + $totalamount=$this->amount; if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility - + // if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me) if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount=$this->multicurrency_amount; - + if ($mode == 'payment_supplier') $totalamount=-$totalamount; // Insert payment into llx_bank @@ -796,7 +802,7 @@ class Paiement extends CommonObject /** * Information sur l'objet - * + * * @param int $id id du paiement dont il faut afficher les infos * @return void */ @@ -962,13 +968,13 @@ class Paiement extends CommonObject /** * get the right way of payment - * + * * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs */ function getWay() { global $conf; - + $way = 'dolibarr'; if (!empty($conf->multicurrency->enabled)) { @@ -981,10 +987,10 @@ class Paiement extends CommonObject } } } - + return $way; } - + /** * Initialise an instance with random values. * Used to build previews or test instances. From ca324346e41e4939d885fc9331611018d5453c5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 19:08:40 +0200 Subject: [PATCH 076/342] Update doc --- htdocs/install/mysql/migration/repair.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index c748f38acb3..991212c7d22 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -13,11 +13,12 @@ -- flush privileges; --- Requests to change character set and collation of a column +-- Requests to change character set and collation of a varchar column. +-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- You can check with "show full columns from llx_accountingaccount"; +-- You can check with "show full columns from llx_accounting_account"; From 58c4144123d6b472fcebb01e79bc7f2bfd067abd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 19:27:07 +0200 Subject: [PATCH 077/342] Fix sort of dictionnary --- htdocs/admin/dict.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index f903ce3e8fc..c83a3aa39be 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -502,6 +502,14 @@ $tabfieldcheck[34] = array(); complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); +// Defaut sortorder +if (empty($sortfield)) +{ + $tmp1 = explode(',',$tabsqlsort[$id]); + $tmp2 = explode(' ',$tmp1[0]); + $sortfield=preg_replace('/^.*\./', '', $tmp2[0]); +} + // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); $sourceList=array(); @@ -944,7 +952,8 @@ if ($id) if (! preg_match('/ WHERE /',$sql)) $sql.= " WHERE 1 = 1"; if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id; - if ($search_code != '') $sql.= natural_search("code", $search_code); + if ($search_code != '' && $id != 9) $sql.= natural_search("code", $search_code); + if ($search_code != '' && $id == 9) $sql.= natural_search("code_iso", $search_code); if ($sortfield) { From b80ee49032ec1c4a097b37515c237ec977d2d838 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jun 2017 19:27:21 +0200 Subject: [PATCH 078/342] Add missing currency for bengladesh --- htdocs/install/mysql/data/llx_c_currencies.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index 1c9d4b5f8a7..d9b1390bb32 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -41,6 +41,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'AZN' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BHD', NULL, 1, 'Bahrain'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BSD', '[36]', 1, 'Bahamas Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BBD', '[36]', 1, 'Barbados Dollar'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BDT', '[2547]', 1, 'Bangladeshi Taka'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BYR', '[112,46]', 1, 'Belarus Ruble'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BZD', '[66,90,36]', 1, 'Belize Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'BMD', '[36]', 1, 'Bermuda Dollar'); From 277dde5d618cae0d661ac69c51040224e36b3cda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Jun 2017 10:25:28 +0200 Subject: [PATCH 079/342] Fix dol_banner --- htdocs/cron/card.php | 85 ++++++++++---------- htdocs/cron/class/cronjob.class.php | 115 ++++++++++++++-------------- htdocs/cron/info.php | 11 +++ htdocs/langs/en_US/cron.lang | 4 +- 4 files changed, 110 insertions(+), 105 deletions(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index fc89f6eb3cf..a371069d7cf 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -109,9 +109,9 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex else { $now = dol_now(); // Date we start - + $result=$object->run_jobs($user->login); - + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -155,7 +155,7 @@ if ($action=='add') $object->unitfrequency=GETPOST('unitfrequency','int'); $object->frequency=GETPOST('nbfrequency','int'); $object->maxrun=GETPOST('maxrun','int'); - + // Add cron task $result = $object->create($user); @@ -191,7 +191,7 @@ if ($action=='update') $object->unitfrequency=GETPOST('unitfrequency','int'); $object->frequency=GETPOST('nbfrequency','int'); $object->maxrun=GETPOST('maxrun','int'); - + // Add cron task $result = $object->update($user); @@ -353,7 +353,7 @@ if (($action=="create") || ($action=="edit")) print '"; print ""; print ""; print "\n"; - + print ""; print "\n"; - + print ""; print "\n"; - + print ""; $priority=0; @@ -505,7 +505,7 @@ if (($action=="create") || ($action=="edit")) print ""; print "\n"; - + print '"; print "\n"; - + print '"; print ""; print ""; - + print '
    '; @@ -181,15 +171,25 @@ if ($resql) print '
    '; $checkdepositstatic->id=$objp->rowid; @@ -197,29 +197,29 @@ if ($resql) $checkdepositstatic->statut=$objp->statut; print $checkdepositstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp),'day').''; if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; else print ' '; print ''.$objp->nbcheque.''.price($objp->amount).''; print $checkdepositstatic->LibStatut($objp->statut,5); print '
    '; print $langs->trans('CronClassFile').""; - print "classesname."\" /> "; + print ' '; print ""; print $form->textwithpicto('',$langs->trans("CronClassFileHelp"),1,'help'); @@ -371,7 +371,7 @@ if (($action=="create") || ($action=="edit")) print '
    '; print $langs->trans('CronMethod').""; - print "methodename."\" /> "; + print ' '; print ""; print $form->textwithpicto('',$langs->trans("CronMethodHelp"),1,'help'); @@ -431,7 +431,7 @@ if (($action=="create") || ($action=="edit")) } $input .= ""; print $input; - + $input = " unitfrequency=="3600"){ $input .= ' checked />'; @@ -441,7 +441,7 @@ if (($action=="create") || ($action=="edit")) } $input .= ""; print $input; - + $input = " unitfrequency=="86400"){ $input .= ' checked />'; @@ -451,7 +451,7 @@ if (($action=="create") || ($action=="edit")) } $input .= ""; print $input; - + $input = " unitfrequency=="604800"){ $input .= ' checked />'; @@ -465,7 +465,7 @@ if (($action=="create") || ($action=="edit")) print ""; print "
    "; print $langs->trans('CronDtStart').""; if(!empty($object->datestart)) @@ -480,7 +480,7 @@ if (($action=="create") || ($action=="edit")) print ""; print "
    "; print $langs->trans('CronDtEnd').""; if(!empty($object->dateend)){ @@ -493,7 +493,7 @@ if (($action=="create") || ($action=="edit")) print ""; print "
    "; print $langs->trans('CronPriority').""; print "
    '; $maxrun=''; if (!empty($object->maxrun)) { @@ -517,7 +517,7 @@ if (($action=="create") || ($action=="edit")) print ""; print "
    '; print $langs->trans('CronDtNextLaunch'); print ' ('.$langs->trans('CronFrom').')'; @@ -529,14 +529,14 @@ if (($action=="create") || ($action=="edit")) else { $form->select_date(-1,'datenextrun',1,1,'',"cronform"); - } + } print ""; print "
    '; - + dol_fiche_end(); print '
    '; @@ -554,24 +554,22 @@ else * view card */ $now = dol_now(); - + dol_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron'); $linkback = '' . $langs->trans("BackToList") . ''; - // TODO Use dol_banner - + $morehtmlref='
    '; + $morehtmlref.='
    '; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + // box add_jobs_box print '
    '; print '
    '; print ''; print '"; - print "\n"; - - print '"; print ""; @@ -616,21 +614,16 @@ else print $langs->trans($object->note); print ""; - print '"; - print '
    '; - print $langs->trans('CronId')."".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id', '', '', 0); - print "
    '; print $langs->trans('CronLabel')."".$langs->trans($object->label); print "
    '; - print $langs->trans('Active').""; - print $object->getLibStatut(4); - print "
    '; print '
    '; - + print '
    '; - + print '
    '; print '
    '; print ''; - + print '"; print ""; - + print '"; - + print ""; - + print ""; print ""; - + print ""; print ""; - + print ""; print ""; - + // Date next run (from) print '"; - + print '
    '; print $langs->trans('CronEvery').""; @@ -639,33 +632,33 @@ else if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days'); if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks'); print "
    '; print $langs->trans('CronDtStart').""; if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhoursec');} print "
    "; print $langs->trans('CronDtEnd').""; if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhoursec');} print "
    "; print $langs->trans('CronPriority')."".$object->priority; print "
    "; print $langs->trans('CronMaxRun').""; print $object->maxrun>0?$object->maxrun:''; print "
    "; print $langs->trans('CronNbRun')."".$object->nbrun; print "
    '; print $langs->trans('CronDtNextLaunch'); @@ -673,18 +666,18 @@ else print ""; //print ''; if (! $object->status) print $langs->trans("Disabled"); - elseif (!empty($object->datenextrun)) { print img_picto('','object_calendarday').' '.dol_print_date($object->datenextrun,'dayhoursec');} + elseif (!empty($object->datenextrun)) { print img_picto('','object_calendarday').' '.dol_print_date($object->datenextrun,'dayhoursec');} else {print $langs->trans('CronNone');} //print ''; if ($object->maxnbrun && $object->nbrun >= $object->maxrun) print img_warning($langs->trans("Finished")); if ($object->datenextrun && $object->datenextrun < $now) print img_warning($langs->trans("Late")); print "
    '; print '
    '; - + print '
    '; - + print '
    '; print '
    '; print ''; @@ -711,7 +704,7 @@ else print '
    '; print '
    '; - + dol_fiche_end(); @@ -733,7 +726,7 @@ else else { print ''.$langs->trans("CronExecute").''; } - + if (! $user->rights->cron->create) { print ''.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").''; } else { @@ -743,7 +736,7 @@ else print ''.$langs->trans("CronStatusInactiveBtn").''; } } - + if (! $user->rights->cron->delete) { print ''.$langs->trans("Delete").''; } else { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 9d01ec888f0..f9b4ac67f03 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -30,36 +30,37 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); */ class Cronjob extends CommonObject { - var $element='cronjob'; //!< Id that identify managed objects - var $table_element='cronjob'; //!< Name of table without prefix where object is stored + public $element='cronjob'; //!< Id that identify managed objects + public $table_element='cronjob'; //!< Name of table without prefix where object is stored + public $picto = 'cron'; - var $jobtype; - var $tms=''; - var $datec=''; - var $label; - var $command; - var $classesname; - var $objectname; - var $methodename; - var $params; - var $md5params; - var $module_name; - var $priority; - var $datelastrun=''; - var $datenextrun=''; - var $dateend=''; - var $datestart=''; - var $datelastresult=''; - var $lastresult; - var $lastoutput; - var $unitfrequency; - var $frequency; - var $status; - var $processing; - var $fk_user_author; - var $fk_user_mod; - var $nbrun; - var $libname; + public $jobtype; + public $tms=''; + public $datec=''; + public $label; + public $command; + public $classesname; + public $objectname; + public $methodename; + public $params; + public $md5params; + public $module_name; + public $priority; + public $datelastrun=''; + public $datenextrun=''; + public $dateend=''; + public $datestart=''; + public $datelastresult=''; + public $lastresult; + public $lastoutput; + public $unitfrequency; + public $frequency; + public $status; + public $processing; + public $fk_user_author; + public $fk_user_mod; + public $nbrun; + public $libname; /** @@ -1265,35 +1266,35 @@ class Cronjob extends CommonObject class Cronjobline { - var $id; - var $ref; + public $id; + public $ref; - var $tms=''; - var $datec=''; - var $label; - var $jobtype; - var $command; - var $classesname; - var $objectname; - var $methodename; - var $params; - var $md5params; - var $module_name; - var $priority; - var $datelastrun=''; - var $datenextrun=''; - var $dateend=''; - var $datestart=''; - var $lastresult=''; - var $lastoutput; - var $unitfrequency; - var $frequency; - var $status; - var $fk_user_author; - var $fk_user_mod; - var $note; - var $nbrun; - var $libname; + public $tms=''; + public $datec=''; + public $label; + public $jobtype; + public $command; + public $classesname; + public $objectname; + public $methodename; + public $params; + public $md5params; + public $module_name; + public $priority; + public $datelastrun=''; + public $datenextrun=''; + public $dateend=''; + public $datestart=''; + public $lastresult=''; + public $lastoutput; + public $unitfrequency; + public $frequency; + public $status; + public $fk_user_author; + public $fk_user_mod; + public $note; + public $nbrun; + public $libname; /** * Constructor diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index 18ab50adeaa..d3365abb90b 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -50,6 +50,17 @@ $head = cron_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); +$linkback = '' . $langs->trans("BackToList") . ''; + +$morehtmlref='
    '; +$morehtmlref.='
    '; + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + +print '
    '; + +print '
    '; + print '
    '; dol_print_object_info($object); print '
    '; diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index a1d3c6a9986..8eb03114c64 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -57,9 +57,9 @@ CronStatusActiveBtn=Enable CronStatusInactiveBtn=Disable CronTaskInactive=This job is disabled CronId=Id -CronClassFile=Classes (filename.class.php) +CronClassFile=Filename with class CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module).
    For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for module is product -CronClassFileHelp=The file name to load.
    For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is product.class.php +CronClassFileHelp=The relative path and file name to load (path is relative to web server root directory).
    For exemple to call the fetch method of Dolibarr Product object htdocs/product/class/product.class.php, the value for class file name is product/class/product.class.php CronObjectHelp=The object name to load.
    For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is Product CronMethodHelp=The object method to launch.
    For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for method is fecth CronArgsHelp=The method arguments.
    For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for paramters can be 0, ProductRef From 0312d2479d58124e4942ce1c29ce027b1904e5c0 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 12 Jun 2017 10:26:24 +0200 Subject: [PATCH 080/342] add block info popin, translation, hidden authority feature --- htdocs/blockedlog/admin/blockedlog.php | 28 ++++----- htdocs/blockedlog/admin/fingerprints.php | 61 +++++++++++++++++-- htdocs/blockedlog/ajax/block-info.php | 15 +++++ htdocs/blockedlog/class/authority.class.php | 2 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../install/mysql/tables/llx_blockedlog.sql | 2 +- htdocs/langs/en_US/blockedlog.lang | 16 +++++ 7 files changed, 104 insertions(+), 22 deletions(-) create mode 100644 htdocs/blockedlog/ajax/block-info.php create mode 100644 htdocs/langs/en_US/blockedlog.lang diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 3c143b70b83..f77c6e9edd8 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -101,20 +101,20 @@ print $block_static->getSignature(); print '
    '.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).''; -print '
    '; -print ''; -print ''; -print ''; -print ''; -print '
    '; -print '
    '.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).''; + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print '
    '; diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index 29cd2a3f73b..95117bf2c28 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -74,7 +74,7 @@ print $langs->trans("FingerprintsDesc")."
    \n"; print '
    '; -echo ''; +echo ''; print ''; @@ -97,15 +97,16 @@ foreach($blocks as &$block) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; @@ -113,6 +114,54 @@ foreach($blocks as &$block) { print '
    '.dol_print_date($block->tms,'dayhour').''.$block->ref_object.''.$langs->trans('log'.$block->action).''.$block->getObject().''.$block->getObject().''.img_info($langs->trans('ShowDetails')).''.price($block->amounts).''.$block->getUser().''.$block->signature.''; - print $block->checkSignature() ? img_picto('OkCheckPaymentValidity', 'on') : img_picto($langs->trans('KoCheckPaymentValidity'), 'off'); - print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); - + print $block->checkSignature() ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off'); + if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { + print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); + } print '
    '; +?> + + +global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { + ?> '; @@ -304,13 +307,23 @@ foreach ($demoprofiles as $profilearray) //print $profilearray['lang']; if (! empty($profilearray['lang'])) $langs->load($profilearray['lang']); - $url=$_SERVER["PHP_SELF"].'?action=gotodemo&urlfrom='.urlencode($_SERVER["PHP_SELF"]); + $url=$_SERVER["PHP_SELF"].'?action=gotodemo'; $urlwithmod=$url.'&demochoice='.$profilearray['key']; // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'
    '; - $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]); + + $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]); //print $urlfrom; - if (! empty($profilearray['url'])) $urlwithmod=$profilearray['url']; + + if (! empty($profilearray['url'])) + { + $urlwithmod=$profilearray['url']; + $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'urlfrom='.urlencode($urlfrom); + if (! empty($profilearray['disablemodules'])) + { + $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'disablemodules='.$profilearray['disablemodules']; + } + } if (empty($profilearray['url'])) { @@ -348,7 +361,7 @@ foreach ($demoprofiles as $profilearray) print ''; - // Modules + // Modules (a profile you must choose modules) if (empty($profilearray['url'])) { print ''; - - print '

    '; - print '
    '; - print ''; - print ''; - print ''; - print ''; - print '
    '; } if ($tab == 'objects') @@ -483,6 +503,12 @@ elseif (! empty($module)) } + if ($tab == 'hooks') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'triggers') { require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; @@ -520,6 +546,12 @@ elseif (! empty($module)) print '
    '; } + if ($tab == 'widget') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'buildpackage') { if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) @@ -536,6 +568,16 @@ elseif (! empty($module)) print ''; } + if ($tab == 'dangerzone') + { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; + } + dol_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 844c444bad2..1306b0aef6a 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -20,8 +20,6 @@ * \file htdocs/modulebuilder/template/admin/about.php * \ingroup mymodule * \brief About page of module MyModule. - * - * MyModuleDescription. */ // Load Dolibarr environment @@ -84,8 +82,8 @@ echo $langs->trans("MyModuleAboutPage"); echo '
    '; -require_once '../core/modulebuilder/mymodule/core/modules/modMyModule.class.php'; -$tmpmodule = new MyModule($db); +dol_include_once('/mymodule/core/modules/modMyModule.class.php'); +$tmpmodule = new modMyModule($db); print $tmpmodule->getDescLong(); // Page end diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index b3f2cc87d73..421452f06e8 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -19,9 +19,7 @@ /** * \file htdocs/modulebuilder/template/admin/setup.php * \ingroup mymodule - * \brief Example module setup page. - * - * Put detailed description here. + * \brief MyModule setup page. */ // Load Dolibarr environment diff --git a/htdocs/modulebuilder/template/img/object_mytest.png b/htdocs/modulebuilder/template/img/object_mymodule.png similarity index 100% rename from htdocs/modulebuilder/template/img/object_mytest.png rename to htdocs/modulebuilder/template/img/object_mymodule.png From 73977639ac44215c6680110fc3d5f4babdf761fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 18:34:39 +0200 Subject: [PATCH 123/342] Update doc --- README-FR.md | 31 ++++++++++++++++++++++++++++--- README.md | 14 ++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README-FR.md b/README-FR.md index 4129e2b7452..8e6a2c5aac0 100644 --- a/README-FR.md +++ b/README-FR.md @@ -98,7 +98,10 @@ Voir fichier ChangeLog. - Rapports - Imports/Exports des données - Connectivité LDAP -- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...) +- Intégratn de ClickToDial +- Intégration RSS +- Intégation Skype +- Intégration de système de paiements (Paypal, Strip, Paybox...) - … ### Divers: @@ -114,17 +117,39 @@ Voir fichier ChangeLog. - Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers). - APIs. - Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) +- … + +### Extension + +Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com). -## CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE) +## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE Voici un liste de fonctionnalites pas encore gérées par Dolibarr: - Dolibarr ne contient pas de module de Gestion de la paie. - Les tâches du module de gestion de projets n'ont pas de dépendances entre elle. -- Dolibarr ne contient pas de Webmail. +- Dolibarr n'embarque pas de Webmail intégré nativement. - Dolibarr ne fait pas le café (pas encore). +## DOCUMENTATION + +Les documentations utilisateur, développeur et traducteur sont disponible sous forme de ressources de la communautés via la site [Wiki](https://wiki.dolibarr.org). + + +## CONTRIBUTING + +Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + + +## CREDITS + +Dolibarr est le résultat du travail de nombreux contributeurs depuis des années et utilise des librairies d'autres contributeurs. + +Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) + + ## ACTUALITES ET RESEAUX SOCIAUX Suivez le projet Dolibarr project sur les réseaux francophones diff --git a/README.md b/README.md index 29a7d4f9545..fbbbdddf665 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ You can use it as a standalone application or as a web application to be able to ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png) + ## LICENSE Dolibarr is released under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version (GPL-3+). @@ -20,6 +21,7 @@ See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) fil Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list. + ## INSTALLING ### Download @@ -67,6 +69,7 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) - Follow the installer instructions + ## UPGRADING - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. @@ -75,10 +78,12 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) *Note: migration process can safely be done multiple times by calling the page /install/index.php* + ## WHAT'S NEW See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. + ## FEATURES ### Main application/modules (all optional) @@ -120,7 +125,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - ClickToDial integration - RSS integration - Skype integration -- Payment platforms integration (PayBox, PayPal) +- Payment platforms integration (PayPal, Stripe, Paybox...) - … ### Other general features @@ -149,29 +154,34 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). + ## FUTURE These are features that Dolibarr does **not** yet fully support: - Tasks dependencies in projects - Payroll module -- Webmail +- No native embedded Webmail - Dolibarr can't do coffee (yet) + ## DOCUMENTATION Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org). + ## CONTRIBUTING See file [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + ## CREDITS Dolibarr is the work of many contributors over the years and uses some fine libraries. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. + ## NEWS AND SOCIAL NETWORKS Follow Dolibarr project on: From 71c0be20b972d0fd3efac0da60a2980d92bb83a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 10:30:32 +0200 Subject: [PATCH 124/342] Change data structure for bookkeeping v6 --- dev/translation/erp_comparison_translation.txt | 4 ++-- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 11 ++++++++++- .../mysql/tables/llx_accounting_bookkeeping.sql | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt index daa1bc79e92..fb96c17e3f9 100644 --- a/dev/translation/erp_comparison_translation.txt +++ b/dev/translation/erp_comparison_translation.txt @@ -8,7 +8,7 @@ Contact/address Contact person Partner/Contact (individual) Financial ?? Invoicing Income / Expense ?? Profit / Loss -Balance Net profit - +Balance ?? Net profit +Subledger account Subledger account ?? 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 bc09bf25ca3..46e3b698100 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 @@ -188,9 +188,18 @@ ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal --Update general ledger for FEC format & harmonization ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); +ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); + +--Subledger account +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; + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN label_compte varchar(255); ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_journal varchar(32); -ALTER TABLE llx_accounting_bookkeeping ADD COLUMN thirdparty_label varchar(255) AFTER code_tiers; + ALTER TABLE llx_accounting_bookkeeping ADD COLUMN label_operation varchar(255) AFTER label_compte; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_amount double AFTER sens; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_code varchar(255) AFTER multicurrency_amount; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 651fee6c339..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,8 +26,9 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - code_tiers varchar(32), -- FEC:CompAuxNum | account number of auxiliary account - thirdparty_label varchar(255), -- FEC:CompAuxLib | label of auxiliary account + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account + subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation From 333304934102fd3afec2ccf5e2d2ff6e400a7205 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 15 Jun 2017 11:11:49 +0200 Subject: [PATCH 125/342] Fix total aren't aligned --- htdocs/compta/facture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 9bb97d8ff0b..2d0208d0c2b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3524,7 +3524,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; - print ''; + print ''; print '' . price($total_prev_ht) . ''; print '' . price($total_prev_ttc) . ''; print ' '; @@ -3564,7 +3564,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; - print ''; + print ''; print '' . price($total_next_ht) . ''; print '' . price($total_next_ttc) . ''; print ' '; From 4009b1837cf1db251c8c5bab6fe185a1960be279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 11:17:02 +0200 Subject: [PATCH 126/342] Fix permissions --- htdocs/societe/class/api_contacts.class.php | 55 ++++++++++++--------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index ad82db3e008..58fe15cf282 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -22,14 +22,14 @@ use Luracast\Restler\RestException; /** * API class for contacts * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Contacts extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'lastname' @@ -56,13 +56,13 @@ class Contacts extends DolibarrApi * * @param int $id ID of contact * @return array|mixed data without useless information - * + * * @throws RestException */ function get($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } $result = $this->contact->fetch($id); @@ -81,9 +81,9 @@ class Contacts extends DolibarrApi /** * List contacts - * + * * Get a list of contacts - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -91,7 +91,7 @@ class Contacts extends DolibarrApi * @param string $thirdparty_ids Thirdparty ids to filter projects of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contact objects - * + * * @throws RestException */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -99,6 +99,11 @@ class Contacts extends DolibarrApi $obj_ret = array(); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) + { + throw new RestException(401, 'No permission to read contacts'); + } + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; @@ -111,7 +116,7 @@ class Contacts extends DolibarrApi $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { // We need this table joined to the select in order to filter by sale - $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')'; @@ -127,7 +132,7 @@ class Contacts extends DolibarrApi $sql .= " AND sc.fk_user = " . $search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -136,7 +141,7 @@ class Contacts extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) @@ -164,7 +169,7 @@ class Contacts extends DolibarrApi } $i++; } - } + } else { throw new RestException(503, 'Error when retreive contacts : ' . $sql); } @@ -184,7 +189,7 @@ class Contacts extends DolibarrApi function post($request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } // Check mandatory fields $result = $this->_validate($request_data); @@ -203,13 +208,13 @@ class Contacts extends DolibarrApi * Update contact * * @param int $id Id of contact to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } $result = $this->contact->fetch($id); @@ -244,7 +249,7 @@ class Contacts extends DolibarrApi function delete($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) { - throw new RestException(401); + throw new RestException(401, 'No permission to delete contacts'); } $result = $this->contact->fetch($id); if (!$result) @@ -273,23 +278,29 @@ class Contacts extends DolibarrApi //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); //} - + if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); if (!isset($request_data["password"])) throw new RestException(400, "password field missing"); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } + if (!DolibarrApiAccess::$user->rights->user->user->creer) { + throw new RestException(401, 'No permission to create user'); + } + $contact = new Contact($this->db); $contact->fetch($id); if ($contact->id <= 0) { throw new RestException(404, 'Contact not found'); } - + if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } + // Check mandatory fields $login = $request_data["login"]; $password = $request_data["password"]; @@ -300,10 +311,10 @@ class Contacts extends DolibarrApi } // password parameter not used in create_from_contact $useraccount->setPassword($useraccount,$password); - + return $result; } - + /** * Get categories for a contact * @@ -324,7 +335,7 @@ class Contacts extends DolibarrApi /** * Validate fields before create or update object - * + * * @param array|null $data Data to validate * @return array * @throws RestException From 097be322a60c9365f12dd364ac1bd878f15d6e55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 19:29:00 +0200 Subject: [PATCH 127/342] Modify code to match new v6 structure. --- htdocs/accountancy/admin/categories_list.php | 22 +- htdocs/accountancy/admin/defaultaccounts.php | 94 +++++-- htdocs/accountancy/admin/journals_list.php | 27 +- htdocs/accountancy/bookkeeping/card.php | 46 ++-- htdocs/accountancy/bookkeeping/list.php | 38 +-- .../accountancy/bookkeeping/listbyaccount.php | 37 ++- htdocs/accountancy/bookkeeping/listbyyear.php | 58 +++-- .../class/accountancycategory.class.php | 20 +- .../class/accountancyexport.class.php | 34 +-- .../class/accountingjournal.class.php | 16 +- .../accountancy/class/bookkeeping.class.php | 234 +++++++++++------- htdocs/accountancy/index.php | 2 - htdocs/accountancy/journal/bankjournal.php | 28 +-- .../journal/expensereportsjournal.php | 15 +- .../accountancy/journal/purchasesjournal.php | 21 +- htdocs/accountancy/journal/sellsjournal.php | 24 +- htdocs/core/modules/modAccounting.class.php | 12 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/langs/en_US/accountancy.lang | 24 +- htdocs/langs/en_US/compta.lang | 6 +- 20 files changed, 433 insertions(+), 326 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 1bf9a693efd..b10015baa6c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -151,7 +151,7 @@ $sourceList=array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -479,7 +479,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -506,7 +506,7 @@ if ($id) print '
    '; print ''; print ''; - + print ''; // Form to add a new line @@ -546,9 +546,9 @@ if ($id) if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - + if ($valuetoshow != '') { print ''; print ''; - + // Title of lines print ''; foreach ($fieldlist as $field => $value) @@ -700,7 +700,7 @@ if ($id) if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } // Affiche nom du champ if ($showfield) @@ -754,7 +754,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index aaf98a0fa8b..ef39252ff87 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -50,23 +50,26 @@ if (! empty($user->rights->accountancy->chartofaccount)) $action = GETPOST('action', 'alpha'); +$list_account_main = array ( + 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'ACCOUNTING_ACCOUNT_CUSTOMER', +); + $list_account = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_PAY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_SUSPENSE', - 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', - 'DONATION_ACCOUNTINGACCOUNT', - 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', - 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', - 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_PAY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_SUSPENSE', + 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', + 'DONATION_ACCOUNTINGACCOUNT', + 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', + 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', + 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' ); @@ -93,15 +96,23 @@ if (GETPOST('change_chart')) if ($action == 'update') { $error = 0; - - foreach ( $list_account as $constname ) { + + foreach ( $list_account_main as $constname ) { $constvalue = GETPOST($constname, 'alpha'); - + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } - + + foreach ( $list_account as $constname ) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -114,11 +125,11 @@ if ($action == 'update') { * View */ -llxHeader(); - $form = new Form($db); $formaccounting = new FormAccounting($db); +llxHeader(); + $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); @@ -129,18 +140,47 @@ print ''; print ''; print ''; -// Define Chart of accounts + +// Define main accounts for thirdparty print '
    '; @@ -617,7 +617,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -632,9 +632,9 @@ if ($id) foreach ($fieldlist as $field => $value) { $showfield=1; // By defaut - + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - + if ($showfield) { if ($value == 'country') @@ -661,7 +661,7 @@ if ($id) } print '
    '; -foreach ( $list_account as $key ) { - +foreach ($list_account_main as $key) { + + print ''; + // Param + $label = $langs->trans($key); + $keydesc=$key.'_Desc'; + + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; +} + + +print "
    '; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force align=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
    \n"; + + +print '
    '; + +// Define default accounts + +print ''; + +foreach ($list_account as $key) { + print ''; // Param $label = $langs->trans($key); - print ''; + print ''; // Value - print ''; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 68d5e5af5c0..dd1982d057c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -127,7 +127,7 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort, // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); - // Must match ids defined into eldy.lib.php + // Must match ids defined into eldy.lib.php $sourceList = array( '1' => $langs->trans('AccountingJournalType1'), '2' => $langs->trans('AccountingJournalType2'), @@ -142,7 +142,7 @@ $elementList = array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -371,13 +371,6 @@ if ($id) print load_fiche_titre($titre,$linkback,$titlepicto); -if (empty($id)) -{ - print $langs->trans("DictionaryDesc"); - print " ".$langs->trans("OnlyActiveElementsAreShown")."
    \n"; -} -print "
    \n"; - // Confirmation de la suppression de la ligne if ($action == 'delete') @@ -400,7 +393,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -427,7 +420,7 @@ if ($id) print ''; print ''; print ''; - + print '
    ' . $label . '' . $label . ''; // Do not force align=right, or it align also the content of the select box + print ''; // Do not force align=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
    '; // Form to add a new line @@ -453,7 +446,7 @@ if ($id) $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } - + if ($valuetoshow != '') { print ''; print ''; - + if ($num) { // Lines with values @@ -621,7 +614,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; @@ -682,10 +675,10 @@ if ($id) else print ''; print ''; - + print ''; } - + print "\n"; $i++; } diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4443fb959b2..3ef418e2e20 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -48,9 +48,9 @@ $piece_num = GETPOST("piece_num"); $mesg = ''; $account_number = GETPOST('account_number'); -$code_tiers = GETPOST('code_tiers'); -if ($code_tiers == - 1) { - $code_tiers = null; +$subledger_account = GETPOST('subledger_account'); +if ($subledger_account == - 1) { + $subledger_account = null; } $label_compte = GETPOST('label_compte'); $debit = price2num(GETPOST('debit')); @@ -82,7 +82,7 @@ if ($action == "confirm_update") { setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -119,7 +119,7 @@ else if ($action == "add") { $book = new BookKeeping($db); $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -171,7 +171,7 @@ else if ($action == "confirm_delete") { else if ($action == "confirm_create") { $error = 0; - + $book = new BookKeeping($db); if (! GETPOST('next_num_mvt')) @@ -179,7 +179,7 @@ else if ($action == "confirm_create") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); $error++; } - + if (! $error) { $book->label_compte = ''; @@ -192,9 +192,9 @@ else if ($action == "confirm_create") { $book->code_journal = GETPOST('code_journal'); $book->fk_doc = 0; $book->fk_docdet = 0; - + $book->montant = 0; - + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -289,9 +289,9 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . ''); dol_fiche_head(); - + print '
    '; - + print '
    '; @@ -522,7 +515,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -582,7 +575,7 @@ if ($id) } print '
     
    '; print ''; @@ -306,12 +306,12 @@ if ($action == 'create') { print ''; print ''; - print ''; - + print ''; print ''; print ''; @@ -335,13 +335,13 @@ if ($action == 'create') { print ''; print ''; print '
    ' . $langs->trans("Codejournal") . ''; + print ''; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch('',$book->code_journal); - print $accountingjournal->getNomUrl(0,1,1,'',1); + print $accountingjournal->getNomUrl(0,1,1,'',1); print '
    ' . $langs->trans("Docref") . '' . $book->doc_ref . '' . $typelabel . '
    '; - + print ''; - + dol_fiche_end(); print '
    '; - + $result = $book->fetch_all_per_mvt($piece_num); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -358,7 +358,7 @@ if ($action == 'create') { print '' . "\n"; $var=False; - + print ""; if (count($book->linesmvt) > 0) { @@ -368,7 +368,7 @@ if ($action == 'create') { print ''; print_liste_field_titre($langs->trans("AccountAccountingShort")); - print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("subledger_account")); print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); @@ -390,7 +390,7 @@ if ($action == 'create') { print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; @@ -403,7 +403,7 @@ if ($action == 'create') { print ''; } else { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -423,7 +423,7 @@ if ($action == 'create') { print "\n"; } - if ($total_debit != $total_credit) + if ($total_debit != $total_credit) { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings'); } @@ -434,7 +434,7 @@ if ($action == 'create') { print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 26ab0fa4c4d..b6685248ca7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -171,15 +171,15 @@ if (! empty($search_accountancy_code_end)) { $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; } if (! empty($search_accountancy_aux_code)) { - $filter['t.code_tiers'] = $search_accountancy_aux_code; + $filter['t.subledger_account'] = $search_accountancy_aux_code; $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; } if (! empty($search_accountancy_aux_code_start)) { - $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; } if (! empty($search_accountancy_aux_code_end)) { - $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; } if (! empty($search_mvt_label)) { @@ -223,7 +223,7 @@ if ($action == 'delbookkeepingyearconfirm') { $deljournal=0; } - if (! empty($delyear) || ! empty($deljournal)) + if (! empty($delyear) || ! empty($deljournal)) { $result = $object->deleteByYearAndJournal($delyear,$deljournal); if ($result < 0) { @@ -365,7 +365,7 @@ $groupby = ' ' . "\n"; +print '
    '; - print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); print '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '
    '; - print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); print '
    '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch('',$line->code_journal); - print ''; + $result = $accountingjournal->fetch('',$line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal); + print ''; print '\n"; print ''; -$var = True; $total_debit = 0; $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty foreach ( $object->lines as $line ) { @@ -272,10 +271,10 @@ foreach ( $object->lines as $line ) { $accountg = length_accountg($line->numero_compte); //if (empty($accountg)) $accountg = '-'; - + // Is it a break ? if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - + // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''; @@ -283,7 +282,7 @@ foreach ( $object->lines as $line ) { print "\n"; print ''; } - + // Show the break account $colspan = 9; print ""; @@ -292,7 +291,7 @@ foreach ( $object->lines as $line ) { else print ''.$langs->trans("Unknown").''; print ''; print ''; - + $displayed_account_number = $accountg; //if (empty($displayed_account_number)) $displayed_account_number='-'; $sous_total_debit = 0; @@ -303,24 +302,24 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - + // TODO Add a link according to doc_type and fk_doc print ''; - + // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->code_tiers)) == 0 ? '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print "\n"; @@ -355,6 +354,4 @@ print "
    '; +print '
    '; print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); -print '
    '; +print '
    '; +print '
    '; print $langs->trans('to') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); +print '
    '; print '
    '; +print '
    '; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); -print '
    '; +print '
    '; +print '
    '; print $langs->trans('to'); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print '
    '; print '
    '; +print '
    '; print $langs->trans('From'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); -print '
    '; +print '
    '; +print '
    '; print $langs->trans('to'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +print '
    '; print '
    '; print ''; @@ -414,7 +423,7 @@ print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); @@ -440,14 +449,15 @@ foreach ($object->lines as $line ) { print '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) : ''). '' . ($line->credit ? price($line->credit) : '') . '' . $accountingjournal->getNomUrl(0,0,0,'',0) . '' . $journaltoshow . ''; print '' . img_edit() . ' '; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index b9a5526a7ab..7d0ba2280ea 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -75,10 +75,6 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_ $object = new BookKeeping($db); -$formaccounting = new FormAccounting($db); -$formother = new FormOther($db); -$form = new Form($db); - $options = ''; $filter = array (); @@ -126,7 +122,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; @@ -156,6 +152,10 @@ if ($action == 'delmouvconfirm') { * View */ +$formaccounting = new FormAccounting($db); +$formother = new FormOther($db); +$form = new Form($db); + $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); llxHeader('', $title_page); @@ -217,7 +217,7 @@ if ( preg_match('/^asc/i', $sortorder) ) else $sortorder = "desc"; -print '
    ' . "\n"; +print ''; @@ -257,13 +257,12 @@ print "
    '.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).' 
     '.$line->piece_num.'' . dol_print_date($line->doc_date, 'day') . ''; //if ($line->doc_type == 'supplier_invoice') //if ($line->doc_type == 'customer_invoice') print $line->doc_ref; print '' . $line->label_compte . '' . $line->label_compte . '
    (' . length_accounta($line->code_tiers) . ')
    ' . $line->label_compte . '' . $line->label_compte . '
    (' . length_accounta($line->subledger_account) . ')
    ' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) :''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->code_journal . ''; - print '' . img_edit() . ' '; + print '' . img_edit() . ' '; print '' . img_delete() . ''; print '
    "; print '
    '; llxFooter(); - - $db->close(); diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index f4134a2e028..e7e51ae67e0 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -52,14 +52,14 @@ $search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha'); if ($search_numero_compte_end == - 1) { $search_numero_compte_end = ''; } -$search_code_tiers = GETPOST('search_code_tiers', 'alpha'); -$search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha'); -if ($search_code_tiers_start == - 1) { - $search_code_tiers_start = ''; +$search_subledger_account = GETPOST('search_subledger_account', 'alpha'); +$search_subledger_account_start = GETPOST('search_subledger_account_start', 'alpha'); +if ($search_subledger_account_start == - 1) { + $search_subledger_account_start = ''; } -$search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha'); -if ($search_code_tiers_end == - 1) { - $search_code_tiers_end = ''; +$search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha'); +if ($search_subledger_account_end == - 1) { + $search_subledger_account_end = ''; } $search_label_compte = GETPOST('search_label_compte', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha'); @@ -81,15 +81,18 @@ if ($sortfield == "") $offset = $limit * $page; -llxHeader('', $langs->trans("Bookkeeping")); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_type = ""; $search_doc_date = ""; $search_doc_ref = ""; $search_numero_compte = ""; - $search_code_tiers = ""; + $search_subledger_account = ""; $search_label_compte = ""; $search_sens = ""; $search_code_journal = ""; @@ -129,17 +132,17 @@ if (! empty($search_numero_compte_end)) { $filter['t.numero_compte<='] = $search_numero_compte_end; $options .= '&search_numero_compte_end=' . $search_numero_compte_end; } -if (! empty($search_code_tiers)) { - $filter['t.code_tiers'] = $search_code_tiers; - $options .= '&search_code_tiers=' . $search_code_tiers; +if (! empty($search_subledger_account)) { + $filter['t.subledger_account'] = $search_subledger_account; + $options .= '&search_subledger_account=' . $search_subledger_account; } -if (! empty($search_code_tiers_start)) { - $filter['t.code_tiers>='] = $search_code_tiers_start; - $options .= '&search_code_tiers_start=' . $search_code_tiers_start; +if (! empty($search_subledger_account_start)) { + $filter['t.subledger_account>='] = $search_subledger_account_start; + $options .= '&search_subledger_account_start=' . $search_subledger_account_start; } -if (! empty($search_code_tiers_end)) { - $filter['t.code_tiers<='] = $search_code_tiers_end; - $options .= '&search_code_tiers_end=' . $search_code_tiers_end; +if (! empty($search_subledger_account_end)) { + $filter['t.subledger_account<='] = $search_subledger_account_end; + $options .= '&search_subledger_account_end=' . $search_subledger_account_end; } if (! empty($search_label_compte)) { $filter['t.label_compte'] = $search_label_compte; @@ -154,10 +157,13 @@ if (! empty($search_code_journal)) { $options .= '&search_code_journal=' . $search_code_journal; } + /* - * Mode List + * Actions */ +llxHeader('', $langs->trans("Bookkeeping")); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); @@ -188,9 +194,9 @@ print $formaccounting->select_account($search_numero_compte_end, 'search_numero_ print ''; print '
    '; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); +print $formaccounting->select_auxaccount($search_subledger_account_start, 'search_subledger_account_start', 1); print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); +print $formaccounting->select_auxaccount($search_subledger_account_end, 'search_subledger_account_end', 1); print '
    '; print ""; @@ -200,7 +206,7 @@ print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_t print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); @@ -232,7 +238,7 @@ print ''; print ''; print ''; print "\n"; -$var = True; - foreach ( $object->lines as $line ) { print ''; @@ -274,7 +278,7 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 139498bd0b2..e4e3017ab15 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -138,7 +138,7 @@ class AccountancyCategory */ public function getAccountsWithNoCategory($id) { global $conf; - + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; @@ -147,9 +147,9 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; - + $this->lines_CptBk = array (); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -159,17 +159,17 @@ class AccountancyCategory $this->lines_cptbk[] = $obj; } } - + return $num; } else { $this->error = "Error " . $this->db->lasterror(); $this->errors[] = $this->error; dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); - + return - 1; } } - + /** * Function to add an accounting account in an accounting category * @@ -191,7 +191,7 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $this->db->begin(); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -201,9 +201,9 @@ class AccountancyCategory return -1; } - while ( $obj = $this->db->fetch_object($resql)) + while ( $obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + if (array_key_exists(length_accountg($obj->account_number), $cpts)) { $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; @@ -332,7 +332,7 @@ class AccountancyCategory } /** - * Function to show result of an accounting account from the general ledger with a sens and a period + * Function to show result of an accounting account from the ledger with a direction and a period * * @param int $cpt Id accounting account * @param string $month Specifig month - Can be empty diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1af9e5d1a6b..dc2b3195ee3 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -172,7 +172,7 @@ class AccountancyExport print $date . $this->separator; print $line->doc_ref . $this->separator; print length_accountg($line->numero_compte) . $this->separator; - print length_accounta($line->code_tiers) . $this->separator; + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print $line->code_journal . $this->separator; @@ -195,7 +195,7 @@ class AccountancyExport print $date . $separator; print $line->code_journal . $separator; print length_accountg($line->numero_compte) . $separator; - print length_accounta($line->code_tiers) . $separator; + print length_accounta($line->subledger_account) . $separator; print $line->sens . $separator; print price($line->montant) . $separator; print $line->label_compte . $separator; @@ -254,7 +254,7 @@ class AccountancyExport print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print 'E' . $this->separator; - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; print $this->end_line; } } @@ -274,7 +274,7 @@ class AccountancyExport $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $this->separator; - if (empty($line->code_tiers)) { + if (empty($line->subledger_account)) { print 'G' . $this->separator; print length_accounta($line->numero_compte) . $this->separator; } else { @@ -284,7 +284,7 @@ class AccountancyExport if (substr($line->numero_compte, 0, 3) == '401') { print 'F' . $this->separator; } - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; } print price($line->debit) . $this->separator; @@ -307,11 +307,11 @@ class AccountancyExport $this->end_line ="\r\n"; $i = 1; - $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd + $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['num_ecriture'] = str_pad($i, 5); @@ -349,8 +349,8 @@ class AccountancyExport $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['type_ligne'] = 'M'; @@ -436,19 +436,21 @@ class AccountancyExport print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print $date . $this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; - - if (empty($line->code_tiers)) { + + if (empty($line->subledger_account)) { print length_accountg($line->numero_compte) . $this->separator; } else { + // FIXME Because the subledger_account is already an accounting account, does we really need + // to concat 4011 or 401 to it ? if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') { - print '411' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') { - print '401' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } } - - print length_accounta($line->code_tiers) . $this->separator; + + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print price($line->montant).$this->separator; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 168934ee5a5..f47715ace58 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -46,7 +46,7 @@ class AccountingJournal extends CommonObject function __construct($db) { $this->db = $db; } - + /** * Load an object from database * @@ -62,9 +62,9 @@ class AccountingJournal extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE"; if ($rowid) { - $sql .= " rowid = '" . $rowid . "'"; + $sql .= " rowid = " . (int) $rowid; } elseif ($journal_code) { - $sql .= " code = '" . $journal_code . "'"; + $sql .= " code = '" . $this->db->escape($journal_code) . "'"; } dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); @@ -96,7 +96,7 @@ class AccountingJournal extends CommonObject } return -1; } - + /** * Return clicable name (with picto eventually) * @@ -147,7 +147,7 @@ class AccountingJournal extends CommonObject { $linkstart = ''; $linkclose = ''; - $linkend = ''; + $linkend = ''; } $label_link = $this->code; @@ -158,7 +158,7 @@ class AccountingJournal extends CommonObject if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; } - + /** * Retourne le libelle du statut d'un user (actif, inactif) * @@ -169,7 +169,7 @@ class AccountingJournal extends CommonObject { return $this->LibType($this->nature,$mode); } - + /** * Return type of an accounting journal * @@ -182,7 +182,7 @@ class AccountingJournal extends CommonObject global $langs; $langs->load("accountancy"); - + if ($mode == 0) { $prefix=''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0fc4a936117..f7c1b4d8b89 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -20,14 +20,14 @@ /** * \file htdocs/accountancy/class/bookkeeping.class.php * \ingroup Advanced accountancy - * \brief File of class to manage general ledger + * \brief File of class to manage Ledger (General Ledger and Subledger) */ // Class require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; /** - * Class to manage general ledger + * Class to manage Ledger (General Ledger and Subledger) */ class BookKeeping extends CommonObject { @@ -53,7 +53,7 @@ class BookKeeping extends CommonObject * * @var string Name of table without prefix where object is stored */ - public $table_element = 'accounting_bookkeeping'; + public $table_element = 'accounting_bookkeeping'; public $entity = 1; @@ -75,7 +75,9 @@ class BookKeeping extends CommonObject public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; @@ -127,8 +129,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -165,7 +173,7 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters if (empty($this->numero_compte) || $this->numero_compte == '-1') { @@ -176,7 +184,7 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); } return -1; @@ -191,7 +199,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; $sql .= " AND fk_doc = " . $this->fk_doc; - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -199,12 +207,12 @@ class BookKeeping extends CommonObject if ($resql) { $row = $this->db->fetch_object($resql); - if ($row->nb == 0) + if ($row->nb == 0) { // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' + $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -244,7 +252,9 @@ class BookKeeping extends CommonObject $sql .= ", doc_ref"; $sql .= ", fk_doc"; $sql .= ", fk_docdet"; - $sql .= ", code_tiers"; + $sql .= ", thirdparty_code"; + $sql .= ", subledger_account"; + $sql .= ", subledger_label"; $sql .= ", numero_compte"; $sql .= ", label_compte"; $sql .= ", debit"; @@ -256,25 +266,27 @@ class BookKeeping extends CommonObject $sql .= ", code_journal"; $sql .= ", journal_label"; $sql .= ", piece_num"; - $sql .= ', entity'; + $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($this->doc_date) . "'"; - $sql .= ",'" . $this->doc_type . "'"; - $sql .= ",'" . $this->doc_ref . "'"; + $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; + $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->code_tiers . "'"; - $sql .= ",'" . $this->numero_compte . "'"; + $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; + $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; - $sql .= ",'" . $this->sens . "'"; - $sql .= ",'" . $this->fk_user_author . "'"; + $sql .= ",'" . $this->db->escape($this->sens) . "'"; + $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'"; - $sql .= ",'" . $this->code_journal . "'"; - $sql .= ",'" . $this->journal_label . "'"; - $sql .= "," . $this->piece_num; + $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; + $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; + $sql .= "," . $this->db->escape($this->piece_num); $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; @@ -282,7 +294,7 @@ class BookKeeping extends CommonObject $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -312,11 +324,11 @@ class BookKeeping extends CommonObject } if (! $error) { - + 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++; @@ -360,8 +372,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -409,7 +427,9 @@ class BookKeeping extends CommonObject $sql .= 'doc_ref,'; $sql .= 'fk_doc,'; $sql .= 'fk_docdet,'; - $sql .= 'code_tiers,'; + $sql .= 'thirdparty,'; + $sql .= 'subledger_account,'; + $sql .= 'subledger_label,'; $sql .= 'numero_compte,'; $sql .= 'label_compte,'; $sql .= 'debit,'; @@ -428,7 +448,9 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; - $sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; + $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; @@ -458,7 +480,7 @@ class BookKeeping extends CommonObject 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++; @@ -483,7 +505,7 @@ class BookKeeping extends CommonObject * * @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) { @@ -498,7 +520,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -532,7 +556,9 @@ class BookKeeping extends CommonObject $this->doc_ref = $obj->doc_ref; $this->fk_doc = $obj->fk_doc; $this->fk_docdet = $obj->fk_docdet; - $this->code_tiers = $obj->code_tiers; + $this->thirdparty_code = $obj->thirdparty_code; + $this->subledger_account = $obj->subledger_account; + $this->subledger_label = $obj->subledger_label; $this->numero_compte = $obj->numero_compte; $this->label_compte = $obj->label_compte; $this->debit = $obj->debit; @@ -555,11 +581,11 @@ class BookKeeping extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -569,7 +595,7 @@ class BookKeeping extends CommonObject * @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 fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -584,7 +610,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -604,11 +632,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } elseif ($key == 't.label_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; @@ -630,7 +658,7 @@ class BookKeeping extends CommonObject } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); - } + } $this->lines = array (); $resql = $this->db->query($sql); @@ -647,7 +675,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -672,8 +702,8 @@ class BookKeeping extends CommonObject return - 1; } } - - + + /** * Load object in memory from the database * @@ -683,7 +713,7 @@ class BookKeeping extends CommonObject * @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') { @@ -698,7 +728,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -719,11 +751,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -758,7 +790,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -814,11 +848,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -834,7 +868,7 @@ class BookKeeping extends CommonObject $sql .= ' GROUP BY t.numero_compte'; if (! empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); @@ -869,7 +903,7 @@ class BookKeeping extends 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 */ public function update(User $user, $notrigger = false) { @@ -890,8 +924,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -937,7 +977,9 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; - $sql .= ' code_tiers = ' . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ','; + $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ','; + $sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ','; + $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; @@ -963,7 +1005,7 @@ class BookKeeping extends CommonObject 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} @@ -987,7 +1029,7 @@ class BookKeeping extends CommonObject * * @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) { @@ -1070,7 +1112,7 @@ class BookKeeping extends CommonObject function deleteByYearAndJournal($delyear='', $journal='') { global $conf; - if (empty($delyear) && empty($journal)) + if (empty($delyear) && empty($journal)) { return -1; } @@ -1137,7 +1179,7 @@ class BookKeeping extends CommonObject * 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) { @@ -1196,8 +1238,10 @@ class BookKeeping extends CommonObject $this->doc_ref = ''; $this->fk_doc = ''; $this->fk_docdet = ''; - $this->code_tiers = ''; - $this->numero_compte = ''; + $this->thirdparty_code = 'CU001'; + $this->subledger_account = '410CU001'; + $this->subledger_label = 'My customer company'; + $this->numero_compte = '410'; $this->label_compte = ''; $this->debit = 99.9; $this->credit = ''; @@ -1205,8 +1249,8 @@ class BookKeeping extends CommonObject $this->sens = ''; $this->fk_user_author = $user->id; $this->import_key = ''; - $this->code_journal = ''; - $this->journal_label = ''; + $this->code_journal = 'VT'; + $this->journal_label = 'Journal de vente'; $this->piece_num = ''; } @@ -1249,7 +1293,7 @@ class BookKeeping extends CommonObject * * @return string Next numero to use */ - public function getNextNumMvt() + public function getNextNumMvt() { global $conf; @@ -1281,7 +1325,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1303,7 +1347,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1335,7 +1381,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1359,7 +1405,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1380,9 +1428,9 @@ class BookKeeping extends CommonObject return - 1; } } - - - + + + /** * Return list of accounts with label by chart of accounts * @@ -1397,11 +1445,11 @@ class BookKeeping extends CommonObject */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; - + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - + $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; @@ -1410,43 +1458,43 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; - + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - + if (! $resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); return - 1; } - + $out = ajax_combobox($htmlname, $event); - + $options = array(); $selected = null; - + while ($obj = $this->db->fetch_object($resql)) { $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; - + if ($select_in == 1) { $select_value_in = $obj->account_number; } if ($select_out == 1) { $select_value_out = $obj->account_number; } - + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $select_value_in) { $selected = $select_value_out; } - + $options[$select_value_out] = $label; } - + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); $this->db->free($resql); return $out; @@ -1454,7 +1502,7 @@ class BookKeeping extends CommonObject /** - * Description of a root accounting account + * Description of a root accounting account * * @param string $account Accounting account * @return string Root account @@ -1470,7 +1518,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; @@ -1480,7 +1528,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } return $obj->label; @@ -1492,8 +1540,8 @@ class BookKeeping extends CommonObject return -1; } } - - + + /** * Description of accounting account * @@ -1519,7 +1567,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } if(empty($obj->category)){ return $obj->label; @@ -1532,7 +1580,7 @@ class BookKeeping extends CommonObject return -1; } } - + } @@ -1547,7 +1595,9 @@ class BookKeepingLine public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 02549be2a94..bf3e80fe866 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -63,8 +63,6 @@ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy' $step = 0; -print "
    \n"; - print $langs->trans("AccountancyAreaDescIntro")."
    \n"; print "
    \n";print "
    \n"; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9eae2072243..6c391531662 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -364,7 +364,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if ($tabtype[$key] == 'payment') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; @@ -378,7 +378,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice } } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; @@ -392,7 +392,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice } } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; @@ -405,13 +405,13 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } @@ -458,7 +458,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice $sqlmid = 'SELECT fac.facnumber'; @@ -472,7 +472,7 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->facnumber; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; @@ -486,23 +486,23 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? @@ -758,7 +758,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
    '; + print '
    '; print ''; print '
    '; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 557218a0ee6..759dca8dae9 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -62,7 +62,7 @@ if ($user->societe_id > 0) /* * Actions */ - + // Get informations of journal $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); @@ -175,7 +175,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->montant = $mt; @@ -222,7 +223,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -267,7 +269,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -462,7 +465,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
    '; + print '
    '; print ''; print '
    '; @@ -576,7 +579,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
    "; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 3729860d29d..506c5517821 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -131,7 +131,7 @@ if ($result) { // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -214,9 +214,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? $mt : 0; @@ -261,7 +262,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -306,7 +308,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -479,7 +482,7 @@ $companystatic = new Fournisseur($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; } @@ -518,7 +521,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
    '; + print '
    '; print ''; print '
    '; @@ -635,7 +638,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
    "; + print ""; // print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0d2e7ac19cc..8506b2a480b 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -231,10 +231,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; - // $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -277,7 +277,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; @@ -321,7 +322,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->montant = $mt; @@ -373,7 +375,7 @@ if ($action == 'writebookkeeping') { { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - + $action=''; } @@ -416,7 +418,7 @@ $form = new Form($db); print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep; print $val["ref"]; print "\n"; } @@ -469,7 +471,7 @@ $form = new Form($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -535,7 +537,7 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ - print '
    '; + print '
    '; print ''; print '
    '; @@ -602,7 +604,7 @@ if (empty($action) || $action == 'view') { // print "
    '; - print ""; + print ""; print ""; print ""; print ""; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 1780da06456..af0874b8c30 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -224,7 +224,7 @@ class modAccounting extends DolibarrModules $this->rights[$r][4] = 'chartofaccount'; $this->rights[$r][5] = ''; $r++; - + $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; @@ -242,9 +242,9 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = 'dispatch_advanced'; $r++; */ - + $this->rights[$r][0] = 50411; - $this->rights[$r][1] = 'Read operations in General Ledger'; + $this->rights[$r][1] = 'Read operations in Ledger'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -252,7 +252,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50412; - $this->rights[$r][1] = 'Write/Edit operations in General Ledger'; + $this->rights[$r][1] = 'Write/Edit operations in Ledger'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -260,7 +260,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50420; - $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, general ledger)'; + $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'comptarapport'; @@ -279,7 +279,7 @@ class modAccounting extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + // Exports //-------- $r=0; 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 46e3b698100..e5ee1866567 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 @@ -187,6 +187,7 @@ UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM ll 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 + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 5f3d4eef2da..8ff65371fa5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -49,8 +49,8 @@ AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. F 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. -AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this, use the menu entry %s. -AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into menu %s, and click into button %s. +AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s. +AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the Ledger. For this, go into menu %s, and click into button %s. AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and generate reports and exports. AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. @@ -61,6 +61,8 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account +SubledgerAccount=Subledger Account +subledger_account=Subledger Account ShowAccountingAccount=Show accounting account ShowAccountingJournal=Show accounting journal AccountAccountingSuggest=Accounting account suggested @@ -77,8 +79,8 @@ SuppliersVentilation=Supplier invoice binding ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction -WriteBookKeeping=Journalize transactions in General Ledger -Bookkeeping=General ledger +WriteBookKeeping=Journalize transactions in Ledger +Bookkeeping=Ledger AccountBalance=Account balance CAHTF=Total purchase supplier before tax @@ -141,16 +143,16 @@ TransactionNumShort=Num. transaction AccountingCategory=Accounting account groups GroupByAccountAccounting=Group by accounting account NotMatch=Not Set -DeleteMvt=Delete general ledger lines +DeleteMvt=Delete Ledger lines DelYear=Year to delete DelJournal=Journal to delete -ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specific journal. At least one criteria is required. -ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger -DelBookKeeping=Delete record of the general ledger +ConfirmDeleteMvt=This will delete all lines of the Ledger for year and/or from a specific journal. At least one criteria is required. +ConfirmDeleteMvtPartial=This will delete the selected line(s) of the Ledger +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 General Ledger. +DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services 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 @@ -192,7 +194,7 @@ 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 FicheVentilation=Binding card -GeneralLedgerIsWritten=Transactions are written in the general ledger +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. NoNewRecordSaved=No new record dispatched ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account @@ -261,4 +263,4 @@ NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind -WarningReportNotReliable=Warning, this report is not based on the General Ledger, so does not contains transaction modified manualy in the General ledger. It will be replaced by a more complete report in a next version. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c85a2671c21..6f8a1b5e301 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -190,8 +190,10 @@ AccountancyJournal=Accountancy code journal ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - VAT on sales (used if not defined on VAT dictionary setup) 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 by default for customer third parties (used if not defined on third party card) -ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account by default for supplier third parties (used if not defined on third party card) +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_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 CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month From f39fb5187a4f490378d672a88794f254af27c055 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 20:27:40 +0200 Subject: [PATCH 128/342] Fix component to select journal --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 6 +++--- htdocs/compta/bank/card.php | 4 ++-- htdocs/core/class/html.formaccounting.class.php | 17 +++++++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3ef418e2e20..f40bfda856f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -256,7 +256,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b6685248ca7..cd93b1142f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -322,7 +322,7 @@ if ($action == 'delbookkeepingyear') { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); $form_question['delyear'] = array ( 'name' => 'delyear', @@ -333,9 +333,9 @@ if ($action == 'delbookkeepingyear') { ); $form_question['deljournal'] = array ( 'name' => 'deljournal', - 'type' => 'select', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component 'label' => $langs->trans('DelJournal'), - 'values' => $journal_array, + 'value' => $journal_array, 'default' => $deljournal ); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 06918ff2846..1f55698d13f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -524,7 +524,7 @@ if ($action == 'create') { print ''; print ''; } @@ -982,7 +982,7 @@ else { print ''; print ''; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 2d444c1aefe..e37e1690ca2 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -54,15 +54,14 @@ class FormAccounting extends Form * @param string $htmlname Name of field in html form * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) * @param int $showempty Add an empty field - * @param array $event Event options * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code * @param int $select_out Set value returned by select. 0=rowid (default), 1=code * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * + * @param int $disabledajaxcombo Disable ajax combo box. * @return string String with HTML select */ - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { global $conf; @@ -92,8 +91,6 @@ class FormAccounting extends Form return -1; } - $out = ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { @@ -125,7 +122,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1)); return $out; } @@ -204,9 +201,9 @@ class FormAccounting extends Form { dol_print_error($db,$db->lasterror()); } - - $out .= ajax_combobox($htmlname, $event); - + + $out .= ajax_combobox($htmlname, array()); + print $out; } @@ -260,7 +257,7 @@ class FormAccounting extends Form require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $out = ''; - + $options = array(); if ($usecache && ! empty($this->options_cache[$usecache])) { From 78d5520741746af4874f0a628d48996a83e95094 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:23:35 +0200 Subject: [PATCH 129/342] Fix: missing _cleanObjectDatas function --- htdocs/admin/agenda.php | 3 +- htdocs/admin/agenda_other.php | 1 + .../action/class/api_agendaevents.class.php | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 22679ca697b..a30ebad4703 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -33,6 +33,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); @@ -172,7 +173,7 @@ if (! empty($triggers)) if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; - + print ''; print ''; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 44ec3ade889..31bcf1077e6 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -36,6 +36,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index f32c721a826..40737a83799 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -111,8 +111,11 @@ class AgendaEvents extends DolibarrApi if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.id as rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter @@ -298,4 +301,59 @@ class AgendaEvents extends DolibarrApi } return $event; } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->import_key); + unset($object->array_options); + unset($object->linkedObjectsIds); + unset($object->context); + unset($object->canvas); + unset($object->fk_project); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); + + return $object; + } } From 8b7ca1f280e5b6f1465caddd1cd4d9c12adf920f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 21:27:20 +0200 Subject: [PATCH 130/342] Fix missing vat_src_code into table of expense report --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_expensereport_det.sql | 1 + 2 files changed, 4 insertions(+) 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 e5ee1866567..a66ef47fba6 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 @@ -90,6 +90,8 @@ ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_so ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); + + ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); 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); @@ -230,6 +232,7 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; +ALTER TABLE llx_expensereport_det ADD COLUMN vat_src_code varchar(10) DEFAULT ''; DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 069cd534e4f..8d01f29de68 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -27,6 +27,7 @@ CREATE TABLE llx_expensereport_det qty real NOT NULL, value_unit real NOT NULL, remise_percent real, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type From 9410466d727f94f6e2b99c390f43a2e4a4bc8e00 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:51:31 +0200 Subject: [PATCH 131/342] Fix: better check and security --- .../action/class/api_agendaevents.class.php | 31 ++++++++++--------- htdocs/core/lib/security.lib.php | 4 +-- htdocs/societe/class/api_contacts.class.php | 10 +++--- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40737a83799..40fce1fd640 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,20 +63,20 @@ class AgendaEvents extends DolibarrApi */ function get($id) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); } $result = $this->actioncomm->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Agenda Events not found'); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { + if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -102,6 +102,10 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + throw new RestException(401, "Insuffisant rights to read events"); + } + // case of external user $socid = 0; if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; @@ -155,7 +159,7 @@ class AgendaEvents extends DolibarrApi { $obj = $db->fetch_object($result); $actioncomm_static = new ActionComm($db); - if($actioncomm_static->fetch($obj->rowid)) { + if ($actioncomm_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static); } $i++; @@ -164,7 +168,7 @@ class AgendaEvents extends DolibarrApi else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if ( ! count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } return $obj_ret; @@ -178,10 +182,10 @@ class AgendaEvents extends DolibarrApi */ function post($request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } @@ -216,19 +220,19 @@ class AgendaEvents extends DolibarrApi */ /* function put($id, $request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } $result = $this->expensereport->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + if ( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { @@ -236,7 +240,7 @@ class AgendaEvents extends DolibarrApi $this->expensereport->$field = $value; } - if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) + if ($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); return false; @@ -314,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->import_key); unset($object->array_options); - unset($object->linkedObjectsIds); unset($object->context); unset($object->canvas); unset($object->fk_project); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 9a9e78513c3..d3250263a6f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -403,9 +403,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh else if (in_array($feature,$checksoc)) // We check feature = checksoc { // If external user: Check permission for external users - if ($user->societe_id > 0) + if ($user->socid > 0) { - if ($user->societe_id <> $objectid) return false; + if ($user->socid <> $objectid) return false; } // If internal user: Check permission for internal users that are restricted on their objects else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 58fe15cf282..f136d6895b2 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -43,7 +43,8 @@ class Contacts extends DolibarrApi /** * Constructor */ - function __construct() { + function __construct() + { global $db, $conf; $this->db = $db; $this->contact = new Contact($this->db); @@ -59,7 +60,8 @@ class Contacts extends DolibarrApi * * @throws RestException */ - function get($id) { + function get($id) + { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); @@ -105,7 +107,7 @@ class Contacts extends DolibarrApi } // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; @@ -171,7 +173,7 @@ class Contacts extends DolibarrApi } } else { - throw new RestException(503, 'Error when retreive contacts : ' . $sql); + throw new RestException(503, 'Error when retrieve contacts : ' . $sql); } if (!count($obj_ret)) { From 8149bf62a89ca60b0dfd44ec88bff6b600121ea1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:47:19 +0200 Subject: [PATCH 132/342] Fix ajaxcombo broken on accouting account edition on vat dictionary. --- htdocs/admin/dict.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c83a3aa39be..f920b04bf62 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1502,9 +1502,12 @@ if ($id) } $class='tddict'; + if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'code') $class.=' width100'; if ($fieldlist[$field] == 'position') $class.=' right'; + if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; + if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; // Show value for field if ($showfield) print ''; } @@ -1694,7 +1697,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } // For state page, we do not show the country input (we link to region, not country) print ''; } elseif ($fieldlist[$field] == 'country_id') @@ -1820,7 +1823,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { $fieldname = $fieldlist[$field]; $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); - print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { From ac708a8ee993457e43da17b7ddbcb1a06cd1e296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:58:56 +0200 Subject: [PATCH 133/342] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- .../accountancy/class/bookkeeping.class.php | 7 +- htdocs/accountancy/journal/bankjournal.php | 10 ++- .../journal/expensereportsjournal.php | 28 ++++--- .../accountancy/journal/purchasesjournal.php | 47 ++++++++---- htdocs/accountancy/journal/sellsjournal.php | 48 +++++++----- .../core/class/html.formaccounting.class.php | 4 +- htdocs/core/lib/functions.lib.php | 73 ++++++++++++------- htdocs/langs/en_US/errors.lang | 2 + 8 files changed, 142 insertions(+), 77 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f7c1b4d8b89..9ed4ef29ac1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -184,7 +184,8 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); } return -1; @@ -451,7 +452,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; - $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; @@ -461,7 +462,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; - $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; + $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6c391531662..568edf051ff 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -103,8 +103,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; @@ -144,6 +143,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + // Variables $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); @@ -537,6 +537,12 @@ if (! $error && $action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 759dca8dae9..ca9d05e7e93 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -86,13 +86,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; -$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation,"; +$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; -$sql .= " f.accountancy_code, ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; @@ -110,7 +110,8 @@ dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + + // Variables $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -130,8 +131,11 @@ if ($result) { $compta_fees = $obj->compte; $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); - // Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); $taber[$obj->rowid]["ref"] = $obj->ref; @@ -271,7 +275,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -307,6 +311,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -556,7 +566,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 506c5517821..b5f763fe2b1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -85,26 +85,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; -$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; +$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " WHERE f.fk_statut > 0 "; +$sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? $sql .= " AND fd.fk_code_ventilation > 0 "; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql .= " AND f.type IN (0,1,2)"; -else - $sql .= " AND f.type IN (0,1,2,3)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY f.datef"; @@ -114,7 +115,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + // Variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -139,10 +140,15 @@ if ($result) { else $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; @@ -214,8 +220,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; @@ -262,6 +269,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; @@ -308,9 +316,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -346,6 +355,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -615,7 +630,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 8506b2a480b..24f5ae6e7aa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -89,27 +89,26 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; -$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; +$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva"; +$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_sell as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'"; $sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ? if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) @@ -127,29 +126,33 @@ if ($result) { $tabcompany = array (); $num = $db->num_rows($result); - $i = 0; + // Variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // les variables $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); } - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } // Situation invoices handling $line = new FactureLigne($db); @@ -231,8 +234,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; @@ -277,6 +281,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; @@ -322,10 +327,11 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -360,6 +366,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -651,7 +663,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; // print ""; print ""; print ""; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e37e1690ca2..7248c4bda3a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -241,7 +241,7 @@ class FormAccounting extends Form * Return list of accounts with label by chart of accounts * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) - * @param string $htmlname Name of field in html form + * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. * @param int $showempty Add an empty field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number @@ -284,8 +284,6 @@ class FormAccounting extends Form return -1; } - $out .= ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 49bcc265050..a582263185b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4099,29 +4099,49 @@ function get_localtax_by_third($local) /** - * Get vat rate and npr from id. - * You can call getLocalTaxesFromRate after to get other fields + * Get vat main information from Id. + * You can call getLocalTaxesFromRate after to get other fields. * - * @param int $vatrowid Line ID into vat rate table. - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array('rowid'=> , 'code'=> ...) + * @see getLocalTaxesFromRate */ -function getTaxesFromId($vatrowid) +function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1) { global $db, $mysoc; - dol_syslog("getTaxesFromId vatrowid=".$vatrowid); + dol_syslog("getTaxesFromId vatrowid=".$vatrate); // Search local taxes - $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr"; + $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - $sql.= " WHERE t.rowid ='".$vatrowid."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; + else + { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; + if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? + else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; + $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; + } $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - - return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr); + if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); + else return array(); } else dol_print_error($db); @@ -4135,12 +4155,13 @@ function getTaxesFromId($vatrowid) * Instead this function must be called when adding a line to get the array of localtax and type, and then * provide it to the function calcul_price_total. * - * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. - * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) - * @param Societe $buyer Company object - * @param Societe $seller Company object - * @param int $firstparamisid 1 if first param is id into table (use this if you can) - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @see getTaxesFromId */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0) { @@ -4148,25 +4169,25 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); - $vatratecleaned = $vatrate; - $vatratecode = ''; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = $reg[1]; - $vatratecode = $reg[2]; - } - // Search local taxes $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; else { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; - if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; } $resql=$db->query($sql); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f49bd832d6..0f57a23d23c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -182,6 +182,7 @@ ErrorFailedToLoadLoginFileForMode=Failed to get the login key for mode '%s'. ErrorModuleNotFound=File of module was not found. ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source line id %s (%s) ErrorFieldAccountNotDefinedForInvoiceLine=Value for Accounting account not defined for invoice id %s (%s) +ErrorFieldAccountNotDefinedForLine=Value for Accounting account not defined for the line (%s) ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s ErrorPhpMailDelivery=Check that you don't use a too high number of recipients and that your email content is not similar to a Spam. Ask also your administrator to check firewall and server logs files for a more complete information. ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter time consumed. @@ -191,6 +192,7 @@ ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package ( Date: Fri, 16 Jun 2017 00:49:52 +0200 Subject: [PATCH 134/342] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- htdocs/accountancy/admin/defaultaccounts.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 8 +++--- htdocs/accountancy/bookkeeping/list.php | 4 +-- .../accountancy/class/bookkeeping.class.php | 7 ++++- .../journal/expensereportsjournal.php | 12 +++++---- .../accountancy/journal/purchasesjournal.php | 26 +++++++++++++------ htdocs/accountancy/journal/sellsjournal.php | 14 +++++++++- .../core/class/html.formaccounting.class.php | 16 +++++------- htdocs/langs/en_US/accountancy.lang | 1 + 9 files changed, 59 insertions(+), 31 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index ef39252ff87..227949a3c1c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -51,8 +51,8 @@ $action = GETPOST('action', 'alpha'); $list_account_main = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER', ); $list_account = array ( diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f40bfda856f..5c558ca0a90 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -387,10 +387,10 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; print ''; print ''; print ''; @@ -431,10 +431,10 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index cd93b1142f8..4a7bca5e1b7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -389,11 +389,11 @@ print ''; print ''; } - // Assujeti a TVA ou pas + // VAT is used print ''; - print ''; + print ''; print ''; // Local Taxes - if ($mysoc->useLocalTax(1)) + // TODO Move this on same record than VATIsUsed + if ($mysoc->localtax1_assuj=="1") { print ''; } - if ($mysoc->useLocalTax(2)) + if ($mysoc->localtax1_assuj=="1") { print ''; - print ''; - print ''; From b416b22bcc00d198ff3ddfdc9e90ebd7187eaf69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:27:28 +0200 Subject: [PATCH 137/342] Fix phpcs --- htdocs/accountancy/journal/expensereportsjournal.php | 2 +- htdocs/accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f73596c5aa4..3da9e09aeda 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -134,7 +134,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 27dfd532981..9ef1afdac38 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -145,7 +145,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 3150b74e9bd..4eb4dc72171 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -150,7 +150,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } From f424f96589b6d43d2a0abb4631470717c9a464b3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 16 Jun 2017 05:15:00 +0200 Subject: [PATCH 138/342] Fix SPEC #7013 : use database type "numeric" to store monetary values --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 +++++++++++++++++++ .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql 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..545b52ea4a7 --- /dev/null +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -0,0 +1,64 @@ +-- +-- 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); + + +-- Clean corrupted values for tms +-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- Remove default not null on date_fin +-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; + +-- Move real to numeric for more precision for storing monetary amounts (no rouding) +-- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); +ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); +ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); +ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index ad1160c356d..01ced5b07f4 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit double NOT NULL, -- FEC:Debit - credit double NOT NULL, -- FEC:Credit - montant double NOT NULL, -- FEC:Montant (Not necessary) + debit numeric(24,8) NOT NULL, -- FEC:Debit + credit numeric(24,8) NOT NULL, -- FEC:Credit + montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount double, -- FEC:Montantdevise + multicurrency_amount numeric(24,8), -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index ae696a0d6d1..59c8e262817 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts real NOT NULL, + amounts numeric(24,8) NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 519ceacc9e5..093b635a964 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount real default 0 NOT NULL, + amount numeric(24,8) default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 98740c232ac..6964abdcd57 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 6d291dcfa00..24158903eb1 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index b7b7c89f9cd..63b2cd111ea 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index c682b22f276..eb43238255a 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 2efca933dba..086bafae0fa 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 0e9b1885c97..16d63a32076 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount real DEFAULT 0, -- montant + amount numeric(24,8) DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index afa5075cd4e..1859c7aa796 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 40e39771978..1857246e22e 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index d023c039391..3b6111a7b2f 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 38364c6812e..3b6da16b9cb 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary real, -- salary of user when payment was done - amount real NOT NULL DEFAULT 0, + salary numeric(24,8), -- salary of user when payment was done + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index e92342eb001..40fff2e842d 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount real DEFAULT 0, -- montant total du prelevement + amount numeric(24,8) DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 3bdc0e2ed81..1d1b59bf3f5 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount real NOT NULL, + amount numeric(24,8) NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 04b6e1ebf5e..448b3846d71 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 20440b692d7..7c88a74de07 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital real, -- capital de la societe + capital numeric(24,8), -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index 9abf63d6ad9..d2a7b67c835 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount real NOT NULL DEFAULT 0, + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From c2901ae8cda0ec59b5ff61327e60112077eb1558 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 11:01:58 +0200 Subject: [PATCH 139/342] Fix: add/remove unset unsused fields --- htdocs/comm/action/class/api_agendaevents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40fce1fd640..a607998cfa8 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -316,11 +316,12 @@ class AgendaEvents extends DolibarrApi $object = parent::_cleanObjectDatas($object); + unset($object->usermod); + unset($object->libelle); unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); - unset($object->fk_project); unset($object->contact); unset($object->contact_id); unset($object->thirdparty); From 1c8daf9700676064bd7adaac2dcee8e30cec2f65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 11:51:33 +0200 Subject: [PATCH 140/342] Standardize and debug code of module BlockedLog --- htdocs/blockedlog/admin/blockedlog.php | 13 +- htdocs/blockedlog/admin/fingerprints.php | 103 ++++--- htdocs/blockedlog/ajax/authority.php | 112 +++++--- htdocs/blockedlog/ajax/block-add.php | 64 +++-- htdocs/blockedlog/ajax/block-info.php | 58 +++- htdocs/blockedlog/ajax/check_signature.php | 83 ++++-- htdocs/blockedlog/class/blockedlog.class.php | 262 +++++++++--------- htdocs/blockedlog/lib/blockedlog.lib.php | 8 +- htdocs/compta/facture/card.php | 31 --- htdocs/core/modules/modBlockedLog.class.php | 6 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 24 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/langs/en_US/blockedlog.lang | 23 +- htdocs/main.inc.php | 36 ++- 14 files changed, 486 insertions(+), 341 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index f77c6e9edd8..b3822a9acb7 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -17,7 +17,7 @@ /** * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -31,12 +31,13 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); /* * Actions */ + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -77,7 +78,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -95,13 +96,11 @@ print "\n"; print ''; print ''; -if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { // Example with a yes / no select $var=!$var; print ''; diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index f585b883c65..da149d4340d 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -16,8 +16,8 @@ */ /** - * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \file htdocs/blockedlog/admin/fingerprints.php + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -32,39 +32,39 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); $showonlyerrors = GETPOST('showonlyerrors','int'); $block_static = new BlockedLog($db); if($action === 'downloadblockchain') { - + $auth = new BlockedLogAuthority($db); - + $bc = $auth->getLocalBlockChain(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); - + header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + echo $bc; - + exit; } else if($action === 'downloadcsv') { - + $res = $db->query("SELECT rowid,tms,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user FROM ".MAIN_DB_PREFIX."blockedlog ORDER BY rowid ASC"); - + if($res) { - + $signature = $block_static->getSignature(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" .$signature. ".csv\""); - + print $langs->transnoentities('Id') .';'.$langs->transnoentities('Timestamp') .';'.$langs->transnoentities('Action') @@ -75,9 +75,9 @@ else if($action === 'downloadcsv') { .';'.$langs->transnoentities('Ref') .';'.$langs->transnoentities('Fingerprint') .';'.$langs->transnoentities('User')."\n"; - + while($obj = $db->fetch_object($res)) { - + print $obj->rowid .';'.$obj->tms .';'.$obj->action @@ -88,15 +88,15 @@ else if($action === 'downloadcsv') { .';'.$obj->ref_object .';'.$obj->signature .';'.$obj->fk_user."\n"; - + } - + exit; } else{ setEventMessage($db->lasterror, 'errors'); } - + } /* @@ -110,7 +110,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -131,52 +131,63 @@ print ' '; print '
    '; -print ''; +print ''; print ''; @@ -264,8 +270,6 @@ print '
    ' . dol_print_date($line->doc_date) . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("subledger_account") . "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
    " . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account") . "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; // print "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
    '.$langs->trans("AccountancyJournal").''; - print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print $formaccountancy->select_journal('', 'code_journal', '', 0, 1, 1, 1, 1); print '
    '.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
    '.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
    '.$trigger['code'].''.$trigger['label'].''.$valuetoshow.''; $fieldname='country'; - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); print '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
    " . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
    " . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.join(', ',$def_tva[$key][$k]). "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "'; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print '
    '; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; print '
    '; print $langs->trans('From'); -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
    '; print '
    '; print $langs->trans('to'); -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
    '; print '
    '; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9ed4ef29ac1..d607c1dc287 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -185,7 +185,12 @@ class BookKeeping extends CommonObject else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); + $mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; + if ($this->subledger_account && $this->subledger_account != $this->numero_compte) + { + $mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; + } + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); } return -1; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index ca9d05e7e93..f73596c5aa4 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -92,15 +92,15 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; -$sql .= " WHERE er.fk_statut > 0 "; -$sql .= " AND erd.fk_code_ventilation > 0 "; +$sql .= " WHERE er.fk_statut > 0"; +$sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; @@ -129,7 +129,9 @@ if ($result) { // Controls $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; $compta_fees = $obj->compte; - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); + + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index b5f763fe2b1..27dfd532981 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -90,21 +90,21 @@ $idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? -$sql .= " AND fd.fk_code_ventilation > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; } if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; @@ -130,7 +130,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); - // contrôles + // Controls $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; @@ -536,8 +536,18 @@ if (empty($action) || $action == 'view') { print ''; }*/ + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
    '; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
    '; print ' diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 24f5ae6e7aa..3150b74e9bd 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -135,6 +135,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); + // Controls $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; @@ -549,8 +550,19 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ + + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
    '; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
    '; print ' diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 7248c4bda3a..8a348dba57a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -325,14 +325,13 @@ class FormAccounting extends Form /** * Return list of auxilary thirdparty accounts * - * @param string $selectid Preselected pcg_type - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * - * @return string String with HTML select + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param string $morecss More css + * @return string String with HTML select */ - function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) { + function select_auxaccount($selectid, $htmlname='account_num_aux', $showempty=0, $morecss='maxwidth200') { $aux_account = array(); @@ -377,8 +376,7 @@ class FormAccounting extends Form $this->db->free($resql); // Build select - $out = ajax_combobox($htmlname, $event); - $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8ff65371fa5..64744eedf4a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -256,6 +256,7 @@ Calculated=Calculated Formula=Formula ## Error +SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) ExportNotSupported=The export format setuped is not supported into this page BookeppingLineAlreayExists=Lines already existing into bookeeping From 07b676792a26886170eb657e23410686c0f2236a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:02:53 +0200 Subject: [PATCH 135/342] Fix do not show localtax info if not used. --- htdocs/comm/card.php | 12 +++++++----- htdocs/societe/card.php | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b8906bd1038..a51ef902eb6 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -175,7 +175,7 @@ if (empty($reshook)) $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == 'update_extras') { $object->fetch($id); @@ -262,21 +262,23 @@ if ($id > 0) print '
    '.$langs->trans('VATIsUsed').''; + print ''.$langs->trans('VATIsUsed').''; print yn($object->tva_assuj); print '
    '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print '
    '.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b5afba996b8..46e6366bba1 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1766,8 +1766,9 @@ else $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { From b1945daf6c7eaa1d57d5bd1bf52f2c973d7b4d57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:07:44 +0200 Subject: [PATCH 136/342] Fix alignement --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 1fcd73f0ddc..834131a86a8 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -365,7 +365,7 @@ if ($sql_select) print ''; print ''; print ''; // date + print ''; // date print $formother->select_month($month?$month:-1,'month',1); $formother->select_year($year?$year:-1,'year',1, 20, 1); print '
    '; -print $langs->trans("EntityKey").''; - +print $langs->trans("CompanyInitialKey").''; print $block_static->getSignature(); - print '
    '; print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; - + print ''; foreach($blocks as &$block) { $checksignature = $block->checkSignature(); $object_link = $block->getObjectLink(); - + if(!$showonlyerrors || $block->error>0) { - + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; - + } } print '
    '.$langs->trans('Date').''.$langs->trans('Ref').''.$langs->trans('#').''.$langs->trans('Date').''.$langs->trans('Author').''.$langs->trans('Action').''.$langs->trans('Ref').''.$langs->trans('Element').''.$langs->trans('Amount').''.$langs->trans('Author').''.$langs->trans('DataOfArchivedEvent').''.$langs->trans('Fingerprint').'
    '.$block->id.''.dol_print_date($block->tms,'dayhour').''.$block->ref_object.''.$langs->trans('log'.$block->action).''.$object_link.''.img_info($langs->trans('ShowDetails')).''.price($block->amounts).''.$block->getUser().''.$block->signature.''.$langs->trans('log'.$block->action).''.$block->ref_object.''.$object_link.''.price($block->amounts).''.img_info($langs->trans('ShowDetails')).''; - - print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off'); + print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature); + print ''; + print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'tick') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8'); + if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); } print '
    '; + + ?> -global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { ?> - + + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - $user=new User($db); - $user->fetch(1); //TODO conf user authority - - $auth = new BlockedLogAuthority($db); - - $signature = GETPOST('s'); - $newblock = GETPOST('b'); - $hash = GETPOST('h'); - - if($auth->fetch(0, $signature)<=0) { - $auth->signature = $signature; - $auth->create($user); - } - - - if(!empty($hash)) { - - echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; - - } - elseif(!empty($newblock)){ - if($auth->checkBlock($newblock)) { - $auth->addBlock($newblock); - $auth->update($user); - - echo 'blockadded'; - } - else{ - - echo 'blockalreadyadded'; - - } +/** + * \file htdocs/blockedlog/ajax/authority.php + * \ingroup blockedlog + * \brief authority + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../master.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$user=new User($db); +$user->fetch(1); //TODO conf user authority + +$auth = new BlockedLogAuthority($db); + +$signature = GETPOST('s'); +$newblock = GETPOST('b'); +$hash = GETPOST('h'); + +if($auth->fetch(0, $signature)<=0) { + $auth->signature = $signature; + $auth->create($user); +} + + +if(!empty($hash)) { + + echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; + +} +elseif(!empty($newblock)){ + if($auth->checkBlock($newblock)) { + $auth->addBlock($newblock); + $auth->update($user); + + echo 'blockadded'; } else{ - echo 'idontunderstandwhatihavetodo'; + + echo 'blockalreadyadded'; + } - - +} +else{ + echo 'idontunderstandwhatihavetodo'; +} + + diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 247b01186fe..c82eac81e7b 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -1,19 +1,49 @@ - + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id','int'); - $element = GETPOST('element','alpha'); - $action = GETPOST('action','alpha'); - - if($element === 'facture') { - dol_include_once('/compta/facture/class/facture.class.php'); - - $facture = new Facture($db); - if($facture->fetch($id)>0) { - $facture->call_trigger($action, $user); - } - +/** + * \file htdocs/blockedlog/ajax/block-add.php + * \ingroup blockedlog + * \brief Block-add + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../main.inc.php'; + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$action = GETPOST('action','alpha'); + +if ($element === 'facture') { + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $facture = new Facture($db); + if($facture->fetch($id)>0) { + $facture->call_trigger($action, $user); } - \ No newline at end of file +} diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index 7a5f531e8f1..83317f33d57 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -1,15 +1,47 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id'); - - $block = new BlockedLog($db); - if($block->fetch($id)>0) { - echo json_encode($block->object_data); - } - else { - echo json_encode(false); - } - \ No newline at end of file +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + +$id = GETPOST('id'); + +$block = new BlockedLog($db); +if($block->fetch($id)>0) { + echo json_encode($block->object_data); +} +else { + echo json_encode(false); +} diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index bb018508a31..170693a2ece 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -1,30 +1,63 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); - - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; - - $auth=new BlockedLogAuthority($db); - $auth->syncSignatureWithAuthority(); - - $block_static = new BlockedLog($db); - - $blocks = $block_static->getLog('just_certified', 0, 0, 1) ; - $auth->signature = $block_static->getSignature(); - - foreach($blocks as &$b) { - $auth->blockchain.=$b->signature; - - } - - $hash = $auth->getBlockchainHash(); - - $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. - $res = file_get_contents($url); - //echo $url; - echo $res; \ No newline at end of file +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; + +if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$auth=new BlockedLogAuthority($db); +$auth->syncSignatureWithAuthority(); + +$block_static = new BlockedLog($db); + +$blocks = $block_static->getLog('just_certified', 0, 0, 1) ; + +$auth->signature = $block_static->getSignature(); + +foreach($blocks as &$b) { + $auth->blockchain.=$b->signature; + +} + +$hash = $auth->getBlockchainHash(); + +$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; + +$res = file_get_contents($url); +//echo $url; +echo $res; \ No newline at end of file diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index b0cddd66f75..8a1508b7a04 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,65 +21,65 @@ class BlockedLog { - + /** * Id of the log * @var int */ public $id; - + /** * Unique fingerprint of the log * @var string */ public $signature = ''; - + /** * Unique fingerprint of the line log content * @var string */ public $signature_line = ''; - + public $amounts = null; - + /** * trigger action * @var string */ public $action = ''; - + /** * Object element * @var string */ public $element = ''; - + /** * Object id * @var int */ public $fk_object = 0; - + /** * Log certified by remote authority or not * @var boolean */ public $certified = false; - + /** * Author * @var int */ public $fk_user = 0; - + public $date_object = 0; - + public $ref_object = ''; - + public $object_data = null; - + public $error = 0; - + /** * Constructor * @@ -88,7 +88,7 @@ class BlockedLog public function __construct(DoliDB $db) { $this->db = $db; - + } /** @@ -96,10 +96,10 @@ class BlockedLog */ public function getObjectLink() { global $langs; - + if($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - + $object = new Facture($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -110,7 +110,7 @@ class BlockedLog } else if($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - + $object = new Paiement($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -119,61 +119,61 @@ class BlockedLog $this->error++; } } - + return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); - + } - + /** * try to retrieve user author */ public function getUser() { global $langs, $cachedUser; - + if(empty($cachedUser))$cachedUser=array(); - + if(empty($cachedUser[$this->fk_user])) { $u=new User($this->db); if($u->fetch($this->fk_user)>0) { $cachedUser[$this->fk_user] = $u; } } - + if(!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } - + return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user); } - + /** * populate log by object * * @param payment|facture $object object to store */ public function setObjectData(&$object) { - + if($object->element=='payment') { $this->date_object = $object->datepaye; } else{ $this->date_object = $object->date; } - + $this->ref_object = $object->ref; $this->element = $object->element; $this->fk_object = $object->id; - + $this->object_data=new stdClass(); - + if($this->element === 'facture') { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); - + foreach($object->thirdparty as $key=>$value) { if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } - + $this->object_data->total_ht = (double) $object->total_ht; $this->object_data->total_tva = (double) $object->total_tva; $this->object_data->total_ttc = (double) $object->total_ttc; @@ -181,17 +181,17 @@ class BlockedLog $this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->note_public = (double) $object->note_public; $this->object_data->note_private= (double) $object->note_private; - + } elseif($this->element==='payment'){ - + $this->object_data->amounts = $object->amounts; - + } - - + + } - + /** * Get object from database * @@ -199,50 +199,50 @@ class BlockedLog * @return int >0 if OK, <0 if KO, 0 if not found */ public function fetch($id) { - + global $langs; - + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); - + if (empty($id)) { $this->error='BadParameter'; return -1; } - + $langs->load("blockedlog"); - + $sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data"; $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; if ($id) $sql.= " WHERE b.rowid = ". $id; - + $resql=$this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; $this->ref = $obj->rowid; - + $this->signature = $obj->signature; $this->amounts = (double) $obj->amounts; $this->action = $obj->action; $this->element = $obj->element; - + $this->fk_object = trim($obj->fk_object); $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; - + $this->certified = ($obj->certified == 1); - + $this->fk_user = $obj->fk_user; - + $this->tms = $this->db->jdate($obj->tms); - + $this->object_data = unserialize($obj->object_data); - + return 1; } else @@ -256,24 +256,24 @@ class BlockedLog $this->error=$this->db->error(); return -1; } - + } - + /** * Set block certified by authority * * @return boolean */ public function setCertified() { - + $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); if($res===false) return false; - + return true; - - + + } - + /** * Create blocked log in database. * @@ -281,31 +281,31 @@ class BlockedLog * @return int <0 if KO, >0 if OK */ public function create($user) { - + global $conf,$langs,$hookmanager; - + $langs->load('blockedlog'); - + $error=0; - + dol_syslog(get_class($this).'::create', LOG_DEBUG); - + $this->getSignatureRecursive(); - - + + if (is_null($this->amounts)) { $this->error=$langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } - + if(empty($this->element)) { $this->error=$langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } - + if(empty($this->action)) { $this->error=$langs->trans("BlockLogNeedAction"); dol_syslog($this->error, LOG_WARNING); @@ -313,9 +313,9 @@ class BlockedLog } $this->fk_user = $user->id; - + $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; $sql.= "action,"; $sql.= " amounts,"; @@ -343,18 +343,18 @@ class BlockedLog $sql.= "".$user->id.","; $sql.= $conf->entity; $sql.= ")"; - + $res = $this->db->query($sql); if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); - + if ($id > 0) { $this->id = $id; - + $this->db->commit(); - + return $this->id; } else @@ -369,9 +369,9 @@ class BlockedLog $this->db->rollback(); return -1; } - + } - + /** * return crypted value. * @@ -379,56 +379,56 @@ class BlockedLog * @return string crypted string */ private function crypt($value) { - + return hash('sha256',$value); - + } - + /** * check if current signature still correct compare to the chain * - * @return boolean + * @return boolean */ public function checkSignature() { - + $signature_to_test = $this->signature; - + $this->getSignatureRecursive(); - + $res = ($signature_to_test === $this->signature); - + if(!$res) { $this->error++; } - + return $res; } - + /** - * set current signatures + * set current signatures */ private function getSignatureRecursive(){ - + $this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) ); /*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') { var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data); }*/ $this->signature = $this->signature_line; - + $logs = $this->getLog('all', 0, 0, 1) ; if($logs!==false) { foreach($logs as &$b) { - + if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature - + $b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré - + $this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts); } } - + } - + /** * return log object for a element. * @@ -439,110 +439,110 @@ class BlockedLog * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { - global $conf,$cachedlogs ; - + global $conf,$cachedlogs ; + /* $cachedlogs allow fastest search */ if(empty($cachedlogs)) $cachedlogs=array(); - - + + if($element=='all') { - + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; - + } else if($element=='not_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; - + } else if($element=='just_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; - + } else{ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE element='".$element."' AND fk_object=".(int) $fk_object; - + } - + $sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC '); - + if($limit > 0 )$sql.=' LIMIT '.$limit; - + $res = $this->db->query($sql); - + if($res) { - + $results=array(); - + while($obj = $this->db->fetch_object($res)) { - + if(!isset($cachedlogs[$obj->rowid])) { $b=new BlockedLog($this->db); $b->fetch($obj->rowid); - + $cachedlogs[$obj->rowid] = $b; } - + $results[] = $cachedlogs[$obj->rowid]; - + } - + return $results; } else{ return false; } } - + /** * set amounts of log from current element value in order to compare signature. */ private function getCurrentValue() { - + if($this->element === 'payment') { $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); - + if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->amount; } } elseif($this->element === 'facture') { $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->total_ttc; } } - + } - + /** - * return and set the entity signature included into line signature + * Return and set the entity signature included into line signature * * @return string current entity signature */ public function getSignature() { global $db,$conf,$mysoc; - - if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint - + + if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - + $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); - + dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity); - - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; + + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; } - + return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; } - + } diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index a7fca40d116..cffac7cbff9 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -32,17 +32,17 @@ function blockedlogadmin_prepare_head() $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php"; - $head[$h][1] = $langs->trans("BlockedLog"); + $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'blockedlog'; $h++; - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php"; $head[$h][1] = $langs->trans("Fingerprints"); $head[$h][2] = 'fingerprints'; $h++; - + $object=new stdClass(); // Show more tabs from modules diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ce16d6b9931..223acb91fb3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4247,37 +4247,6 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - if(!empty($conf->blockedlog->enabled) && $object->statut>0) { - ?> - - numoffiles; // Show links to link elements diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index b149471cd20..f3f3be971b5 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -43,15 +43,15 @@ class modBlockedLog extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "base"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Enable a log on some business events into a reserved log. This module may be mandatory for some countries."; + $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; $this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; + $this->special = 2; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 004c4eecd78..6759d18ba5d 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -50,9 +50,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers if (empty($conf->blockedlog->enabled)) { return 0; } - - if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' - || $action === 'BILL_SENTBYMAIL' || $action === 'DOWNLOAD_BILL' || $action === 'PREVIEW_BILL') { + + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' + || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { @@ -62,8 +62,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts+= price2num($amount); } } - - + + } else if(strpos($action,'PAYMENT')!==false) { $amounts= (double) $object->amount; @@ -71,25 +71,25 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers else { return 0; // not implemented action log } - + $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; $b->setObjectData($object); - + $res = $b->create($user); - + if($res<0) { setEventMessage($b->error,'errors'); - + return -1; } else { - + return 1; } - - + + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 695373e22b5..1aa79c2dced 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -467,7 +467,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...) +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,6 +565,8 @@ Module2900Name=GeoIPMaxmind Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards +Module3200Name=Non Reversible Logs +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index fcad52508bd..7129b65257d 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,12 +1,14 @@ +BlockedLog=Non Reversible Logs Field=Field -BlockedLogDesc=This module store event for invoice and payments as block chain -FingerprintsDesc=All fingerprints stored -EntityKey=Entity Key -ShowAllFingerPrintsMightBeTooLong=Show all fingerprints (might be long) -ShowAllFingerPrintsErrorsMightBeTooLong=Show all fingerprints with error (might be long) +BlockedLogDesc=This module store event for invoice and payments into a block chain +Fingerprints=Archived events and fingerprints +FingerprintsDesc=Archived business events and fingerprints +CompanyInitialKey=Company initial key +ShowAllFingerPrintsMightBeTooLong=Show all archived logs (might be long) +ShowAllFingerPrintsErrorsMightBeTooLong=Show all archive logs with error (might be long) DownloadBlockChain=Download fingerprints -KoCheckFingerprintValidity=Fingerprint is not valid -OkCheckFingerprintValidity=Fingerprint is valid +KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker ?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists). +OkCheckFingerprintValidity=Archived log is valid. It means all data on this line were not modified and record follow the previous one. AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details @@ -18,6 +20,7 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV -logPREVIEW_BILL=Preview of a validated customer bill in order to print or download -logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file +DownloadLogCSV=Download archive logs (CSV) +logDOC_PREVIEW=Preview of a validated document in order to print or download +logDOC_DOWNLOAD=Download of a validated document in order to print or send +DataOfArchivedEvent=Full datas of archived event \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b75b957590..33b155bb64c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1891,7 +1891,7 @@ if (! function_exists("llxFooter")) */ function llxFooter($comment='',$zone='private') { - global $conf, $langs, $user; + global $conf, $langs, $user, $object; global $delayedhtmlcontent; // Global html output events ($mesgs, $errors, $warnings) @@ -2026,6 +2026,40 @@ if (! function_exists("llxFooter")) '; } + // Wrapper to add log when clicking on download or preview + if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) + { + if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' + { + print "\n\n"; + ?> + + \n"; print ''."\n"; From e813fd2dfa69d3ce67ab5aec2af6df34970e3c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 12:57:30 +0200 Subject: [PATCH 141/342] Fix missing key import_key and extraparams --- htdocs/adherents/class/api_memberstypes.class.php | 1 - htdocs/comm/action/class/api_agendaevents.class.php | 1 - htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 7 +++++-- htdocs/install/mysql/tables/llx_actioncomm.sql | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 9457b910c5d..ff8064d80fb 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -274,7 +274,6 @@ class MembersTypes extends DolibarrApi unset($object->cotisation); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->linkedObjectsIds); unset($object->context); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index a607998cfa8..4edd656da53 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -318,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->usermod); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); 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 a66ef47fba6..5e46393768a 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 @@ -82,14 +82,17 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label); +ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; + + ALTER TABLE llx_holiday ADD COLUMN import_key varchar(14); ALTER TABLE llx_holiday ADD COLUMN extraparams varchar(255); -ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; - ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_actioncomm ADD COLUMN import_key varchar(14); +ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 4849aacb690..48b73bcaa65 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -69,8 +69,10 @@ create table llx_actioncomm recurdateend datetime, -- no more recurring event after this date fk_element integer DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) - elementtype varchar(255) DEFAULT NULL -- For link to an element (proposal, invoice, order, ...) + elementtype varchar(255) DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) + import_key varchar(14), + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; From 81f1a341120a85e97c718571ca5bf447a74c08c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 13:06:35 +0200 Subject: [PATCH 142/342] Revert "Fix SPEC #7013 : use database type "numeric" to store monetary values" --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 ------------------- .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 28 insertions(+), 92 deletions(-) delete mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql 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 deleted file mode 100644 index 545b52ea4a7..00000000000 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ /dev/null @@ -1,64 +0,0 @@ --- --- 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); - - --- Clean corrupted values for tms --- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; --- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; --- Remove default not null on date_fin --- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; --- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; - --- Move real to numeric for more precision for storing monetary amounts (no rouding) --- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); -ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); -ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); -ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); -ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); -ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); -ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); -ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); -ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 01ced5b07f4..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit numeric(24,8) NOT NULL, -- FEC:Debit - credit numeric(24,8) NOT NULL, -- FEC:Credit - montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) + debit double NOT NULL, -- FEC:Debit + credit double NOT NULL, -- FEC:Credit + montant double NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount numeric(24,8), -- FEC:Montantdevise + multicurrency_amount double, -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index 59c8e262817..ae696a0d6d1 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts numeric(24,8) NOT NULL, + amounts real NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 093b635a964..519ceacc9e5 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount numeric(24,8) default 0 NOT NULL, + amount real default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 6964abdcd57..98740c232ac 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 24158903eb1..6d291dcfa00 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht numeric(24,8) default 0, + amount_ht real default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 63b2cd111ea..b7b7c89f9cd 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index eb43238255a..c682b22f276 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 086bafae0fa..2efca933dba 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 16d63a32076..0e9b1885c97 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount numeric(24,8) DEFAULT 0, -- montant + amount real DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index 1859c7aa796..afa5075cd4e 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 1857246e22e..40e39771978 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index 3b6111a7b2f..d023c039391 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital numeric(24,8) DEFAULT 0, - amount_insurance numeric(24,8) DEFAULT 0, - amount_interest numeric(24,8) DEFAULT 0, + amount_capital real DEFAULT 0, + amount_insurance real DEFAULT 0, + amount_interest real DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 3b6da16b9cb..38364c6812e 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary numeric(24,8), -- salary of user when payment was done - amount numeric(24,8) NOT NULL DEFAULT 0, + salary real, -- salary of user when payment was done + amount real NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index 40fff2e842d..e92342eb001 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount numeric(24,8) DEFAULT 0, -- montant total du prelevement + amount real DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 1d1b59bf3f5..3bdc0e2ed81 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount numeric(24,8) NOT NULL, + amount real NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 448b3846d71..04b6e1ebf5e 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount numeric(24,8) DEFAULT 0, + amount real DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 7c88a74de07..20440b692d7 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital numeric(24,8), -- capital de la societe + capital real, -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index d2a7b67c835..9abf63d6ad9 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount numeric(24,8) NOT NULL DEFAULT 0, + amount real NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From b228fe6a2ae6aa5ac265fcb1aca90c5247c2d4d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 16:06:20 +0200 Subject: [PATCH 143/342] Fix auto focus on module page --- htdocs/admin/modules.php | 4 +++- htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..5d5886b5415 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -430,6 +430,8 @@ print "
    \n"; if ($mode == 'common') { + dol_set_focus('#search_keyword'); + print '
    '; if ($optioncss != '') print ''; print ''; @@ -441,7 +443,7 @@ if ($mode == 'common') $moreforfilter = ''; $moreforfilter.='
    '; - $moreforfilter.= $langs->trans('Keyword') . ': '; + $moreforfilter.= $langs->trans('Keyword') . ': '; $moreforfilter.= '
    '; $moreforfilter.='
    '; $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a582263185b..fd3b0012165 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6089,12 +6089,12 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') /** * Set focus onto field with selector * - * @param string $selector Selector ('#id') + * @param string $selector Selector ('#id') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. * @return string HTML code to set focus */ function dol_set_focus($selector) { - print ''."\n"; + print "\n".''."\n"; print ''."\n"; } From f0e234eef2e2fbc9c2425bdc7311d64f0768a1f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 17:01:43 +0200 Subject: [PATCH 144/342] Fix: missing hookmanager init --- htdocs/admin/defaultvalues.php | 6 +++++- htdocs/admin/modules.php | 36 ++++++++++++++++++++++------------ htdocs/admin/translation.php | 7 +++++-- htdocs/user/group/index.php | 2 +- htdocs/user/perms.php | 12 ++++++------ 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 94682cd502f..53c22353b92 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +61,9 @@ $urlpage = GETPOST('urlpage'); $key = GETPOST('key'); $value = GETPOST('value'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admindefaultvalues','globaladmin')); + /* * Actions diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..1aebae10947 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -1,12 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud * * 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 @@ -75,11 +75,18 @@ if ($search_version) $param.='&search_version='.urlencode($search_version); $dirins=DOL_DOCUMENT_ROOT.'/custom'; $urldolibarrmodules='https://www.dolistore.com/'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('adminmodules','globaladmin')); + /* * Actions */ +$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 (GETPOST('buttonreset')) { $search_keyword=''; @@ -204,7 +211,7 @@ if ($action == 'set' && $user->admin) setEventMessages($msg, null, 'warnings'); } } - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -212,7 +219,7 @@ if ($action == 'reset' && $user->admin) { $result=unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); - header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); exit; } @@ -474,10 +481,13 @@ if ($mode == 'common') print $hookmanager->resPrint; } + $moreforfilter=''; print '

    '; - $moreforfilter=''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Show list of modules @@ -657,7 +667,7 @@ if ($mode == 'common') } else { - print ''; + print ''; print img_picto($langs->trans("Activated"),'switch_on'); print ''; } @@ -749,7 +759,7 @@ if ($mode == 'common') } } print ''."\n"; - print ''; print img_picto($langs->trans("Disabled"),'switch_off'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 8a6c38ffe46..be48bd0c8f4 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2007-2016 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,6 +56,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='lang,transkey'; if (! $sortorder) $sortorder='ASC'; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admintranslation','globaladmin')); + /* * Actions diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 06e11caced9..e8d37801998 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -203,7 +203,7 @@ if ($resql) print '
    '; print "\n"; - $db->free(); + $db->free($resql); } else { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 5d87232c928..6f89e49af5e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -1,10 +1,10 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2012 Juanjo Menent +/* Copyright (C) 2002-2005 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 1d91ce90d33b3909c6a5e968ad0152c2b6b05735 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 00:13:09 +0200 Subject: [PATCH 145/342] FIX image from medias directory into PDF free text --- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/commande.php | 2 +- htdocs/admin/contract.php | 2 +- htdocs/admin/expedition.php | 2 +- htdocs/admin/expensereport.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 2 +- htdocs/admin/livraison.php | 2 +- htdocs/admin/propal.php | 2 +- htdocs/admin/supplier_invoice.php | 2 +- htdocs/admin/supplier_order.php | 2 +- htdocs/admin/supplier_proposal.php | 2 +- htdocs/core/lib/pdf.lib.php | 7 +++++++ 13 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index f88dfc6f5a6..3d3db2451d2 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -274,7 +274,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index f4104e2007f..e9ad5ab6ed6 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -559,7 +559,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e2f865f61f6..427b3a531c4 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 12d0b7951d5..af932b94b45 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 24aaeede5b4..cd14d472057 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -497,7 +497,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 57ff2321a12..85ee8c09934 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -731,7 +731,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 68d2d87800a..926a3651362 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -525,7 +525,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 0136f6cc9d9..fe41afabfb8 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -474,7 +474,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 8acbf19f939..2f90145f3cc 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -564,7 +564,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 17501cdb4f9..6d65af336b9 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -487,7 +487,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 13499af551a..21b3de68835 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -553,7 +553,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 8c52ee83dda..4e7efa4d922 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -520,7 +520,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 9220725dc8e..a9fb8e52734 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -861,6 +861,13 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; complete_substitutions_array($substitutionarray, $outputlangs, $object); $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); + + // Make a change into HTML code to allow to include images from medias directory. + // + // become + // + $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); + $line.=$outputlangs->convToOutputCharset($newfreetext); } From b240f536b5e121ac8a54bbf16ddf579ca593b3fe Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 17 Jun 2017 07:54:35 +0200 Subject: [PATCH 146/342] Fix : Accountancy - Debug and add information in database --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/card.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/fiscalyear_info.php | 2 +- htdocs/accountancy/admin/importaccounts.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/bookkeeping/balance.php | 273 +++++++++--------- .../bookkeeping/balancebymonth.php | 6 +- htdocs/accountancy/bookkeeping/card.php | 18 +- htdocs/accountancy/bookkeeping/list.php | 6 +- .../accountancy/bookkeeping/listbyaccount.php | 15 +- htdocs/accountancy/bookkeeping/listbyyear.php | 18 +- .../class/accountancycategory.class.php | 4 +- .../class/accountancyexport.class.php | 20 +- .../class/accountancysystem.class.php | 2 +- .../class/accountingaccount.class.php | 2 +- .../accountancy/class/bookkeeping.class.php | 43 ++- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/journal/bankjournal.php | 77 ++++- .../journal/expensereportsjournal.php | 15 +- .../accountancy/journal/purchasesjournal.php | 10 +- htdocs/accountancy/journal/sellsjournal.php | 14 +- htdocs/accountancy/report/result.php | 2 +- htdocs/accountancy/supplier/card.php | 2 +- htdocs/accountancy/supplier/index.php | 2 +- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/accountancy/tpl/export_journal.tpl.php | 2 +- .../bank/class/paymentvarious.class.php | 25 +- htdocs/compta/bank/ligne.php | 2 +- 34 files changed, 326 insertions(+), 258 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index e22e993796f..aa6c4a71551 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 73e3fdf6dd9..fa3adf1301b 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index b10015baa6c..7c658d2661c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index eaf69f34f1f..cdec35415fd 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index 3596d73d751..baadbdc0828 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 6ae94dc8ce2..93d41b3cbc6 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 33bf067fa9e..5b614061dbc 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3f2c472cc58..a32b739752a 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016 Alexandre Spangaro +/* Copyright (C) 2016 Olivier Geffroy + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,10 +100,10 @@ if (! empty($search_accountancy_code_end)) { if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_date_start = ''; - $search_date_end = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_date_start = ''; + $search_date_end = ''; } @@ -137,140 +137,137 @@ if ($action == 'export_csv') { } else { - $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); - - llxHeader('', $title_page); - - // List + $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); - $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - - - print '
    '; - - $button = ''; - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); - - - $moreforfilter = ''; - - $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('DateStart') . ': '; - $moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); - $moreforfilter .= $langs->trans('DateEnd') . ': '; - $moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); - $moreforfilter .= '
    '; - - if (! empty($moreforfilter)) { - print '
    '; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
    '; - } - - print ''; + llxHeader('', $title_page); - print ''; - print ''; - print ''; + + print ''; + + print ''; + print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "\n"; + + $total_debit = 0; + $total_credit = 0; + $sous_total_debit = 0; + $sous_total_credit = 0; + $displayed_account = ""; + + foreach ($object->lines as $line) { + $link = ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + $description = $object->get_compte_desc($line->numero_compte); // Search description of the account + $root_account_description = $object->get_compte_racine($line->numero_compte); + if (empty($description)) { + $link = '' . img_edit_add() . ''; + } + print ''; + + // Permet d'afficher le compte comptable + if ($root_account_description != $displayed_account) { + + // Affiche un Sous-Total par compte comptable + if ($displayed_account != "") { + print ''; + print "\n"; + print ''; + } + + // Affiche le compte comptable en d�but de ligne + print ""; + print ''; + print ''; + + $displayed_account = $root_account_description; + $sous_total_debit = 0; + $sous_total_credit = 0; + } + + // $object->get_compte_racine($line->numero_compte); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + } + + print ''; + print "\n"; + print ''; + + print ''; + print "\n"; + print ''; + + print "
    '; - print $langs->trans('From'); - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); - print ' '; - print $langs->trans('to'); - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); - print ''; + // List + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + print ''; + + $button = ''; + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); + + $moreforfilter = ''; + + $moreforfilter .= '
    '; + $moreforfilter .= $langs->trans('DateStart') . ': '; + $moreforfilter .= $form->select_date($search_date_start, 'date_start', 0, 0, 1, '', 1, 0, 1); + $moreforfilter .= $langs->trans('DateEnd') . ': '; + $moreforfilter .= $form->select_date($search_date_end, 'date_end', 0, 0, 1, '', 1, 0, 1); + $moreforfilter .= '
    '; + + if (! empty($moreforfilter)) { + print '
    '; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
    '; + } + + print ''; + + print ''; + print ''; + print ''; - - print ''; - - print ''; - print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); - print "\n"; - - $total_debit = 0; - $total_credit = 0; - $sous_total_debit = 0; - $sous_total_credit = 0; - $displayed_account = ""; - - foreach ($object->lines as $line) { - $link = ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - $description = $object->get_compte_desc($line->numero_compte); // Search description of the account - $root_account_description = $object->get_compte_racine($line->numero_compte); - if (empty($description)) { - $link = '' . img_edit_add() . ''; - } - print ''; - - // Permet d'afficher le compte comptable - if ($root_account_description != $displayed_account) { - - // Affiche un Sous-Total par compte comptable - if ($displayed_account != "") { - print ''; - print "\n"; - print ''; - } - - // Affiche le compte comptable en d�but de ligne - print ""; - print ''; - print ''; - - $displayed_account = $root_account_description; - $sous_total_debit = 0; - $sous_total_credit = 0; - } - - // $object->get_compte_racine($line->numero_compte); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; - } - - print ''; - print "\n"; - print ''; - - print ''; - print "\n"; - print ''; - - print "
    '; + print $langs->trans('From'); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); + print ' '; + print $langs->trans('to'); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; - print '
    ' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
    ' . $root_account_description . '
    ' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . '' . $link; - print '
    ' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
    ' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price($total_credit - $total_debit) . ' 
    "; - print ''; - - llxFooter(); + print '
    ' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
    ' . $root_account_description . '
    ' . length_accountg($line->numero_compte) . '' . $description . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . '' . $link; + print '
    ' . $langs->trans("SubTotal") . ':' . price($sous_total_debit) . '' . price($sous_total_credit) . '' . price($sous_total_credit - $sous_total_debit) . ' 
    ' . $langs->trans("AccountBalance") . ':' . price($total_debit) . '' . price($total_credit) . '' . price($total_credit - $total_debit) . ' 
    "; + print ''; + + llxFooter(); } $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index 83908f72172..1d746b4d4df 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 5c558ca0a90..660248a46a3 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -52,7 +52,7 @@ $subledger_account = GETPOST('subledger_account'); if ($subledger_account == - 1) { $subledger_account = null; } -$label_compte = GETPOST('label_compte'); +$label_operation = GETPOST('label_operation'); $debit = price2num(GETPOST('debit')); $credit = price2num(GETPOST('credit')); @@ -83,7 +83,7 @@ if ($action == "confirm_update") { } else { $book->numero_compte = $account_number; $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; + $book->label_operation = $label_operation; $book->debit = $debit; $book->credit = $credit; @@ -120,7 +120,7 @@ else if ($action == "add") { $book->numero_compte = $account_number; $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; + $book->label_operation = $label_operation; $book->debit = $debit; $book->credit = $credit; $book->doc_date = GETPOST('doc_date'); @@ -182,7 +182,7 @@ else if ($action == "confirm_create") { if (! $error) { - $book->label_compte = ''; + $book->label_operation = ''; $book->debit = 0; $book->credit = 0; $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); @@ -392,7 +392,7 @@ if ($action == 'create') { print ''; print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; - print ''; + print ''; print ''; print ''; print '' . price($line->montant) . ''; @@ -404,17 +404,17 @@ if ($action == 'create') { } else { print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; print '' . price($line->montant) . ''; print '' . $line->sens . ''; print ''; - print ''; + print ''; print img_edit(); print ' '; - print ''; + print ''; print img_delete(); print ''; @@ -436,7 +436,7 @@ if ($action == 'create') { print ''; print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 4a7bca5e1b7..65e615cecaf 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -183,7 +183,7 @@ if (! empty($search_accountancy_aux_code_end)) { $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; } if (! empty($search_mvt_label)) { - $filter['t.label_compte'] = $search_mvt_label; + $filter['t.label_operation'] = $search_mvt_label; $param .= '&search_mvt_label=' . $search_mvt_label; } if (! empty($search_direction)) { @@ -424,7 +424,7 @@ print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_d print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); @@ -450,7 +450,7 @@ foreach ($object->lines as $line ) { print '' . $line->doc_ref . ''; print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . ($line->debit ? price($line->debit) : ''). ''; print '' . ($line->credit ? price($line->credit) : '') . ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7d0ba2280ea..a1398df6fb2 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1,9 +1,8 @@ largely based on the great work of : - * - Copyright (C) 2013-2016 Olivier Geffroy - * - Copyright (C) 2013-2016 Florian Henry - * - Copyright (C) 2013-2016 Alexandre Spangaro +/* Copyright (C) 2016 Neil Orley + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -100,11 +99,11 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; } if (! empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; + $filter['t.label_operation'] = $search_label_account; $options .= '&search_label_account=' . $search_label_account; } if (! empty($search_mvt_label)) { - $filter['t.label_compte'] = $search_mvt_label; + $filter['t.label_operation'] = $search_mvt_label; $options .= '&search_mvt_label=' . $search_mvt_label; } if (! empty($search_direction)) { @@ -312,7 +311,7 @@ foreach ( $object->lines as $line ) { // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_compte . '' : '' . $line->label_compte . '
    (' . length_accounta($line->subledger_account) . ')'; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' : '' . $line->label_operation . '
    (' . length_accounta($line->subledger_account) . ')'; print '' . ($line->debit ? price($line->debit) :''). ''; diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index e7e51ae67e0..becb700761a 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -61,7 +61,7 @@ $search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha') if ($search_subledger_account_end == - 1) { $search_subledger_account_end = ''; } -$search_label_compte = GETPOST('search_label_compte', 'alpha'); +$search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha'); $search_code_journal = GETPOST('search_code_journal', 'alpha'); @@ -93,7 +93,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_doc_ref = ""; $search_numero_compte = ""; $search_subledger_account = ""; - $search_label_compte = ""; + $search_label_operation = ""; $search_sens = ""; $search_code_journal = ""; } @@ -144,9 +144,9 @@ if (! empty($search_subledger_account_end)) { $filter['t.subledger_account<='] = $search_subledger_account_end; $options .= '&search_subledger_account_end=' . $search_subledger_account_end; } -if (! empty($search_label_compte)) { - $filter['t.label_compte'] = $search_label_compte; - $options .= '&search_label_compte=' . $search_label_compte; +if (! empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $options .= '&search_label_operation=' . $search_label_operation; } if (! empty($search_sens)) { $filter['t.sens'] = $search_sens; @@ -207,7 +207,7 @@ print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); @@ -242,7 +242,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; @@ -279,7 +279,7 @@ foreach ( $object->lines as $line ) { print '' . $line->doc_ref . ''; print '' . length_accountg($line->numero_compte) . ''; print '' . length_accounta($line->subledger_account) . ''; - print '' . $line->label_compte . ''; + print '' . $line->label_operation . ''; print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; print '' . price($line->montant) . ''; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index e4e3017ab15..db75947771e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -92,7 +92,7 @@ class AccountancyCategory public function getCptBK($id) { global $conf; - $sql = "SELECT t.numero_compte, t.label_compte, t.doc_ref"; + $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; @@ -104,7 +104,7 @@ class AccountancyCategory $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1)"; - $sql .= " GROUP BY t.numero_compte, t.label_compte, t.doc_ref"; + $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; $this->lines_CptBk = array (); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index dc2b3195ee3..a3358337889 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -198,7 +198,7 @@ class AccountancyExport print length_accounta($line->subledger_account) . $separator; print $line->sens . $separator; print price($line->montant) . $separator; - print $line->label_compte . $separator; + print $line->label_operation . $separator; print $line->doc_ref; print $this->end_line; } @@ -220,7 +220,7 @@ class AccountancyExport print $line->piece_num . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print '' . $this->separator; - print $line->label_compte . $this->separator; + print $line->label_operation . $this->separator; print $date . $this->separator; if ($line->sens=='D') { print price($line->montant) . $this->separator; @@ -230,7 +230,7 @@ class AccountancyExport print price($line->montant) . $this->separator; } print $line->doc_ref . $this->separator; - print $line->label_compte . $this->separator; + print $line->label_operation . $this->separator; print $this->end_line; } } @@ -289,7 +289,7 @@ class AccountancyExport print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; - print dol_trunc($line->label_compte, 32) . $this->separator; + print dol_trunc($line->label_operation, 32) . $this->separator; print $this->end_line; } } @@ -320,11 +320,11 @@ class AccountancyExport $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_operation, 25), 25); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); - $Tab['intitule_compte'] = str_pad(self::trunc($data->label_compte, 34), 34); + $Tab['intitule_compte'] = str_pad(self::trunc($data->label_operation, 34), 34); $Tab['end'] = 'O2003'; $Tab['end_line'] = $this->end_line; @@ -359,7 +359,7 @@ class AccountancyExport $Tab['folio'] = '000'; $Tab['date_ecriture'] = $date_ecriture; $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 20), 20); $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount @@ -375,7 +375,7 @@ class AccountancyExport $Tab['devis'] = str_pad($conf->currency, 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['filler3'] = str_repeat(' ', 3); - $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); + $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 32), 32); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['filler4'] = str_repeat(' ', 73); @@ -406,7 +406,7 @@ class AccountancyExport print $line->code_journal . $this->separator; print length_accountg($line->numero_compte) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator; - print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print price2num($line->montant).$this->separator; print $line->sens.$this->separator; diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index a1c90a97b5b..87d1ccd663c 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index a526f9171a6..1dad83512e3 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index d607c1dc287..2e826b55e08 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2016 Alexandre Spangaro +/* Copyright (C) 2014-2016 Olivier Geffroy + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2015-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -80,6 +80,7 @@ class BookKeeping extends CommonObject public $subledger_label; public $numero_compte; public $label_compte; + public $label_operation; public $debit; public $credit; public $montant; @@ -144,6 +145,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -263,6 +267,7 @@ class BookKeeping extends CommonObject $sql .= ", subledger_label"; $sql .= ", numero_compte"; $sql .= ", label_compte"; + $sql .= ", label_operation"; $sql .= ", debit"; $sql .= ", credit"; $sql .= ", montant"; @@ -284,6 +289,7 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; + $sql .= ",'" . $this->db->escape($this->label_operation) . "'"; $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; @@ -393,6 +399,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -438,6 +447,7 @@ class BookKeeping extends CommonObject $sql .= 'subledger_label,'; $sql .= 'numero_compte,'; $sql .= 'label_compte,'; + $sql .= 'label_operation,'; $sql .= 'debit,'; $sql .= 'credit,'; $sql .= 'montant,'; @@ -459,6 +469,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; @@ -531,6 +542,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -567,6 +579,7 @@ class BookKeeping extends CommonObject $this->subledger_label = $obj->subledger_label; $this->numero_compte = $obj->numero_compte; $this->label_compte = $obj->label_compte; + $this->label_operation = $obj->label_operation; $this->debit = $obj->debit; $this->credit = $obj->credit; $this->montant = $obj->montant; @@ -621,6 +634,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -644,9 +658,9 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=' . $value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; - } elseif ($key == 't.label_compte') { + } elseif ($key == 't.label_operation') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; - }else { + } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } @@ -686,6 +700,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -725,7 +740,7 @@ class BookKeeping extends CommonObject public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; @@ -739,6 +754,7 @@ class BookKeeping extends CommonObject $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.montant,"; @@ -801,6 +817,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -945,6 +962,9 @@ class BookKeeping extends CommonObject if (isset($this->label_compte)) { $this->label_compte = trim($this->label_compte); } + if (isset($this->label_operation)) { + $this->label_operation = trim($this->label_operation); + } if (isset($this->debit)) { $this->debit = trim($this->debit); } @@ -988,6 +1008,7 @@ class BookKeeping extends CommonObject $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; + $sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; @@ -1245,14 +1266,15 @@ class BookKeeping extends CommonObject $this->fk_doc = ''; $this->fk_docdet = ''; $this->thirdparty_code = 'CU001'; - $this->subledger_account = '410CU001'; + $this->subledger_account = '41100001'; $this->subledger_label = 'My customer company'; - $this->numero_compte = '410'; - $this->label_compte = ''; + $this->numero_compte = '411'; + $this->label_compte = 'Customer'; + $this->label_operation = 'Sales of pea'; $this->debit = 99.9; $this->credit = ''; $this->montant = ''; - $this->sens = ''; + $this->sens = 'D'; $this->fk_user_author = $user->id; $this->import_key = ''; $this->code_journal = 'VT'; @@ -1358,6 +1380,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -1416,6 +1439,7 @@ class BookKeeping extends CommonObject $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; $line->montant = $obj->montant; @@ -1606,6 +1630,7 @@ class BookKeepingLine public $subledger_label; public $numero_compte; public $label_compte; + public $label_operation; public $debit; public $credit; public $montant; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index c436fdfd088..a10cd24adc4 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index deca83b6f12..24e066917bc 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index a5dfa3941d1..b5778ce86f2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 56765e1ba4f..85a97fb3a1e 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 568edf051ff..bc27ebfa24f 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -50,6 +50,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; $langs->load("companies"); $langs->load("other"); @@ -60,6 +61,7 @@ $langs->load('donations'); $langs->load("accountancy"); $langs->load("trips"); $langs->load("salaries"); +$langs->load("hrm"); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -131,6 +133,7 @@ $paymentdonstatic = new PaymentDonation($db); $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); +$paymentvariousstatic = new PaymentVarious($db); // Get code of finance journal $accountingjournalstatic = new AccountingJournal($db); @@ -208,7 +211,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) // So we excluded 'company' here { // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; @@ -250,9 +253,9 @@ if ($result) { $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); @@ -285,6 +288,15 @@ if ($result) { $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); $tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id; + } else if ($links[$key]['type'] == 'payment_various') { + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $links[$key]['url_id']; + $paymentvariousstatic->label = $links[$key]['label']; + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; + $paymentvariousstatic->fetch($paymentvariousstatic->id); + $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : $langs->trans("CodeNotDef")); + $tabtp[$obj->rowid][$account_various] += $obj->amount; } else if ($links[$key]['type'] == 'banktransfert') { $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabtp[$obj->rowid][$account_transfer] += $obj->amount; @@ -353,7 +365,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $compte->label; + $bookkeeping->label_operation = $val["label"]; $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0 ? $mt : 0); @@ -412,8 +424,11 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = ''; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Ref of various payment } $result = $bookkeeping->create($user); @@ -447,7 +462,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_type = 'bank'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_operation = $tabcompany[$key]['name']; $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0 ? - $mt : 0); @@ -473,7 +488,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; @@ -487,7 +503,23 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_operation = $tabuser[$key]['name']; + $sqlmid = 'SELECT e.ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; + $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport + } } else if ($tabtype[$key] == 'payment_vat') { $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; @@ -499,16 +531,19 @@ if (! $error && $action == 'writebookkeeping') { } else if ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment + } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->subledger_account = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Rowid of various payment } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else { - // FIXME Should be a temporary account ??? + // Temporary account $bookkeeping->doc_ref = $k; - //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->numero_compte = 'CodeNotDef'; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; } $result = $bookkeeping->create($user); @@ -745,6 +780,7 @@ if (empty($action) || $action == 'view') { $vatstatic = new Tva($db); $donationstatic = new Don($db); $salarystatic = new PaymentSalary($db); + $variousstatic = new PaymentVarious($db); llxHeader('', $langs->trans("FinanceJournal")); @@ -913,7 +949,20 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } - + elseif ($tabtype[$key] == 'payment_various') + { + $sqlmid = 'SELECT v.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; + $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $variousstatic->fetch($objmid->id); + $ref=$variousstatic->getNomUrl(1); + } + else dol_print_error($db); + } /*$invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 3da9e09aeda..6dba1443ae1 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -136,7 +136,7 @@ if ($result) { // Define array to display all VAT rates that use this accounting account $compta_tva if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); @@ -148,7 +148,7 @@ if ($result) { $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabuser[$obj->rowid] = array ( 'id' => $obj->uid, - 'name' => $obj->firstname.' '.$obj->lastname, + 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'user_accountancy_code' => $obj->user_accountancy_account ); @@ -169,6 +169,7 @@ if ($action == 'writebookkeeping') { $db->begin(); + // Thirdparty if (! $errorforline) { foreach ( $tabttc[$key] as $k => $mt ) { @@ -183,7 +184,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; - $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -212,9 +213,9 @@ if ($action == 'writebookkeeping') { } } + // Fees if (! $errorforline) { - // Fees foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k, true); @@ -231,7 +232,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_operation = $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -261,9 +262,9 @@ if ($action == 'writebookkeeping') { } } + // VAT if (! $errorforline) { - // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -277,7 +278,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 9ef1afdac38..e80ae3ba059 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * @@ -208,10 +208,10 @@ if ($action == 'writebookkeeping') { $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = $tabcompany[$key]['code_client']; + // Thirdparty if (! $errorforline) { foreach ( $tabttc[$key] as $k => $mt ) { - // get compte id and label if ($mt) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -223,7 +223,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = ''; // TODO To complete - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -272,7 +272,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -319,7 +319,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 4eb4dc72171..a50f8be7fb9 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,13 +1,13 @@ * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014 Raphaël Doursenaud * * 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 @@ -239,7 +239,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -286,7 +286,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -332,7 +332,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; diff --git a/htdocs/accountancy/report/result.php b/htdocs/accountancy/report/result.php index aa31185604a..801ba0a2007 100644 --- a/htdocs/accountancy/report/result.php +++ b/htdocs/accountancy/report/result.php @@ -1,6 +1,6 @@ - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 69a7855dfd2..b73c40ced74 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 805c5e40420..3aa8e501bb9 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 164525d5214..dc6b5e7ec20 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 26000c3fb66..93aeb1746f5 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index f69b47a8017..b5b6920e853 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Charlie Benke * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d0c0d61a954..939872ce7fd 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,9 @@ */ /** - * \file htdocs/compta/bank/class/paymentvarious.class.php - * \ingroup salaries - * \brief Class for salaries module payment + * \file htdocs/compta/bank/class/paymentvarious.class.php + * \ingroup bank + * \brief Class for various payment */ // Put here all includes required by your class file @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class PaymentVarious extends CommonObject { - //public $element='payment_various'; //!< Id that identify managed objects + //public $element='payment_various'; //!< Id that identify managed objects //public $table_element='payment_various'; //!< Name of table without prefix where object is stored var $tms; @@ -74,7 +74,6 @@ class PaymentVarious extends CommonObject $error=0; // Clean parameters - $this->fk_user=trim($this->fk_user); $this->amount=trim($this->amount); $this->label=trim($this->label); $this->note=trim($this->note); @@ -85,10 +84,9 @@ class PaymentVarious extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET"; $sql.= " tms=".$this->db->idate($this->tms).","; - $sql.= " fk_user=".$this->fk_user.","; $sql.= " datep=".$this->db->idate($this->datep).","; $sql.= " datev=".$this->db->idate($this->datev).","; $sql.= " sens=".$this->sens.","; @@ -114,10 +112,10 @@ class PaymentVarious extends CommonObject if (! $notrigger) { - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers } if (! $error) @@ -178,7 +176,6 @@ class PaymentVarious extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); $this->sens = $obj->sens; @@ -252,12 +249,12 @@ class PaymentVarious extends CommonObject $this->id=0; $this->tms=''; - $this->fk_user=''; $this->datep=''; $this->datev=''; $this->sens=''; $this->amount=''; $this->label=''; + $this->accountancy_code=''; $this->note=''; $this->fk_bank=''; $this->fk_user_author=''; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index b50bf07d31a..99362167a07 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -49,7 +49,7 @@ $confirm=GETPOST('confirm','alpha'); $rowid=GETPOST("rowid",'int'); $orig_account=GETPOST("orig_account"); $backtopage=GETPOST('backtopage'); -$cancel=GETPOSt('cancel'); +$cancel=GETPOST('cancel'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); From 5320ebc0515e865553004f2febe718b3a46b9620 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:16:52 +0200 Subject: [PATCH 147/342] getTotalWeightVolume : add conversion Lb & oz to KG New conversion value : Oz once Little az a wizzard... --- htdocs/core/class/commonobject.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3ac7cb6ffb3..bd5d8a6b831 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3097,9 +3097,18 @@ abstract class CommonObject $trueWeightUnit=pow(10, $weightUnit); $totalWeight += $weight * $qty * $trueWeightUnit; } - else - { - $totalWeight += $weight * $qty; // This may be wrong if we mix different units + else { + if ($weight_units == 99) { + // conversion 1 Livre = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 once = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else + $totalWeight += $weight * $qty; // This may be wrong if we mix different units } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { From 5b7a8e9c90f82b4abe7c0a4dff84603b16f5884f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:17:36 +0200 Subject: [PATCH 148/342] Fix missing signature when sending email from user card --- htdocs/commande/card.php | 25 ++++++++----- htdocs/core/class/html.formmail.class.php | 6 ++-- htdocs/langs/en_US/other.lang | 1 + htdocs/user/card.php | 43 ++++------------------- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 83135a8c0f5..f837119730c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2621,6 +2621,19 @@ if ($action == 'create' && $user->rights->commande->creer) $outputlangs->load('commercial'); } + // Show email form + + // By default if $action=='presend' + $titreform='SendOrderByMail'; + $topicmail=''; + if (empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); + } else if (! empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); + } + $action='send'; + $modelmail='order_send'; + // Build document if it not exists if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2635,7 +2648,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
    '; print '
    '; print '
    '; - print load_fiche_titre($langs->trans('SendOrderByMail')); + print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(''); @@ -2662,11 +2675,7 @@ if ($action == 'create' && $user->rights->commande->creer) $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withtocc = $liste; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } + $formmail->withtopic = $topicmail; $formmail->withfile = 2; $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; @@ -2696,8 +2705,8 @@ if ($action == 'create' && $user->rights->commande->creer) } // Tableau des parametres complementaires - $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'order_send'; + $formmail->param['action'] = $action; + $formmail->param['models'] = $modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 860d3fcfb1c..d59ac6c25af 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -288,14 +288,15 @@ class FormMail extends Form $outputlangs->load('other'); } - // Get message template + // Get message template for $this->param["models"] into c_email_templates $model_id=0; if (array_key_exists('models_id',$this->param)) { $model_id=$this->param["models_id"]; } $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); - //var_dump($arraydefaultmessage); + //var_dump($this->param["models"]); + //var_dump($arraydefaultmessage); $out.= "\n".'
    '."\n"; if ($this->withform == 1) @@ -876,6 +877,7 @@ class FormMail extends Form elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } $ret['label']='default'; $ret['topic']=''; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..b151614ce3c 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -81,6 +81,7 @@ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find her PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ +PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
    (manual module selection) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 089820da442..a2938a89712 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1659,13 +1659,11 @@ else } if ($action == 'presend') { - /* - * Affiche formulaire mail - */ + // Show email form // By default if $action=='presend' $titreform='SendMail'; - $topicmail=''; + $topicmail=1; $action='send'; $modelmail='user'; @@ -1680,9 +1678,8 @@ else $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->default_lang; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + // $newlang = $object->thirdparty->default_lang; // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -1701,7 +1698,7 @@ else $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); } $formmail->withfrom=1; - $formmail->withtopic=1; + $formmail->withtopic=$topicmail; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$object->email; $formmail->withtofree=1; $formmail->withtocc=1; @@ -1711,37 +1708,9 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - //$formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object); $formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__FIRSTNAME__']=$object->firstname; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - - //Find the good contact adress - /* - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) - { - foreach($contactarr as $contact) - { - if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - }*/ - // Tableau des parametres complementaires du post $formmail->param['action']=$action; From e98bc90489b8c9085904ffc7762cd0b63e48ada8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:18:59 +0200 Subject: [PATCH 149/342] introduce OZ : once weight --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 01064c8ffa3..1dbfbc7662f 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -307,7 +307,7 @@ class FormProduct $return=''; $measuring_units=array(); - if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,99=>1); + if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1); else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1); else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3 From 17247c64f0fbe50c0720e5c13c70965892ae18e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:26:01 +0200 Subject: [PATCH 150/342] add WeightUnitonce --- htdocs/core/lib/product.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 5aec64f3ce0..16bedc4d346 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,8 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') { From f0bc72cda4aa3864dcfaba252537a3005027bad8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 10:27:00 +0200 Subject: [PATCH 151/342] WeightUnitonce translation --- htdocs/langs/en_US/other.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..120b1dcd790 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,6 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound +WeightUnitonce=once Length=Length LengthUnitm=m LengthUnitdm=dm From bebe7baa80990fa25f37b25c5ac8620cbf90ea6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:44:08 +0200 Subject: [PATCH 152/342] Fix images into medias not reabable into send emails --- htdocs/core/actions_sendmails.inc.php | 31 ++++++++++++++++++--------- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index dded23e6cbf..7bb3e8aec49 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -31,7 +31,7 @@ /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { $trackid = GETPOST('trackid','aZ09'); @@ -137,7 +137,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); } else @@ -229,7 +229,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (dol_strlen($sendto)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $langs->load("commercial"); @@ -254,11 +259,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $message = $_POST['message']; - + + // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. + // + // become + // + $message=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); + $sendtobcc= GETPOST('sendtoccc'); - if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); @@ -371,7 +382,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_object($object)) { if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically - + $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) @@ -392,7 +403,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - + if ($error) { dol_print_error($db); @@ -403,7 +414,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) + if ($conf->dolimail->enabled) { header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); exit; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a9fb8e52734..3c771220c70 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Make a change into HTML code to allow to include images from medias directory. // // become - // + // $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f57a23d23c..ac982973ef3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -44,6 +44,7 @@ ErrorFailedToWriteInDir=Failed to write in directory %s ErrorFoundBadEmailInFile=Found incorrect email syntax for %s lines in file (example line %s with email=%s) ErrorUserCannotBeDelete=User cannot be deleted. May be it is associated to Dolibarr entities. ErrorFieldsRequired=Some required fields were not filled. +ErrorSubjectIsRequired=The email topic is required ErrorFailedToCreateDir=Failed to create a directory. Check that Web server user has permissions to write into Dolibarr documents directory. If parameter safe_mode is enabled on this PHP, check that Dolibarr php files owns to web server user (or group). ErrorNoMailDefinedForThisUser=No mail defined for this user ErrorFeatureNeedJavascript=This feature need javascript to be activated to work. Change this in setup - display. From 7c41c9a3e4aedb97742ab505afe957281e9527e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:43:00 +0200 Subject: [PATCH 153/342] Fix activation of dependency for a dedicated country. BlockedLog depends now on CashDesk only. --- htdocs/admin/modules.php | 8 +++-- htdocs/core/lib/admin.lib.php | 20 ++++++------ htdocs/core/modules/modBlockedLog.class.php | 6 ++-- htdocs/core/modules/modCashDesk.class.php | 6 ++-- htdocs/core/modules/modFacture.class.php | 31 +++++++++---------- htdocs/langs/en_US/admin.lang | 6 ++-- htdocs/langs/en_US/main.lang | 3 +- .../core/modules/modMyModule.class.php | 2 ++ htdocs/theme/md/style.css.php | 1 - 9 files changed, 45 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5d5886b5415..d3221f40505 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -80,7 +80,7 @@ $urldolibarrmodules='https://www.dolistore.com/'; * Actions */ -if (GETPOST('buttonreset')) +if (GETPOST('buttonreset','alpha')) { $search_keyword=''; $search_status=''; @@ -738,13 +738,17 @@ if ($mode == 'common') print ''."\n"; foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { - if (! empty($modules[$keymodule]->const_name)) // If module that request warning is on + $keymodulelowercase=strtolower(preg_replace('/^mod/','',$keymodule)); + if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on { foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { if ($keycountry == 'always' || $keycountry == $mysoc->country_code) { $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); + $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName(); + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name; + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); } } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index ba5f099365c..e90f006ac7e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -756,7 +756,7 @@ function purgeSessions($mysessionid) */ function activateModule($value,$withdeps=1) { - global $db, $modules, $langs, $conf; + global $db, $modules, $langs, $conf, $mysoc; // Check parameters if (empty($value)) { @@ -813,7 +813,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); // Enable module - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -848,19 +848,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -879,12 +879,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1221,7 +1221,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if ($result) { $obj = $db->fetch_object($result); // Take first result of select - + // For avoid warning in strict mode if (empty($obj)) { @@ -1360,7 +1360,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; @@ -1391,7 +1391,7 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); $sql.= ")"; - + dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index f3f3be971b5..3125627c007 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -65,9 +65,9 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- $this->hidden = false; // A condition to disable module - $this->depends = array('modFacture'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array(); // Constants diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ec8764c9017..e5ba473c1c7 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -65,11 +65,13 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies - $this->depends = array("modBanque","modFacture","modProduct"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants $this->const = array(); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3af85a1944d..40e2a03d161 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -64,14 +64,13 @@ class modFacture extends DolibarrModules $this->dirs = array("/facture/temp"); // Dependencies - $this->depends = array('always'=>"modSociete", 'FR'=>'modBlockedLog'); + $this->depends = array('always'=>"modSociete"); $this->requiredby = array("modComptabilite","modAccounting"); $this->conflictwith = array(); $this->langfiles = array("bills","companies","compta","products"); - $this->warnings_activation = array('FR'=>'WarningNoteModuleInvoiceForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') - $this->warnings_activation = array(); - $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') - + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') + // Config pages $this->config_page_url = array("facture.php"); @@ -99,7 +98,7 @@ class modFacture extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "__(Draft)__"; @@ -107,7 +106,7 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ - + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); $this->boxes = array( @@ -116,16 +115,16 @@ class modFacture extends DolibarrModules 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') ); - // Cronjobs + // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) - ); - // List of cron jobs entries to add - // Example: + ); + // List of cron jobs entries to add + // Example: // $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) // ); // Permissions @@ -206,8 +205,8 @@ class modFacture extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1aa79c2dced..0ba5ab270bc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -104,7 +104,7 @@ MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) DetailPosition=Sort number to define menu position AllMenus=All -NotConfigured=Module not configured +NotConfigured=Module/Application not configured Active=Active SetupShort=Setup OtherOptions=Other options @@ -114,7 +114,6 @@ CurrentValueSeparatorThousand=Thousand separator Destination=Destination IdModule=Module ID IdPermissions=Permissions ID -Modules=Modules LanguageBrowserParameter=Parameter %s LocalisationDolibarrParameters=Localisation parameters ClientTZ=Client Time Zone (user) @@ -1700,7 +1699,8 @@ UserHasNoPermissions=This user has no permission defined TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")
    Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)
    Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the editor of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. +WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8ea14fdb305..a35342f2af9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,7 +366,8 @@ VATRate=Tax Rate Average=Average Sum=Sum Delta=Delta -Module=Module +Module=Module/Application +Modules=Modules/Applications Option=Option List=List FullList=Full list diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index dc98c327cb3..60889bdf279 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -114,6 +114,8 @@ class modMyModule extends DolibarrModules $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mymodule@mymodule"); + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5fbd8455919..e96fa032538 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2528,7 +2528,6 @@ div.pagination li.noborder a:hover { div.pagination li a, div.pagination li span { background-color: #fff; - border: 1px solid #ddd; } div.pagination li:first-child a, div.pagination li:first-child span { From a4f34539ea92cf634c49a98904c6aa92eb0015b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:46:45 +0200 Subject: [PATCH 154/342] Fix translation --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0ba5ab270bc..e2b5825f14f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -466,7 +466,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,7 +565,7 @@ Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards Module3200Name=Non Reversible Logs -Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table of chained event that can be then read and exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company From 8a1de52f3c5b80c10c290c6028e0cc61cdf003f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 12:00:33 +0200 Subject: [PATCH 155/342] Fix translation --- htdocs/admin/index.php | 6 +++--- htdocs/langs/en_US/admin.lang | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index a1ac45244e1..9ac33f1cc3d 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; -print $langs->trans("SetupDescription2")."

    "; +print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."

    "; print '
    '; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit')); +print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup")); if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); @@ -88,7 +88,7 @@ print '
    '; print '
    '; // Show info setup module -print img_picto('','puce').' '.$langs->trans("SetupDescription4",DOL_URL_ROOT.'/admin/modules.php?mainmenu=home'); +print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules")); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e2b5825f14f..23b207b4fea 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -190,7 +190,7 @@ FeatureAvailableOnlyOnStable=Feature only available on official stable versions Rights=Permissions BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown. -ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after enabling module. Click on button on/off to enable an application/module. +ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after activating it. Click on button on/off to enable a module/application. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module wil then be visible on the tab %s. ModulesMarketPlaces=Find external modules... @@ -270,7 +270,7 @@ FeatureNotAvailableOnLinux=Feature not available on Unix like systems. Test your SubmitTranslation=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit your change to www.transifex.com/dolibarr-association/dolibarr/ SubmitTranslationENUS=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit modified files on dolibarr.org/forum or for developers on github.com/Dolibarr/dolibarr. ModuleSetup=Module setup -ModulesSetup=Modules setup +ModulesSetup=Modules/Application setup ModuleFamilyBase=System ModuleFamilyCrm=Customer Relation Management (CRM) ModuleFamilySrm=Supplier Relation Management (SRM) @@ -997,9 +997,9 @@ Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed memb Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do Delays_MAIN_DELAY_EXPENSEREPORTS=Tolerance delay (in days) before alert for expense reports to approve SetupDescription1=The setup area is for initial setup parameters before starting to use Dolibarr. -SetupDescription2=The two most important setup steps are the first two in the setup menu on the left: Company/Organisation setup page and Modules setup page: -SetupDescription3=Parameters in menu Setup -> Company/Organisation are required because submitted data are used on Dolibarr displays and to customize the default behaviour of the software (for country-related features for example). -SetupDescription4=Parameters in menu Setup -> Modules are required because Dolibarr is not a monolithic ERP/CRM but a collection of several modules, all more or less independent. New features will be added to menus for every module you'll enable. +SetupDescription2=The two mandatory setup steps are the first two in the setup menu on the left: %s setup page and %s setup page : +SetupDescription3=Parameters in menu %s -> %s are required because defined data are used on Dolibarr screens and to customize the default behavior of the software (for country-related features for example). +SetupDescription4=Parameters in menu %s -> %s are required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features will be added to menus for every module you will activate. SetupDescription5=Other menu entries manage optional parameters. LogEvents=Security audit events Audit=Audit @@ -1015,7 +1015,7 @@ BrowserOS=Browser OS ListOfSecurityEvents=List of Dolibarr security events SecurityEventsPurged=Security events purged LogEventDesc=You can enable here the logging for Dolibarr security events. Administrators can then see its content via menu System tools - Audit. Warning, this feature can consume a large amount of data in database. -AreaForAdminOnly=Those features can be used by administrator users only. +AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" or "Save" button at bottom of page) From 240e9637fa03e1bf03add7712f050b26d2d20e7e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 14:43:15 +0200 Subject: [PATCH 156/342] New: add extrafields API REST --- .../class/api_dictionaryextrafields.class.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 htdocs/api/class/api_dictionaryextrafields.class.php diff --git a/htdocs/api/class/api_dictionaryextrafields.class.php b/htdocs/api/class/api_dictionaryextrafields.class.php new file mode 100644 index 00000000000..69f574797c7 --- /dev/null +++ b/htdocs/api/class/api_dictionaryextrafields.class.php @@ -0,0 +1,112 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Luracast\Restler\RestException; + +//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + +/** + * API class for extra fields (content of the extrafields) + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class DictionaryExtraFields extends DolibarrApi +{ + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } + + /** + * Get the list of extra fields. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" + * @return List of events types + * + * @throws RestException + */ + function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + { + $list = array(); + + if ($type == 'thirdparty') $type='societe'; + if ($type == 'contact') $type='socpeople'; + + $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed"; + $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; + $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; + if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $this->db->order($sortfield, $sortorder); + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + while ($tab = $this->db->fetch_object($resql)) + { + // New usage + $list[$tab->elementtype][$tab->name]['type']=$tab->type; + $list[$tab->elementtype][$tab->name]['label']=$tab->label; + $list[$tab->elementtype][$tab->name]['size']=$tab->size; + $list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; + $list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; + $list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; + $list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; + $list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; + $list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); + $list[$tab->elementtype][$tab->name]['pos']=$tab->pos; + $list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; + $list[$tab->elementtype][$tab->name]['perms']=$tab->perms; + $list[$tab->elementtype][$tab->name]['list']=$tab->list; + $list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; + } + } + } + else + { + throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); + } + + if (! count($list)) + { + throw new RestException(404, 'No extrafield found'); + } + + return $list; + } + +} From 48866f07325c1374c1f8112382674f1160b3a74c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 14:43:31 +0200 Subject: [PATCH 157/342] Fix: wrong array format --- htdocs/core/class/extrafields.class.php | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4b5f151ec72..24be010ff4c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -702,20 +702,20 @@ class ExtraFields $this->attribute_hidden[$tab->name]=$tab->ishidden; // New usage - $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; - $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; - $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; - $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; - $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; - $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; - $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; - $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; - $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); - $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; - $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; - $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; - $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; - $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; + $this->attributes[$tab->elementtype][$tab->name]['type']=$tab->type; + $this->attributes[$tab->elementtype][$tab->name]['label']=$tab->label; + $this->attributes[$tab->elementtype][$tab->name]['size']=$tab->size; + $this->attributes[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; + $this->attributes[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; + $this->attributes[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; + $this->attributes[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; + $this->attributes[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; + $this->attributes[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype][$tab->name]['pos']=$tab->pos; + $this->attributes[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; + $this->attributes[$tab->elementtype][$tab->name]['perms']=$tab->perms; + $this->attributes[$tab->elementtype][$tab->name]['list']=$tab->list; + $this->attributes[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; } } if ($elementtype) $this->attributes[$elementtype]['loaded']=1; From 12cab2dfe08695f75199afb84779c84b897101e9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:03 +0200 Subject: [PATCH 158/342] Once to Ounce --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 16bedc4d346..7048b8570c6 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -441,7 +441,7 @@ function measuring_units_string($unit,$measuring_style='') $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitonce"); + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); } else if ($measuring_style == 'size') From db173632674e7fd6ae22c0965ae8e9361b607502 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:30:37 +0200 Subject: [PATCH 159/342] Update other.lang --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 120b1dcd790..bf01ba734f3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -123,7 +123,7 @@ WeightUnitkg=kg WeightUnitg=g WeightUnitmg=mg WeightUnitpound=pound -WeightUnitonce=once +WeightUnitounce=ounce Length=Length LengthUnitm=m LengthUnitdm=dm From fcdf68db6a1175f2faa5e9a95afef05398c29fb5 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 17 Jun 2017 16:31:54 +0200 Subject: [PATCH 160/342] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd5d8a6b831..b87b3d28ea8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3099,11 +3099,11 @@ abstract class CommonObject } else { if ($weight_units == 99) { - // conversion 1 Livre = 0.45359237 KG + // conversion 1 Pound = 0.45359237 KG $trueWeightUnit = 0.45359237; $totalWeight += $weight * $qty * $trueWeightUnit; } elseif ($weight_units == 98) { - // conversion 1 once = 0.0283495 KG + // conversion 1 Ounce = 0.0283495 KG $trueWeightUnit = 0.0283495; $totalWeight += $weight * $qty * $trueWeightUnit; } From 04821376200381ef232947147b8063bf189c2f9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 18:03:53 +0200 Subject: [PATCH 161/342] Fix warning --- htdocs/install/inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index dc7e29b19f5..b9efc4eb8a4 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -385,12 +385,12 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='',$css // We force the content charset header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -453,7 +453,7 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0) print '
    '; if ($nonext == '2') { - print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'

    '; + print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'

    '; } print '"'; From 285b5563d66cb0cde3f20ad86e23641a0f4bf4dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 18:23:26 +0200 Subject: [PATCH 162/342] Update changelog --- ChangeLog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 78793b9d419..c43fd92f676 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,22 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 5.0.4 compared to 5.0.3 ***** +FIX: #6880 +FIX: #6925 +FIX: #6926 +FIX: Can set supplier invoice to billed. +FIX: Can't create invoice if PO disapproved +FIX: contratligne update +FIX: CVE-2017-7886 +FIX: default param +FIX: Line of invoices not inserted when using POS module and VAT NPR. +FIX: origin & originid on supplierproposal +FIX: Redirect to payment page from member subscription page failed if a unique security key was defined. +FIX: REST api to get project when user has permission to read all. +FIX: situation_progress param default value must be 100 and not 0 +FIX: SQL injection on user/index.php parameter search_statut. +FIX: Warnings ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty From fd9c30fd11ca2faa2b838977fd81219273d4d362 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 17 Jun 2017 18:30:11 +0200 Subject: [PATCH 163/342] Revert "Fix: wrong array format" This reverts commit 48866f07325c1374c1f8112382674f1160b3a74c. --- htdocs/core/class/extrafields.class.php | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 24be010ff4c..4b5f151ec72 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2009-2012 Laurent Destailleur - * Copyright (C) 2009-2017 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Charles-Fr BENKE - * Copyright (C) 2016 Raphaël Doursenaud +/* Copyright (C) 2002-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2009-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Charles-Fr BENKE + * Copyright (C) 2016 Raphaël Doursenaud * * 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 @@ -702,20 +702,20 @@ class ExtraFields $this->attribute_hidden[$tab->name]=$tab->ishidden; // New usage - $this->attributes[$tab->elementtype][$tab->name]['type']=$tab->type; - $this->attributes[$tab->elementtype][$tab->name]['label']=$tab->label; - $this->attributes[$tab->elementtype][$tab->name]['size']=$tab->size; - $this->attributes[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype; - $this->attributes[$tab->elementtype][$tab->name]['default']=$tab->fielddefault; - $this->attributes[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed; - $this->attributes[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique; - $this->attributes[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired; - $this->attributes[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : ''); - $this->attributes[$tab->elementtype][$tab->name]['pos']=$tab->pos; - $this->attributes[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable; - $this->attributes[$tab->elementtype][$tab->name]['perms']=$tab->perms; - $this->attributes[$tab->elementtype][$tab->name]['list']=$tab->list; - $this->attributes[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden; + $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; + $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; + $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; + $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; + $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; + $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; + $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; + $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; + $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; + $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; + $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; + $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; } } if ($elementtype) $this->attributes[$elementtype]['loaded']=1; From a6b4b15e07a29934b483c93b8487eb6b7dee0218 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 19:40:48 +0200 Subject: [PATCH 164/342] Work on modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 6 +- htdocs/modulebuilder/index.php | 142 +++++++++++++++++- .../modulebuilder/template/class/MyObject.txt | 1 + ...class.class.php => api_myobject.class.php} | 0 .../template/class/myobject.class.php | 4 +- ...bject_mymodule.png => object_myobject.png} | Bin 6 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 htdocs/modulebuilder/template/class/MyObject.txt rename htdocs/modulebuilder/template/class/{myobject_api_class.class.php => api_myobject.class.php} (100%) rename htdocs/modulebuilder/template/img/{myobject_mymodule.png => object_myobject.png} (100%) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index adce0950b88..b8300182b05 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,11 +1,15 @@ # Dolibarr language file - Source file is en_US - loan ModuleBuilderDesc=This tools give you utilites to build or edit your own module. -EnterNameOfModuleDesc=Enter name of the module to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) +EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) +EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module +NewObject=New object ModuleKey=Key for new module +ObjectKey=Key for new object ModuleInitialized=Module initialized +FilesForObjectInitialized=Files for new object initialized ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8cabec1bdfb..0f60d76ca4f 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -33,11 +33,13 @@ $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm','alpha'); $module=GETPOST('module','alpha'); $tab=GETPOST('tab','aZ09'); +$tabobj=GETPOST('tabobj','alpha'); if (empty($module)) $module='initmodule'; if (empty($tab)) $tab='description'; +if (empty($tabobj)) $tabobj='newobject'; $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); - +$objectname=dol_sanitizeFileName(GETPOST('objectname','alpha')); // Security check if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed'); @@ -80,6 +82,18 @@ if ($dirins && $action == 'initmodule' && $modulename) } } + // Delete some files + dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_list.php'); + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/scripts/myobject.php'); + dol_delete_file($destdir.'/img/object_myobject.png'); + dol_delete_file($destdir.'/class/myobject.class.php'); + dol_delete_file($destdir.'/class/api_myobject.class.php'); + dol_delete_file($destdir.'/class/MyObject.txt'); + // Edit PHP files if (! $error) { @@ -113,6 +127,86 @@ if ($dirins && $action == 'initmodule' && $modulename) } } +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', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + foreach($filetogenerate as $srcfile => $destfile) + { + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + } + } + else + { + // Copy is ok + } + } + + // Edit PHP files + foreach($filetogenerate as $destfile) + { + $phpfileval['fullname'] = $destdir.'/'.$destfile; + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'htdocs/modulebuilder/template/'=>'', + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); + + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } + } + + if (! $error) + { + setEventMessages('FilesForObjectInitialized', null); + } +} + + if ($dirins && $action == 'confirm_delete') { $modulelowercase=strtolower($module); @@ -485,9 +579,53 @@ elseif (! empty($module)) if ($tab == 'objects') { - print $langs->trans("FeatureNotYetAvailable"); + $head3 = array(); + $h=0; + $modulelowercase=strtolower($module); + + // Dir for module + $dir = $dirins.'/'.$modulelowercase.'/class'; + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=newobject'; + $head3[$h][1] = $langs->trans("NewObject"); + $head3[$h][2] = 'newobject'; + $h++; + + $listofobject = dol_dir_list($dir , 'files', 0, '\.txt$'); + foreach($listofobject as $fileobj) + { + $objectname = preg_replace('/\.txt$/', '', $fileobj['name']); + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname; + $head3[$h][1] = $objectname; + $head3[$h][2] = $objectname; + $h++; + } + + dol_fiche_head($head3, $tabobj, '', -1, ''); + + if ($tabobj == 'newobject') + { + // New module + print '
    '; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfObjectDesc").'

    '; + + print ''; + print ''; + print '
    '; + } + + if ($tabobj == 'fields') + { + print $langs->trans("FeatureNotYetAvailable").'

    '; + } } if ($tab == 'menus') diff --git a/htdocs/modulebuilder/template/class/MyObject.txt b/htdocs/modulebuilder/template/class/MyObject.txt new file mode 100644 index 00000000000..37ccaca81ed --- /dev/null +++ b/htdocs/modulebuilder/template/class/MyObject.txt @@ -0,0 +1 @@ +# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject_api_class.class.php b/htdocs/modulebuilder/template/class/api_myobject.class.php similarity index 100% rename from htdocs/modulebuilder/template/class/myobject_api_class.class.php rename to htdocs/modulebuilder/template/class/api_myobject.class.php diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f2d4daee8d4..9e66b9410f6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -31,11 +31,11 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class MyModuleObject + * Class MyObject * * Put here description of your class. */ -class MyModuleObject extends CommonObject +class MyObject extends CommonObject { /** * @var string Id to identify managed object diff --git a/htdocs/modulebuilder/template/img/myobject_mymodule.png b/htdocs/modulebuilder/template/img/object_myobject.png similarity index 100% rename from htdocs/modulebuilder/template/img/myobject_mymodule.png rename to htdocs/modulebuilder/template/img/object_myobject.png From 69b26dcb4ebea5a36cd6dcfb9fbf4ced48a910de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 21:23:52 +0200 Subject: [PATCH 165/342] Work on modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 10 +- htdocs/modulebuilder/index.php | 152 ++++++++++++++++-- .../template/class/myobject.class.php | 22 ++- 3 files changed, 159 insertions(+), 25 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index b8300182b05..8d9a31cfdf7 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -17,7 +17,7 @@ ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. -ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file. +ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost ! DangerZone=Danger zone BuildPackage=Build package @@ -25,4 +25,10 @@ ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module t ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description EditorName=Name of editor -EditorUrl=URL of editor \ No newline at end of file +EditorUrl=URL of editor +DescriptorFile=Descriptor file of module +ClassFile=File for PHP class +ApiClassFile=File for PHP API class +PageForList=PHP page for list of record +PageForCreateEditView=PHP page to create/edit/view a record +PathToModulePackage=Path to zip of module/application package \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0f60d76ca4f..d9ae491b654 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -454,7 +454,9 @@ elseif (! empty($module)) $head2 = array(); $h=0; - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); + $modulelowercase=strtolower($module); + + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive"); if (! empty($conf->$module->enabled)) { $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); @@ -513,7 +515,12 @@ elseif (! empty($module)) if ($tab == 'description') { - print '
    '; + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.'
    '; + print '
    '; + + print '
    '; print '
    '; print ''; @@ -579,12 +586,9 @@ elseif (! empty($module)) if ($tab == 'objects') { - $head3 = array(); $h=0; - $modulelowercase=strtolower($module); - // Dir for module $dir = $dirins.'/'.$modulelowercase.'/class'; @@ -621,10 +625,92 @@ elseif (! empty($module)) print ''; print ''; } - - if ($tabobj == 'fields') + else { - print $langs->trans("FeatureNotYetAvailable").'

    '; + 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.'
    '; + + $result = dol_include_once($pathtoclass); + $tmpobjet = new $tabobj($db); + + $reflector = new ReflectionClass($tabobj); + $properties = $reflector->getProperties(); + $propdefault = $reflector->getDefaultProperties(); + + print load_fiche_titre($langs->trans("Properties"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + foreach($properties as $propkey => $propval) + { + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + + // Discard generic properties + if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue; + + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + + + print ''; + print ''; + + print ''; + + print ''; + + print ''; + print ''; + } + } + print '
    '.$langs->trans("Property").''.$langs->trans("Description").''.$langs->trans("Type").''.$langs->trans("DefaultValue").'
    '; + print ''; + print '
    '; + print $propname; + print ''; + + print ''; + + print ''; + print $propdefault[$propname]; + print ''; + + print '
    '; + + print ''; + } + catch(Exception $e) + { + print $e->getMessage(); + } } } @@ -666,10 +752,9 @@ elseif (! empty($module)) $var=True; foreach ($triggers as $trigger) { - print ''; print ''.$trigger['picto'].''; - print ''.$trigger['file'].''; + print ''.$trigger['relpath'].''; print ''.$trigger['status'].''; print ''; $text=$trigger['info']; @@ -698,11 +783,56 @@ elseif (! empty($module)) print '
    '; } + $modulelowercase=strtolower($module); + + // Zip file to build + $FILENAMEZIP=''; + + // Load module + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + $class='mod'.$module; + + if (class_exists($class)) + { + try { + $moduleobj = new $class($db); + } + catch(Exception $e) + { + $error++; + dol_print_error($e->getMessage()); + } + } + else + { + $error++; + $langs->load("errors"); + dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $arrayversion=explode('.',$moduleobj->version,3); + if (count($arrayversion)) + { + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; + } + + print ' '. $langs->trans("PathToModulePackage") . ' : '; + if (! dol_is_file($outputfile)) print ''.$langs->trans("PackageFileNotYetGenerated").''; + else { + print ''.$outputfile.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; + } + print '

    '; + + print '

    '; + print '
    '; print ''; print ''; print ''; - print ''; + print ''; print '
    '; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9e66b9410f6..4993f60f83c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -21,8 +21,8 @@ /** * \file htdocs/modulebuilder/template/class/myobject.class.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * \ingroup mymodule + * \brief This file is a CRUD class file for MyObject (Create/Read/Update/Delete) */ // Put here all includes required by your class file @@ -31,24 +31,22 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class MyObject - * - * Put here description of your class. + * Class for MyObject */ class MyObject extends CommonObject { /** * @var string Id to identify managed object */ - public $element = 'mymoduleobject'; + public $element = 'myobject'; /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'mymoduleobject'; + public $table_element = 'myobject'; /** * @var array Array with all fields and their property */ - public $picto = 'generic'; + public $picto = 'myobject'; /** * @var array Array with all fields and their property */ @@ -67,12 +65,12 @@ class MyObject extends CommonObject protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - public $table_element_line = 'mymoduleobjectdet'; - public $class_element_line = 'MyModuleObjectline'; - public $fk_element = 'fk_mymoduleobject'; + public $table_element_line = 'myobjectdet'; + public $class_element_line = 'MyObjectline'; + public $fk_element = 'fk_myobject'; /** - * @var MyModuleObjectLine[] Lines + * @var MyObjectLine[] Lines */ public $lines = array(); From 862b12abfd4bef2915abf492dd6fb7790657d234 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 21:28:29 +0200 Subject: [PATCH 166/342] Fix responsive --- htdocs/opensurvey/card.php | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 18326321a4b..c634ca1ceaa 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -67,48 +67,48 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if ($cancel) $action=''; - + // Delete if ($action == 'delete_confirm') { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $result=$object->delete($user,'',$numsondage); - + header('Location: '.dol_buildpath('/opensurvey/list.php',1)); exit(); } - + // Close if ($action == 'close') { $object->status = Opensurveysondage::STATUS_CLOSED; $object->update($user); } - + // Reopend if ($action == 'reopen') { $object->status = Opensurveysondage::STATUS_VALIDATED; $object->update($user); } - + // Update if ($action == 'update') { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $error=0; - + if (! GETPOST('nouveautitre')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); $error++; $action = 'edit'; } - + if (! $error) { $object->titre = GETPOST('nouveautitre'); @@ -118,7 +118,7 @@ if (empty($reshook)) $object->allow_comments = GETPOST('cancomment') == 'on' ? true : false; $object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false; $object->mailsonde = GETPOST('mailsonde') == 'on' ? true : false; - + $res=$object->update($user); if ($res < 0) { @@ -132,7 +132,7 @@ if (empty($reshook)) if (GETPOST('ajoutcomment')) { $error=0; - + if (! GETPOST('comment')) { $error++; @@ -143,33 +143,33 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } - + if (! $error) { $comment = GETPOST("comment"); $comment_user = GETPOST('commentuser'); - + $resql = $object->addComment($comment, $comment_user); - + if (! $resql) { setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); } } } - + // Delete comment $idcomment=GETPOST('deletecomment','int'); if ($idcomment) { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $resql = $object->deleteComment($idcomment); } - + if ($action == 'edit') { - + // Security check if (!$user->rights->opensurvey->write) accessforbidden(); } @@ -307,7 +307,7 @@ print ''; // Expire date print ''.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire',0,0,0,'',1,0,1); -else +else { print dol_print_date($object->date_fin,'day'); if ($object->date_fin && $object->date_fin < dol_now()) print img_warning($langs->trans("Expired")); @@ -377,7 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) { //Opened button print ''.$langs->trans("ReOpen") . ''; } - + //Delete button print ''.$langs->trans('Delete').''; } @@ -420,7 +420,7 @@ print '
    '; // Add comment if ($object->allow_comments) { print $langs->trans("AddACommentForPoll") . '
    '; - print '
    '."\n"; + print '
    '."\n"; print $langs->trans("Name") .':
    '."\n"; print '
    '."\n"; if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") { From 787d6946b220453e6337d56e1b6859ac266dcee9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 12:30:18 +0200 Subject: [PATCH 167/342] Continue work started on module builder --- htdocs/langs/en_US/modulebuilder.lang | 14 +- htdocs/modulebuilder/index.php | 361 ++++++++++++------ .../modulebuilder/template/class/MyObject.txt | 3 +- .../template/class/myobject.class.php | 62 ++- .../modulebuilder/template/modulebuilder.txt | 5 +- 5 files changed, 294 insertions(+), 151 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 8d9a31cfdf7..fe636fd4f2d 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,24 +1,25 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build or edit your own module. +ModuleBuilderDesc=This tools give you utilites to build or edit your own module (More information here). EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module NewObject=New object -ModuleKey=Key for new module -ObjectKey=Key for new object +ModuleKey=Module key +ObjectKey=Object key ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object initialized ModuleBuilderDescdescription=Enter here all general information that describe your module -ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated. +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. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. -ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost ! +EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module will be definitly lost ! +EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be definitly lost ! DangerZone=Danger zone BuildPackage=Build package ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) @@ -31,4 +32,5 @@ ClassFile=File for PHP class ApiClassFile=File for PHP API class PageForList=PHP page for list of record PageForCreateEditView=PHP page to create/edit/view a record -PathToModulePackage=Path to zip of module/application package \ No newline at end of file +PathToModulePackage=Path to zip of module/application package +SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d9ae491b654..7aa3440b8a8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -58,41 +58,50 @@ $FILEFLAG='modulebuilder.txt'; if ($dirins && $action == 'initmodule' && $modulename) { - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dirins.'/'.strtolower($modulename); - - $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename - ); - - $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); - //dol_mkdir($destfile); - if ($result <= 0) + if (preg_match('/\s/', $modulename)) { - if ($result < 0) - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); - } - else // $result == 0 - { - setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); - } + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - // Delete some files - dol_delete_file($destdir.'/myobject_card.php'); - dol_delete_file($destdir.'/myobject_list.php'); - dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); - dol_delete_file($destdir.'/sql/llx_myobject.sql'); - dol_delete_file($destdir.'/scripts/myobject.php'); - dol_delete_file($destdir.'/img/object_myobject.png'); - dol_delete_file($destdir.'/class/myobject.class.php'); - dol_delete_file($destdir.'/class/api_myobject.class.php'); - dol_delete_file($destdir.'/class/MyObject.txt'); + if (! $error) + { + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($modulename); + + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename + ); + + $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); + //dol_mkdir($destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); + } + } + + // Delete some files + dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_list.php'); + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/scripts/myobject.php'); + dol_delete_file($destdir.'/img/object_myobject.png'); + dol_delete_file($destdir.'/class/myobject.class.php'); + dol_delete_file($destdir.'/class/api_myobject.class.php'); + dol_delete_file($destdir.'/class/MyObject.txt'); + } // Edit PHP files if (! $error) @@ -129,74 +138,86 @@ if ($dirins && $action == 'initmodule' && $modulename) 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', - 'myobject_list.php'=>strtolower($objectname).'_list.php', - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', - 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', - 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', - 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', - 'class/MyObject.txt'=>'class/'.$objectname.'.txt' - ); - - foreach($filetogenerate as $srcfile => $destfile) + if (preg_match('/\s/', $objectname)) { - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); - if ($result <= 0) - { - if ($result < 0) - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); - } - else // $result == 0 - { - setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); - } - } - else - { - // Copy is ok - } + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); } - // Edit PHP files - foreach($filetogenerate as $destfile) + if (! $error) { - $phpfileval['fullname'] = $destdir.'/'.$destfile; + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($module); - //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, - 'htdocs/modulebuilder/template/'=>'', + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); - //var_dump($result); - if ($result < 0) + + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + foreach($filetogenerate as $srcfile => $destfile) { - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + } + } + else + { + // Copy is ok + } + } + } + + if (! $error) + { + // Edit PHP files + foreach($filetogenerate as $destfile) + { + $phpfileval['fullname'] = $destdir.'/'.$destfile; + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'htdocs/modulebuilder/template/'=>'', + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); + + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } } } @@ -206,18 +227,90 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if ($dirins && $action == 'confirm_delete') { - $modulelowercase=strtolower($module); + if (preg_match('/\s/', $module)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - // Dir for module - $dir = $dirins.'/'.$modulelowercase; + if (! $error) + { + $modulelowercase=strtolower($module); - dol_delete_dir_recursive($dir); + // Dir for module + $dir = $dirins.'/'.$modulelowercase; - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - exit; + $result = dol_delete_dir_recursive($dir); + + if ($result > 0) + { + setEventMessages($langs->trans("DirDeleted"), null); + } + else + { + setEventMessages($langs->trans("NothingDeleted"), null, 'warnings'); + } + } + + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $module = 'deletemodule'; +} + +if ($dirins && $action == 'confirm_deleteobject' && $objectname) +{ + if (preg_match('/\s/', $objectname)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } + + if (! $error) + { + $modulelowercase=strtolower($module); + $objectlowercase=strtolower($objectname); + + // Dir for module + $dir = $dirins.'/'.$modulelowercase; + + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', + 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', + 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', + 'class/MyObject.txt'=>'class/'.$objectname.'.txt' + ); + + $resultko = 0; + foreach($filetogenerate as $filetodelete) + { + $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); + if (! $resulttmp) $resultko++; + } + + if ($resultko == 0) + { + setEventMessages($langs->trans("FilesDeleted"), null); + } + else + { + setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); + } + } + + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $tabobj = 'deleteobject'; } if ($dirins && $action == 'generatepackage') @@ -341,7 +434,7 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En // Show description of content $newdircustom=$dirins; if (empty($newdircustom)) $newdircustom=img_warning(); -print $langs->trans("ModuleBuilderDesc").'
    '; +print $langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
    '; print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'
    '; $message=''; @@ -381,7 +474,7 @@ print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
    $tmpmodulewithcase) $h++; } +$head[$h][0] = $_SERVER["PHP_SELF"].'?module=deletemodule'; +$head[$h][1] = $langs->trans("DangerZone"); +$head[$h][2] = 'deletemodule'; +$h++; dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic'); @@ -446,6 +543,19 @@ if ($module == 'initmodule') print ''; print ''; } +elseif ($module == 'deletemodule') +{ + print '
    '; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfModuleToDeleteDesc").'

    '; + + print ''; + print ''; + print '
    '; +} elseif (! empty($module)) { // Tabs for module @@ -502,11 +612,6 @@ elseif (! empty($module)) $head2[$h][2] = 'buildpackage'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dangerzone&module='.$module; - $head2[$h][1] = $langs->trans("DangerZone"); - $head2[$h][2] = 'dangerzone'; - $h++; - print $modulestatusinfo.'

    '; dol_fiche_head($head2, $tab, '', -1, ''); @@ -532,6 +637,7 @@ elseif (! empty($module)) print ''; print $langs->trans("Numero"); + print ' ('.$langs->trans("SeeHere").')'; print ''; print $moduleobj->numero; print ''; @@ -608,6 +714,12 @@ elseif (! empty($module)) $h++; } + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=deleteobject'; + $head3[$h][1] = $langs->trans("DangerZone"); + $head3[$h][2] = 'deleteobject'; + $h++; + + dol_fiche_head($head3, $tabobj, '', -1, ''); if ($tabobj == 'newobject') @@ -625,6 +737,21 @@ elseif (! empty($module)) print ''; print ''; } + elseif ($tabobj == 'deleteobject') + { + // New module + print '
    '; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfObjectToDeleteDesc").'

    '; + + print ''; + print ''; + print '
    '; + } else { try { @@ -641,8 +768,9 @@ elseif (! empty($module)) $tmpobjet = new $tabobj($db); $reflector = new ReflectionClass($tabobj); - $properties = $reflector->getProperties(); - $propdefault = $reflector->getDefaultProperties(); + $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"), '', ''); @@ -655,8 +783,10 @@ elseif (! empty($module)) print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -676,7 +806,7 @@ elseif (! empty($module)) $propname=$propval->getName(); // Discard generic properties - if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue; + 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; @@ -686,11 +816,10 @@ elseif (! empty($module)) print $propname; print ''; print ''; - print ''; print ' diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index b641627b789..c05916d55a7 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -28,6 +28,9 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; +$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''; + print top_htmlhead('',$langs->trans('SendNewPassword')); ?> @@ -94,7 +97,7 @@ if (! empty($hookmanager->resArray['options'])) { } ?> -resArray['options'])) {
    -
    class="button" name="password" value="trans('SendNewPassword'); ?>" tabindex="4" /> +
    class="button" name="password" value="trans('SendNewPassword'); ?>" tabindex="4" />
    diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index ac3a45d5683..6753a4299b0 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -39,7 +39,7 @@ $element = GETPOST('element', 'alpha'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (isset($action) && ! empty($action)) diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php index 6b9dd7e062f..423677c5da5 100644 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ b/htdocs/expensereport/ajax/ajaxprojet.php @@ -46,7 +46,7 @@ require '../../main.inc.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; dol_syslog(join(',',$_GET)); diff --git a/htdocs/externalsite/frames.php b/htdocs/externalsite/frames.php index adf9d547073..6005b8e55b6 100644 --- a/htdocs/externalsite/frames.php +++ b/htdocs/externalsite/frames.php @@ -34,8 +34,8 @@ if (empty($conf->global->EXTERNALSITE_URL)) llxFooter(); } -$mainmenu=GETPOST('mainmenu', 'alpha'); -$leftmenu=GETPOST('leftmenu', 'alpha'); +$mainmenu=GETPOST('mainmenu', "aZ09"); +$leftmenu=GETPOST('leftmenu', "aZ09"); $idmenu=GETPOST('idmenu', 'int'); $theme=GETPOST('theme', 'alpha'); $codelang=GETPOST('lang', 'aZ09'); diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index af3d728dc78..9a8c24c4eba 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -46,7 +46,7 @@ $langs->load('margins'); top_httphead(); -//print ''."\n"; +//print ''."\n"; if ($idprod > 0) { @@ -55,7 +55,7 @@ if ($idprod > 0) $sorttouse = 's.nom, pfp.quantity, pfp.price'; if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; - + $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. if ( is_array($productSupplierArray)) { @@ -63,15 +63,15 @@ if ($idprod > 0) { $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100); $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100); - + $title = $productSupplier->fourn_name.' - '.$productSupplier->fourn_ref.' - '; - + if ($productSupplier->fourn_qty == 1) { $title.= price($price,0,$langs,0,0,-1,$conf->currency)."/"; } $title.= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); - + if ($productSupplier->fourn_qty > 1) { $title.=" - "; @@ -84,19 +84,19 @@ if ($idprod > 0) $title.= price($productSupplier->fourn_unitcharges,0,$langs,0,0,-1,$conf->currency); $price += $productSupplier->fourn_unitcharges; } - + $label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); if ($productSupplier->fourn_ref) $label.=' ('.$productSupplier->fourn_ref.')'; - + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price,0,'',0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } - + // Add price for costprice $price=$producttmp->cost_price; $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price,0,$langs,0,0,-1,$conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price,0,$langs,0,0,-1,$conf->currency)); // For price field, we must use price2num(), for label or title, price() - if(!empty($conf->stock->enabled)) + if(!empty($conf->stock->enabled)) { // Add price for pmp $price=$producttmp->pmp; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 1ab8fbd785f..9523d489256 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -66,7 +66,7 @@ $year_end = GETPOST('year_end'); $search_employe = GETPOST('search_employe'); $search_valideur = GETPOST('search_valideur'); $search_statut = GETPOST('select_statut'); -$type = GETPOST('type','int'); +$type = GETPOST('type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -82,7 +82,7 @@ $fieldstosearchall = array( * 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") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_ref=""; $month_create=""; @@ -168,7 +168,7 @@ if($year_create > 0) { } } else { if($month_create > 0) { - $filter.= " AND date_format(cp.date_create, '%m') = '$month_create'"; + $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($month_create)."'"; } } @@ -313,7 +313,7 @@ print ''; // DATE CREATE print '
    '; @@ -409,7 +409,7 @@ if (! empty($holiday->holiday)) $userstatic->login=$infos_CP['user_login']; $userstatic->statut=$infos_CP['user_statut']; $userstatic->photo=$infos_CP['user_photo']; - + // Valideur $approbatorstatic->id=$infos_CP['fk_validator']; $approbatorstatic->lastname=$infos_CP['validator_lastname']; @@ -417,7 +417,7 @@ if (! empty($holiday->holiday)) $approbatorstatic->login=$infos_CP['validator_login']; $approbatorstatic->statut=$infos_CP['validator_statut']; $approbatorstatic->photo=$infos_CP['validator_photo']; - + $date = $infos_CP['date_create']; print ''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7e52b454f97..2806f2d06a0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -97,8 +97,9 @@ function test_sql_and_script_inject($val, $type) $sql_inj += preg_match('/'; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -556,7 +556,7 @@ class FormFile if (empty($noform)) $out.= ''; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= '
    '.$langs->trans("Property").''.$langs->trans("Description").''.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''.$langs->trans("Comment").''.$langs->trans("Type").''.$langs->trans("DefaultValue").''; - + print $propval->getDocComment(); print ''; - + print gettype($tmpobjet->$propname); print ''; @@ -836,16 +965,6 @@ elseif (! empty($module)) print ''; } - if ($tab == 'dangerzone') - { - print '
    '; - print ''; - print ''; - print ''; - print ''; - print '
    '; - } - dol_fiche_end(); } } diff --git a/htdocs/modulebuilder/template/class/MyObject.txt b/htdocs/modulebuilder/template/class/MyObject.txt index 37ccaca81ed..e86e7cdf5c6 100644 --- a/htdocs/modulebuilder/template/class/MyObject.txt +++ b/htdocs/modulebuilder/template/class/MyObject.txt @@ -1 +1,2 @@ -# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. \ No newline at end of file +# DO NOT DELETE THIS FILE MANUALLY +# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder. Use ModuleBuilder if you want to delete object. \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4993f60f83c..c66110fddf6 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -36,43 +36,63 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; class MyObject extends CommonObject { /** - * @var string Id to identify managed object + * @var string ID to identify managed object */ public $element = 'myobject'; /** * @var string Name of table without prefix where object is stored */ public $table_element = 'myobject'; - /** - * @var array Array with all fields and their property + + /** + * @var array Does this field is linked to a thirdparty ? + */ + 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 */ public $picto = 'myobject'; - /** - * @var array Array with all fields and their property + + /** + * @var int Entity Id + */ + public $entity; + + /** + * @var array Array with all fields and their property */ public $fields; + + + // If this object has a subtable with lines + /** - * @var mixed Sample property 1 + * @var int Name of subtable line */ - public $prop1; + //public $table_element_line = 'myobjectdet'; /** - * @var mixed Sample property 2 + * @var int Field with ID of parent key if this field has a parent */ - public $prop2; - - //... - - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - - public $table_element_line = 'myobjectdet'; - public $class_element_line = 'MyObjectline'; - public $fk_element = 'fk_myobject'; - - /** - * @var MyObjectLine[] Lines + //public $fk_element = 'fk_myobject'; + /** + * @var int Name of subtable class that manage subtable lines */ - public $lines = array(); + //public $class_element_line = 'MyObjectline'; + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('myobjectdet'); + /** + * @var MyObjectLine[] Array of subtable lines + */ + //public $lines = array(); diff --git a/htdocs/modulebuilder/template/modulebuilder.txt b/htdocs/modulebuilder/template/modulebuilder.txt index 5cdb6c6e6e8..24ea0d6eac5 100644 --- a/htdocs/modulebuilder/template/modulebuilder.txt +++ b/htdocs/modulebuilder/template/modulebuilder.txt @@ -1,2 +1,3 @@ -File to flag module built using official module template. -When this file is present into a module directory, you can edit it with the module builder tool. \ No newline at end of file +# DO NOT DELETE THIS FILE MANUALLY +# File to flag module built using official module template. +# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. \ No newline at end of file From cde0da6e1286febe81523590c3cbb693187ee1af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 12:48:58 +0200 Subject: [PATCH 168/342] Fix responsive --- htdocs/public/demo/index.php | 2 +- htdocs/public/opensurvey/studs.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index f9bb4db7ecf..60559eb7aed 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -291,7 +291,7 @@ print ''; print '
    '; print '
    '; print '
    '.$langs->trans("DemoDesc").'

    '; -print ''.$langs->trans("ChooseYourDemoProfil").''; +print '
    '.$langs->trans("ChooseYourDemoProfil").'
    '; print '
    '; print '
    '; diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 8e769452ec1..5f4c7a1fb03 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -113,14 +113,14 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout } $nom=substr(GETPOST("nom"),0,64); - + // Check if vote already exists $sql = 'SELECT id_users, nom as name'; $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; $sql.= " WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); - + $num_rows = $db->num_rows($resql); if ($num_rows > 0) { @@ -739,7 +739,7 @@ if ($comments) if ($object->allow_comments) { print '
    ' .$langs->trans("AddACommentForPoll") . "
    \n"; - print '
    '."\n"; + print '
    '."\n"; print $langs->trans("Name") .': '; print '   '."\n"; print '
    '."\n"; From abe736c6a6080589fe03d6f7026af0a5b1c7561a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Jun 2017 19:42:59 +0200 Subject: [PATCH 169/342] Escape hml tags --- htdocs/admin/tools/index.php | 2 +- htdocs/bookmarks/bookmarks.lib.php | 2 +- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/ajax/bankconciliate.php | 2 +- htdocs/core/ajax/box.php | 2 +- htdocs/core/ajax/constantonoff.php | 2 +- htdocs/core/ajax/contacts.php | 8 ++++---- htdocs/core/ajax/extraparams.php | 18 +++++++++--------- htdocs/core/ajax/loadinplace.php | 2 +- htdocs/core/ajax/objectonoff.php | 2 +- htdocs/core/ajax/price.php | 2 +- htdocs/core/ajax/row.php | 6 +++--- htdocs/core/ajax/saveinplace.php | 2 +- htdocs/core/ajax/security.php | 6 +++--- htdocs/core/ajax/vatrates.php | 2 +- htdocs/core/ajax/ziptown.php | 2 +- htdocs/core/class/html.formother.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 7 ++----- htdocs/core/lib/security2.lib.php | 6 +----- htdocs/core/tpl/ajax/fileupload_main.tpl.php | 2 +- htdocs/core/tpl/login.tpl.php | 6 +++++- htdocs/core/tpl/passwordforgotten.tpl.php | 7 +++++-- htdocs/ecm/ajax/ecmdatabase.php | 2 +- htdocs/expensereport/ajax/ajaxprojet.php | 2 +- htdocs/externalsite/frames.php | 4 ++-- htdocs/fourn/ajax/getSupplierPrices.php | 18 +++++++++--------- htdocs/holiday/list.php | 12 ++++++------ htdocs/main.inc.php | 11 ++++++----- htdocs/product/ajax/products.php | 2 +- htdocs/product/stats/card.php | 2 +- htdocs/public/paybox/paymentko.php | 2 +- htdocs/public/paybox/paymentok.php | 2 +- htdocs/public/paypal/paymentko.php | 6 +++--- htdocs/public/paypal/paymentok.php | 2 +- htdocs/societe/ajax/company.php | 4 ++-- htdocs/societe/ajaxcompanies.php | 2 +- htdocs/societe/ajaxcountries.php | 2 +- htdocs/user/passwordforgotten.php | 3 --- 38 files changed, 84 insertions(+), 86 deletions(-) diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index 8da041d05da..b8dfad44e8f 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -38,7 +38,7 @@ if (! $user->admin) $form = new Form($db); $title=$langs->trans("SystemToolsArea"); -if (GETPOST('leftmenu') == 'admintools') $title=$langs->trans("ModulesSystemTools"); +if (GETPOST('leftmenu',"aZ09") == 'admintools') $title=$langs->trans("ModulesSystemTools"); llxHeader('', $title); diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 3cee534e797..e6d3125abed 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -40,7 +40,7 @@ function printBookmarksList($aDb, $aLangs) $langs->load("bookmarks"); - $url= $_SERVER["PHP_SELF"].(! empty($_SERVER["QUERY_STRING"])?'?'.$_SERVER["QUERY_STRING"]:''); + $url= $_SERVER["PHP_SELF"].(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); $ret = ''; // Menu bookmark diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 28f78e22ef4..bbc7647c802 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -139,7 +139,7 @@ if (! dol_is_dir($upload_dir)) } print ''."\n"; -print ''."\n"; +//print ''."\n"; $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 3a8a3e30687..76ab3045f93 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -45,7 +45,7 @@ $action=GETPOST('action'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') { diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 63f96a0c513..106822f998b 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -50,7 +50,7 @@ $userid=GETPOST('userid','int'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -print ''."\n"; +print ''."\n"; // Add a box if ($boxid > 0 && $zone !='' && $userid > 0) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 331a5e87513..f79753260d7 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -45,7 +45,7 @@ $name=GETPOST('name','alpha'); //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -print ''."\n"; +//print ''."\n"; // Registering the location of boxes if (! empty($action) && ! empty($name)) diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index c3788a8baeb..1c7c7a56e4b 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -41,20 +41,20 @@ $showempty = GETPOST('showempty','int'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($id) && ! empty($action) && ! empty($htmlname)) { $form = new Form($db); - + $return=array(); if (empty($showempty)) $showempty=0; - + $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); $return['num'] = $form->num; $return['error'] = $form->error; - + echo json_encode($return); } diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 510ef8a1cf8..f8a636e52a5 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -40,17 +40,17 @@ $type = GETPOST('type', 'alpha'); top_httphead(); -print ''."\n"; +print ''."\n"; if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) { $value = GETPOST('value','alpha'); $params=array(); - + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); - + $classpath = $subelement = $element; - + // For compatibility if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } @@ -60,19 +60,19 @@ if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } - + dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); - + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } else $classname = ucfirst($subelement); - + $object = new $classname($db); $object->fetch($id); - + $params[$htmlelement] = array($type => $value); $object->extraparams = array_merge($object->extraparams, $params); - + $result=$object->setExtraParameters(); } diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index de3a4e57d19..7e9e541c768 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -41,7 +41,7 @@ $fk_element = GETPOST('fk_element','alpha'); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 6ac5abd3bbb..37173ed9943 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -42,7 +42,7 @@ $object = new GenericObject($db); top_httphead(); -print ''."\n"; +print ''."\n"; // Registering new values if (($action == 'set') && ! empty($id)) diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index 5c891df14d5..d4a101fb497 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -39,7 +39,7 @@ $tva_tx = str_replace('*','',GETPOST('tva_tx','alpha')); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($output) && isset($amount) && isset($tva_tx)) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 41d411f01fd..827ee92d525 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -17,8 +17,8 @@ /** * \file htdocs/core/ajax/row.php - * \brief File to return Ajax response on Row move. - * This ajax page is called when doing an up or down drag and drop. + * \brief File to return Ajax response on Row move. + * This ajax page is called when doing an up or down drag and drop. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; top_httphead(); -print ''."\n"; +print ''."\n"; // Registering the location of boxes if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line'])) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 48797dd0432..eb04379a778 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -54,7 +54,7 @@ savemethodname: top_httphead(); -//print ''."\n"; +//print ''."\n"; //print_r($_POST); // Load original field value diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 28a53a87679..cc7335618d0 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -17,8 +17,8 @@ /** * \file htdocs/core/ajax/security.php - * \brief This ajax component is used to generated has keys for security purposes - * like key to use into URL to protect them. + * \brief This ajax component is used to generated has keys for security purposes + * like key to use into URL to protect them. */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal @@ -38,7 +38,7 @@ require '../../main.inc.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; // Registering the location of boxes if (isset($_GET['action']) && ! empty($_GET['action'])) diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index fc30a13afec..ac9691bfa25 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -41,7 +41,7 @@ $productid = (GETPOST('productid','int')?GETPOST('productid','int'):0); top_httphead(); -//print ''."\n"; +//print ''."\n"; // Load original field value if (! empty($id) && ! empty($action) && ! empty($htmlname)) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 30e0211ece1..9fa475039d9 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. top_httphead(); -//print ''."\n"; +//print ''."\n"; dol_syslog("GET is ".join(',',$_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)?'':$conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); //var_dump($_GET); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 98720d335b9..1771b6f7a4c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1062,7 +1062,7 @@ class FormOther async: false }); // We force reload to be sure to get all boxes into list - window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=delbox\'; + window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=delbox\'; } else { @@ -1084,7 +1084,7 @@ class FormOther url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\', async: false }); - window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid; + window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=addbox&boxid=\'+boxid; } });'; if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 97ce3c4f698..f9f9c8557ee 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -289,9 +289,6 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) case 'intcomma': if (preg_match('/[^0-9,]+/i',$out)) $out=''; break; - case 'intcomma': - if (preg_match('/[^0-9,]+/i',$out)) $out=''; - break; case 'alpha': $out=trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. @@ -2931,8 +2928,8 @@ function dol_print_error($db='',$error='',$errors=null) $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
    \n"; $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
    \n"; $out.="
    \n"; - $syslog.="url=".$_SERVER["REQUEST_URI"]; - $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; + $syslog.="url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); + $syslog.=", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); } else // Mode CLI { diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index fc05e2c9194..8c16ae8309a 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -144,10 +144,6 @@ function dol_loginfunction($langs,$conf,$mysoc) $dol_url_root = DOL_URL_ROOT; - $php_self = $_SERVER['PHP_SELF']; - $php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; - if (! preg_match('/mainmenu=/',$php_self)) $php_self.=(preg_match('/\?/',$php_self)?'&':'?').'mainmenu=home'; - // Title $appli=constant('DOL_APPLICATION_TITLE'); $title=$appli.' '.DOL_VERSION; @@ -422,7 +418,7 @@ function encodedecode_dbpassconf($level=0) fflush($fp); fclose($fp); clearstatcache(); - + // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch //@chmod($file, octdec('0600')); diff --git a/htdocs/core/tpl/ajax/fileupload_main.tpl.php b/htdocs/core/tpl/ajax/fileupload_main.tpl.php index b7437af4616..034e9ebc3fc 100644 --- a/htdocs/core/tpl/ajax/fileupload_main.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_main.tpl.php @@ -45,7 +45,7 @@ $(function () { // Events $('#fileupload').fileupload({ stop: function (e, data) { - location.href=''; + location.href=''; }, destroy: function (e, data) { var that = $(this).data('fileupload'); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 3772b44c9fc..608e508d717 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -31,6 +31,10 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; // If we force to use jmobile, then we reenable javascript if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; +$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''; +if (! preg_match('/mainmenu=/',$php_self)) $php_self.=(preg_match('/\?/',$php_self)?'&':'?').'mainmenu=home'; + // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second $arrayofjs=array( '/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)), @@ -80,7 +84,7 @@ $(document).ready(function () {
    '; -echo dol_escape_htmltag($title); +echo dol_escape_htmltag($title); if ($disablenofollow) echo ''; ?>
    '; -print ''; +print ''; $formother->select_year($year_create,'year_create',1, $min_year, 0); print '
    '; @@ -644,9 +644,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -671,7 +671,7 @@ class FormFile $documenturl = DOL_URL_ROOT.'/document.php'; if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + // Show file name with link to download $out.= ''; @@ -799,7 +799,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -919,7 +919,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -928,7 +928,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action') == 'editfile' && $permtoeditline) { @@ -938,7 +938,7 @@ class FormFile print ''; } print '
    '; $out.= '"; $out.=''; $out.=''; @@ -756,7 +756,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.='
    '.$langs->trans("None").'
    '."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -971,13 +971,13 @@ class FormFile $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; } $var=!$var; - + $editline=0; - + print ''."\n"; print ''; print '"; @@ -1103,7 +1103,7 @@ class FormFile { print ''; } - + return $nboffiles; } } @@ -1489,11 +1489,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs From 4dda771079d04bb22eb5166ad2aff8042e237184 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:54:26 +0200 Subject: [PATCH 230/342] FIX #6973 --- htdocs/admin/mails_templates.php | 404 +++++++++++++++++-------------- 1 file changed, 216 insertions(+), 188 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index cc35aed19be..123877f7f4e 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -50,6 +50,7 @@ $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); +$search_label=GETPOST('search_label','alpha'); $allowed=$user->admin; if (! $allowed) accessforbidden(); @@ -78,10 +79,6 @@ $hookmanager->initHooks(array('emailtemplates')); $tabname=array(); $tabname[25]= MAIN_DB_PREFIX."c_email_templates"; -// Requests to extract data -$tabsql=array(); -$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; - // Criteria to sort dictionaries $tabsqlsort=array(); $tabsqlsort[25]="label ASC"; @@ -173,211 +170,223 @@ $id = 25; * Actions */ -if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) -{ - //$search_country_id = ''; -} +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -// Actions add or modify an entry into a dictionary -if (GETPOST('actionadd') || GETPOST('actionmodify')) -{ - $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); - $listfieldinsert=explode(',',$tabfieldinsert[$id]); - $listfieldmodify=explode(',',$tabfieldinsert[$id]); - $listfieldvalue=explode(',',$tabfieldvalue[$id]); +$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'); - // Check that all fields are filled - $ok=1; - foreach ($listfield as $f => $value) +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 ($value == 'content') continue; - if ($value == 'content_lines') continue; - if ($value == 'content') $value='content-'.$rowid; - if ($value == 'content_lines') $value='content_lines-'.$rowid; - - if (! isset($_POST[$value]) || $_POST[$value]=='') - { - $ok=0; - $fieldnamekey=$listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; - if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } + $search_label=''; + $toselect=''; + $search_array_options=array(); } - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd')) + // Actions add or modify an entry into a dictionary + if (GETPOST('actionadd') || GETPOST('actionmodify')) { - if ($tabrowid[$id]) + $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); + $listfieldinsert=explode(',',$tabfieldinsert[$id]); + $listfieldmodify=explode(',',$tabfieldinsert[$id]); + $listfieldvalue=explode(',',$tabfieldvalue[$id]); + + // Check that all fields are filled + $ok=1; + foreach ($listfield as $f => $value) { - // Recupere id libre pour insertion - $newid=0; - $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; - $result = $db->query($sql); - if ($result) + if ($value == 'content') continue; + if ($value == 'content_lines') continue; + if ($value == 'content') $value='content-'.$rowid; + if ($value == 'content_lines') $value='content_lines-'.$rowid; + + if (! isset($_POST[$value]) || $_POST[$value]=='') { - $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $ok=0; + $fieldnamekey=$listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - } else { - dol_print_error($db); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) - $sql.= $tabrowid[$id].","; - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $newid=0; + $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $newid=($obj->newid + 1); - // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) - $sql.= $newid.","; - $i=0; - foreach ($listfieldinsert as $f => $value) - { - //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; + } else { + dol_print_error($db); + } } - if ($i) $sql.=","; - if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0'; - if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1'; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql.=",1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only - } - else - { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $tabrowid[$id].","; + $sql.= $tabfieldinsert[$id]; + $sql.=",active)"; + $sql.= " VALUES("; + + // List of values + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) + $sql.= $newid.","; + $i=0; + foreach ($listfieldinsert as $f => $value) + { + //var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value); + if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + if ($value == 'private' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='0'; + if ($value == 'position' && ! is_numeric($_POST[$listfieldvalue[$i]])) $_POST[$listfieldvalue[$i]]='1'; + if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; } - else { - dol_print_error($db); + $sql.=",1)"; + + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST=array('id'=>$id); // Clean $_POST array, we keep only + } + else + { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } + else { + dol_print_error($db); + } + } + } + + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify')) + { + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) + { + $sql.= $tabrowid[$id]."="; + $sql.= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; + if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; + if ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql.=","; + $sql.= $field."="; + if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' + else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (! $resql) + { + setEventMessages($db->error(), null, 'errors'); } } } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify')) + if ($action == 'confirm_delete' && $confirm == 'yes') // delete { if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify)) - { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; - } - $i = 0; - foreach ($listfieldmodify as $field) - { - if ($field == 'content') $_POST['content']=$_POST['content-'.$rowid]; - if ($field == 'content_lines') $_POST['content_lines']=$_POST['content_lines-'.$rowid]; - if ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql.=","; - $sql.= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if (! $resql) + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (! $result) { - setEventMessages($db->error(), null, 'errors'); + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } + else + { + dol_print_error($db); + } } } -} -if ($action == 'confirm_delete' && $confirm == 'yes') // delete -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; - - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (! $result) + // activate + if ($action == $acts[0]) { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; } - else + elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; + } + + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } + } + + // disable + if ($action == $acts[1]) + { + if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } + else { $rowidcol="rowid"; } + + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; + } + elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; + } + + $result = $db->query($sql); + if (!$result) { dol_print_error($db); } } } -// activate -if ($action == $acts[0]) -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; - } - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } -} - -// disable -if ($action == $acts[1]) -{ - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } - - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; - } - elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; - } - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } -} - - /* * View @@ -416,8 +425,11 @@ if ($action == 'delete') } //var_dump($elementList); -// Complete requete recherche valeurs avec critere de tri -$sql=$tabsql[$id]; + +$sql="SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active"; +$sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates"; +$sql.=" WHERE entity IN (".getEntity('email_template').")"; +if ($search_label) $sql.=natural_search('label', $search_label); if ($search_country_id > 0) { @@ -572,9 +584,19 @@ if ($action != 'edit') $colspan=count($fieldlist)+1; - print ''; // Keep   to have a line with enough height + //print ''; // Keep   to have a line with enough height } +print '
    '; - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; @@ -1038,7 +1038,7 @@ class FormFile // Delete or view link // ($param must start with &) print ''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1046,10 +1046,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','holiday','project'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1058,7 +1058,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1076,7 +1076,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "
     
     
    '; +print ''; + +print '
    '; + +print '
    '; +print ''; +print ''; + +print ''; // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); @@ -599,8 +621,26 @@ if ($resql) print ''; } + + // Title line with search boxes + print ''; + $filterfound=0; + foreach ($fieldlist as $field => $value) + { + if ($value == 'label') print ''; + elseif (! in_array($value, array('content', 'content_lines'))) print ''; + } + if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; + print ''; + // Action column + print ''; + print ''; + // Title of lines - print ''; + print ''; foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles @@ -642,18 +682,6 @@ if ($resql) print getTitleFieldOfList(''); print ''; - // Title line with search boxes - print ''; - $filterfound=0; - foreach ($fieldlist as $field => $value) - { - if (! in_array($field, array('content', 'content_lines'))) print ''; - } - if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print ''; - print ''; - print ''; - print ''; - if ($num) { // Lines with values From efe5d79a862f72b3da7aecbf07e508d7e6d23b65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:58:43 +0200 Subject: [PATCH 231/342] Work on #6958. Only one type of invoice supported for supplier invoices --- .../mod_facture_fournisseur_tulip.php | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index b7a3801a9cd..2e155c04df8 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -72,27 +72,32 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $tooltip.=$langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; - // Parametrage du prefix des replacement - $texte.= ''; - $texte.= ''; - $texte.= ''; + if ($conf->global->MAIN_FEATURE_LEVEL >= 2) + { + // Parametrage du prefix des replacement + $texte.= ''; + $texte.= ''; + $texte.= ''; - // Parametrage du prefix des avoirs - $texte.= ''; - $texte.= ''; - $texte.= ''; + // Parametrage du prefix des avoirs + $texte.= ''; + $texte.= ''; + $texte.= ''; - // Parametrage du prefix des acomptes - $texte.= ''; - $texte.= ''; - $texte.= ''; + // Parametrage du prefix des acomptes + $texte.= ''; + $texte.= ''; + $texte.= ''; + } $texte.= '
    '; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").'):
    '.$langs->trans("Mask"); + //$texte.= ' ('.$langs->trans("InvoiceStandard").')'; + $texte.= ':'.$form->textwithpicto('',$tooltip,1,1).' 
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'.$form->textwithpicto('',$tooltip,1,1).'
    '; $texte.= '
    '; @@ -137,7 +142,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices // Get Mask value $mask = ''; - if (is_object($object) && $object->type == 1) + if (is_object($object) && $object->type == 1) { $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; if (! $mask) From f1701469e0a16d80951de4801a4637918ad7493d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 13:28:34 +0200 Subject: [PATCH 232/342] NEW data files are now also parsed by phpunit for sql syntax --- htdocs/core/db/pgsql.class.php | 3 ++- htdocs/install/mysql/data/llx_accounting.sql | 2 +- htdocs/install/mysql/data/llx_const.sql | 8 ++++---- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 2 +- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 +- .../mysql/tables/llx_blockedlog_authority.sql | 2 +- htdocs/install/pgsql/functions/functions.sql | 3 ++- test/phpunit/CodingSqlTest.php | 13 +++++++++++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 89f2a66bdea..2b8e90d0780 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -169,7 +169,7 @@ class DoliDBPgsql extends DoliDB $line = preg_replace('/ SEPARATOR/i', ',', $line); $line = preg_replace('/STRING_AGG\(([^,\)]+)\)/i', 'STRING_AGG(\\1, \',\')', $line); //print $line."\n"; - + if ($type == 'auto') { if (preg_match('/ALTER TABLE/i',$line)) $type='dml'; @@ -210,6 +210,7 @@ class DoliDBPgsql extends DoliDB // tinytext/mediumtext -> text $line=preg_replace('/tinytext/i','text',$line); $line=preg_replace('/mediumtext/i','text',$line); + $line=preg_replace('/longtext/i','text',$line); $line=preg_replace('/text\([0-9]+\)/i','text',$line); diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index ea1fe7a7dd7..6448646bda0 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -360,7 +360,7 @@ INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (305,'PCG99-BASE','FINAN', 'XXXXXX', '511', '304', 'Valeurs à l''encaissement', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (306,'PCG99-BASE','FINAN', 'BANK', '512', '304', 'Banques', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (307,'PCG99-BASE','FINAN', 'XXXXXX', '514', '304', 'Chèques postaux', 1); -INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (308,'PCG99-BASE','FINAN', 'XXXXXX', '515', '304', '"Caisses" du Trésor et des établissements publics', 1); +INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (308,'PCG99-BASE','FINAN', 'XXXXXX', '515', '304', 'Caisses du Trésor et des établissements publics', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (309,'PCG99-BASE','FINAN', 'XXXXXX', '516', '304', 'Sociétés de bourse', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (310,'PCG99-BASE','FINAN', 'XXXXXX', '517', '304', 'Autres organismes financiers', 1); INSERT INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (311,'PCG99-BASE','FINAN', 'XXXXXX', '518', '304', 'Intérêts courus', 1); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index bf76d378789..ee6f952e6ae 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -91,7 +91,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAILING_EMAIL_ -- -- ODT Path --- -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0); -insert into `llx_const` (`name`, `entity`, `value`, `type`, `visible`) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0); +insert into llx_const (name, entity, value, type, visible) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 2253eb68787..91c155d3d84 100644 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -803,7 +803,7 @@ ALTER TABLE llx_user ADD COLUMN job varchar(128) AFTER firstname; -- Use entity 0 for all entities -INSERT INTO llx_const(name, value, visible, entity) SELECT __ENCRYPT('SYSLOG_HANDLERS')__, __ENCRYPT('[\'mod_syslog_file\']')__, 0, 0 FROM llx_const WHERE __DECRYPT('name')__ = 'SYSLOG_FILE_ON' AND __DECRYPT('value')__ = '1'; +INSERT INTO llx_const(name, value, visible, entity) SELECT __ENCRYPT('SYSLOG_HANDLERS')__, __ENCRYPT('["mod_syslog_file"]')__, 0, 0 FROM llx_const WHERE __DECRYPT('name')__ = 'SYSLOG_FILE_ON' AND __DECRYPT('value')__ = '1'; -- New Imports 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 3acf312bae1..637648be3ba 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 @@ -493,7 +493,7 @@ CREATE TABLE llx_blockedlog_authority rowid integer AUTO_INCREMENT PRIMARY KEY, blockchain longtext NOT NULL, signature varchar(100) NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + tms timestamp ) ENGINE=innodb; ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql index eb491f93af4..9e7dae8f23c 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql @@ -3,5 +3,5 @@ CREATE TABLE llx_blockedlog_authority rowid integer AUTO_INCREMENT PRIMARY KEY, blockchain longtext NOT NULL, signature varchar(100) NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + tms timestamp ) ENGINE=innodb; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 441b20c66ad..1b2d184de0f 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -24,9 +24,10 @@ CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITHOUT TIME ZONE) RETURNS B CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP(TIMESTAMP WITH TIME ZONE) RETURNS BIGINT LANGUAGE SQL IMMUTABLE STRICT AS 'SELECT EXTRACT(EPOCH FROM $1)::bigint;'; - +DROP FUNCTION date_format(timestamp without time zone,text); CREATE OR REPLACE FUNCTION date_format(timestamp without time zone, text) RETURNS text AS $$ DECLARE i int := 1; temp text := ''; c text; n text; res text; BEGIN WHILE i <= pg_catalog.length($2) LOOP c := SUBSTRING ($2 FROM i FOR 1); IF c = '%' AND i != pg_catalog.length($2) THEN n := SUBSTRING ($2 FROM (i + 1) FOR 1); SELECT INTO res CASE WHEN n = 'a' THEN pg_catalog.to_char($1, 'Dy') WHEN n = 'b' THEN pg_catalog.to_char($1, 'Mon') WHEN n = 'c' THEN pg_catalog.to_char($1, 'FMMM') WHEN n = 'D' THEN pg_catalog.to_char($1, 'FMDDth') WHEN n = 'd' THEN pg_catalog.to_char($1, 'DD') WHEN n = 'e' THEN pg_catalog.to_char($1, 'FMDD') WHEN n = 'f' THEN pg_catalog.to_char($1, 'US') WHEN n = 'H' THEN pg_catalog.to_char($1, 'HH24') WHEN n = 'h' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'I' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'i' THEN pg_catalog.to_char($1, 'MI') WHEN n = 'j' THEN pg_catalog.to_char($1, 'DDD') WHEN n = 'k' THEN pg_catalog.to_char($1, 'FMHH24') WHEN n = 'l' THEN pg_catalog.to_char($1, 'FMHH12') WHEN n = 'M' THEN pg_catalog.to_char($1, 'FMMonth') WHEN n = 'm' THEN pg_catalog.to_char($1, 'MM') WHEN n = 'p' THEN pg_catalog.to_char($1, 'AM') WHEN n = 'r' THEN pg_catalog.to_char($1, 'HH12:MI:SS AM') WHEN n = 'S' THEN pg_catalog.to_char($1, 'SS') WHEN n = 's' THEN pg_catalog.to_char($1, 'SS') WHEN n = 'T' THEN pg_catalog.to_char($1, 'HH24:MI:SS') WHEN n = 'U' THEN pg_catalog.to_char($1, '?') WHEN n = 'u' THEN pg_catalog.to_char($1, '?') WHEN n = 'V' THEN pg_catalog.to_char($1, '?') WHEN n = 'v' THEN pg_catalog.to_char($1, '?') WHEN n = 'W' THEN pg_catalog.to_char($1, 'FMDay') WHEN n = 'w' THEN EXTRACT(DOW FROM $1)::text WHEN n = 'X' THEN pg_catalog.to_char($1, '?') WHEN n = 'x' THEN pg_catalog.to_char($1, '?') WHEN n = 'Y' THEN pg_catalog.to_char($1, 'YYYY') WHEN n = 'y' THEN pg_catalog.to_char($1, 'YY') WHEN n = '%' THEN pg_catalog.to_char($1, '%') ELSE NULL END; temp := temp operator(pg_catalog.||) res; i := i + 2; ELSE temp = temp operator(pg_catalog.||) c; i := i + 1; END IF; END LOOP; RETURN temp; END $$ IMMUTABLE STRICT LANGUAGE plpgsql; +DROP FUNCTION date_format(timestamp with time zone,text); CREATE OR REPLACE FUNCTION date_format(timestamp with time zone, text) RETURNS text AS $$ DECLARE i int := 1; temp text := ''; c text; n text; res text; BEGIN WHILE i <= pg_catalog.length($2) LOOP c := SUBSTRING ($2 FROM i FOR 1); IF c = '%' AND i != pg_catalog.length($2) THEN n := SUBSTRING ($2 FROM (i + 1) FOR 1); SELECT INTO res CASE WHEN n = 'a' THEN pg_catalog.to_char($1, 'Dy') WHEN n = 'b' THEN pg_catalog.to_char($1, 'Mon') WHEN n = 'c' THEN pg_catalog.to_char($1, 'FMMM') WHEN n = 'D' THEN pg_catalog.to_char($1, 'FMDDth') WHEN n = 'd' THEN pg_catalog.to_char($1, 'DD') WHEN n = 'e' THEN pg_catalog.to_char($1, 'FMDD') WHEN n = 'f' THEN pg_catalog.to_char($1, 'US') WHEN n = 'H' THEN pg_catalog.to_char($1, 'HH24') WHEN n = 'h' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'I' THEN pg_catalog.to_char($1, 'HH12') WHEN n = 'i' THEN pg_catalog.to_char($1, 'MI') WHEN n = 'j' THEN pg_catalog.to_char($1, 'DDD') WHEN n = 'k' THEN pg_catalog.to_char($1, 'FMHH24') WHEN n = 'l' THEN pg_catalog.to_char($1, 'FMHH12') WHEN n = 'M' THEN pg_catalog.to_char($1, 'FMMonth') WHEN n = 'm' THEN pg_catalog.to_char($1, 'MM') WHEN n = 'p' THEN pg_catalog.to_char($1, 'AM') WHEN n = 'r' THEN pg_catalog.to_char($1, 'HH12:MI:SS AM') WHEN n = 'S' THEN pg_catalog.to_char($1, 'SS') WHEN n = 's' THEN pg_catalog.to_char($1, 'SS') WHEN n = 'T' THEN pg_catalog.to_char($1, 'HH24:MI:SS') WHEN n = 'U' THEN pg_catalog.to_char($1, '?') WHEN n = 'u' THEN pg_catalog.to_char($1, '?') WHEN n = 'V' THEN pg_catalog.to_char($1, '?') WHEN n = 'v' THEN pg_catalog.to_char($1, '?') WHEN n = 'W' THEN pg_catalog.to_char($1, 'FMDay') WHEN n = 'w' THEN EXTRACT(DOW FROM $1)::text WHEN n = 'X' THEN pg_catalog.to_char($1, '?') WHEN n = 'x' THEN pg_catalog.to_char($1, '?') WHEN n = 'Y' THEN pg_catalog.to_char($1, 'YYYY') WHEN n = 'y' THEN pg_catalog.to_char($1, 'YY') WHEN n = '%' THEN pg_catalog.to_char($1, '%') ELSE NULL END; temp := temp operator(pg_catalog.||) res; i := i + 2; ELSE temp = temp operator(pg_catalog.||) c; i := i + 1; END IF; END LOOP; RETURN temp; END $$ IMMUTABLE STRICT LANGUAGE plpgsql; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 348043d4a4e..d158b71fc2e 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -141,7 +141,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); + $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/data', DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); foreach ($listofsqldir as $dir) { @@ -161,8 +161,12 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); $result=strpos($filecontent,'"'); + if ($result) + { + $result=! strpos($filecontent,'["'); + } print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; - $this->assertTrue($result===false, 'Found double quote into '.$file.'. Bad.'); + $this->assertTrue($result===false, 'Found double quote that is not [" (used for json content) into '.$file.'. Bad.'); $result=strpos($filecontent,'int('); print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; @@ -176,6 +180,11 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase { // Test for migration files only + } + elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data') + { + // Test for data files only + } else { From 302e086f991c60dad5abd3a7b3ea214dbf3b5106 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 13:33:26 +0200 Subject: [PATCH 233/342] Fix pgsql compatibility --- .../class/supplier_proposal.class.php | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e3f873476ba..b14e4a40ff9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -50,7 +50,7 @@ class SupplierProposal extends CommonObject public $fk_element='fk_supplier_proposal'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; - + /** * {@inheritdoc} */ @@ -140,7 +140,7 @@ class SupplierProposal extends CommonObject var $multicurrency_total_ht; var $multicurrency_total_tva; var $multicurrency_total_ttc; - + /** * Draft status */ @@ -160,10 +160,10 @@ class SupplierProposal extends CommonObject /** * Billed or closed/processed quote */ - const STATUS_CLOSE = 4; - - - + const STATUS_CLOSE = 4; + + + /** * Constructor * @@ -407,7 +407,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -419,7 +419,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -487,7 +487,7 @@ class SupplierProposal extends CommonObject $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -583,7 +583,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -595,7 +595,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; if ($remise_percent > 0) @@ -662,7 +662,7 @@ class SupplierProposal extends CommonObject if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } - + // Multicurrency $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); $this->line->multicurrency_total_ht = $multicurrency_total_ht; @@ -1180,7 +1180,7 @@ class SupplierProposal extends CommonObject $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - + if ($obj->fk_statut == 0) { $this->brouillon = 1; @@ -1271,7 +1271,7 @@ class SupplierProposal extends CommonObject $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->fk_unit = $objp->fk_unit; - + $this->lines[$i] = $line; $i++; @@ -1653,7 +1653,7 @@ class SupplierProposal extends CommonObject { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1704,7 +1704,7 @@ class SupplierProposal extends CommonObject $productsupplier = new ProductFournisseur($this->db); dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) + foreach ($this->lines as $product) { if ($product->subprice <= 0) continue; @@ -1721,7 +1721,7 @@ class SupplierProposal extends CommonObject $this->createPriceFournisseur($product, $user); } } - + return 1; } @@ -2149,7 +2149,7 @@ class SupplierProposal extends CommonObject $response->label = $label; $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; $response->img = img_object('',"propal"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { @@ -2187,7 +2187,7 @@ class SupplierProposal extends CommonObject global $user,$langs,$conf; // Load array of products prodids - $num_prods = 0; + $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; @@ -2250,7 +2250,7 @@ class SupplierProposal extends CommonObject $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; } - + $this->lines[$xnbp]=$line; $this->total_ht += $line->total_ht; @@ -2375,10 +2375,10 @@ class SupplierProposal extends CommonObject global $langs, $conf, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $url=''; $result=''; - + $label=''.$langs->trans("ShowSupplierProposal").''; if (! empty($this->ref)) $label.= '
    '.$langs->trans('Ref').': '.$this->ref; @@ -2396,7 +2396,7 @@ class SupplierProposal extends CommonObject if ($option == 'document') { $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id. $get_params; } - + $linkclose=''; if (empty($notooltip) && $user->rights->propal->lire) { @@ -2408,7 +2408,7 @@ class SupplierProposal extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -2432,14 +2432,14 @@ class SupplierProposal extends CommonObject function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal - + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; - $sql.= ' p.description as product_desc, pt.ref_fourn as ref_produit_fourn'; - $sql.= ' ,pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql.= ' p.description as product_desc, pt.ref_fourn as ref_produit_fourn,'; + $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_supplier_proposal = '.$this->id; @@ -2486,7 +2486,7 @@ class SupplierProposal extends CommonObject $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_produit_fourn; - + // Multicurrency $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; @@ -2541,7 +2541,7 @@ class SupplierProposal extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + /** * Function used to replace a thirdparty id with another one. * @@ -2555,10 +2555,10 @@ class SupplierProposal extends CommonObject $tables = array( 'supplier_proposal' ); - + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + } @@ -2669,7 +2669,7 @@ class SupplierProposalLine extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines var $ref_fourn; - + // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -2750,7 +2750,7 @@ class SupplierProposalLine extends CommonObjectLine $this->product_desc = $objp->product_desc; $this->ref_fourn = $objp->ref_produit_forun; - + // Multicurrency $this->fk_multicurrency = $objp->fk_multicurrency; $this->multicurrency_code = $objp->multicurrency_code; @@ -2798,11 +2798,11 @@ 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->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -2826,8 +2826,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; - $sql.= ' ref_fourn'; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; + $sql.= ' ref_fourn,'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql.= " VALUES (".$this->fk_supplier_proposal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -2860,7 +2860,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ", ".$this->multicurrency_total_ht; $sql.= ", ".$this->multicurrency_total_tva; $sql.= ", ".$this->multicurrency_total_ttc; - $sql.= ", fk_unit=".($this->fk_unit?$this->fk_unit:'null'); + $sql.= ", ".($this->fk_unit?$this->fk_unit:'null'); $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); @@ -2869,7 +2869,7 @@ class SupplierProposalLine extends CommonObjectLine { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); $this->id=$this->rowid; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -2982,11 +2982,11 @@ 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->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -3031,13 +3031,13 @@ class SupplierProposalLine extends CommonObjectLine if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - + // Multicurrency $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); From 3873bc74333657921b2c01cc67a3153284674146 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 15:06:24 +0200 Subject: [PATCH 234/342] Fix bette compatibility with pgsql --- htdocs/core/db/pgsql.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 2b8e90d0780..4aa56b367f3 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -185,8 +185,8 @@ class DoliDBPgsql extends DoliDB // we are inside create table statement so lets process datatypes if (preg_match('/(ISAM|innodb)/i',$line)) { // end of create table sequence - $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); - $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb);/i',');',$line); + $line=preg_replace('/\)[\s\t]*type[\s\t]*=[\s\t]*(MyISAM|innodb).*;/i',');',$line); + $line=preg_replace('/\)[\s\t]*engine[\s\t]*=[\s\t]*(MyISAM|innodb).*;/i',');',$line); $line=preg_replace('/,$/','',$line); } From ec9bbe2b52214008f6d6c55bf3dafbb8b8080778 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 16:54:37 +0200 Subject: [PATCH 235/342] Help/Need debug of some online instances with the log view --- htdocs/admin/syslog.php | 14 +++++++++++--- htdocs/admin/tools/purge.php | 10 +++++++++- htdocs/core/lib/files.lib.php | 21 +++++++++++++-------- htdocs/document.php | 5 +++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 65933c25639..75de985728c 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -88,7 +88,7 @@ if ($action == 'set') $newActiveModules = array(); $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); - + // Save options of handler foreach ($syslogModules as $syslogHandler) { @@ -111,7 +111,7 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0); // Check configuration @@ -206,7 +206,7 @@ foreach ($syslogModules as $moduleName) //print $moduleName." = ".$moduleactive." - ".$module->getName()." ".($moduleactive == -1)."
    \n"; if (($moduleactive == -1) && empty($conf->global->MAIN_FEATURES_LEVEL)) continue; // Some modules are hidden if not activable and not into debug mode (end user must not see them) - + print ''; print ''; print ' '; @@ -229,6 +229,14 @@ foreach ($syslogModules as $moduleName) print $option['name'].': '; if (! empty($option['example'])) print '
    '.$langs->trans("Example").': '.$option['example']; + + if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/',$value)) + { + $filelogparam =' ('; + $filelogparam.=$langs->trans('Download'); + $filelogparam.=$filelog.')'; + print $filelogparam; + } } } print ''; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index e913d59a4a7..7a5cb30ae75 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -83,7 +83,15 @@ if (! empty($conf->syslog->enabled)) { print ' '.$langs->trans("PurgeDeleteLogFile",$filelog).'

    '; + $filelogparam=$filelog; + if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) + { + $filelogparam =''.$filelog.''; + } + print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); + print '

    '; } print 'admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); + $original_file=$dolibarr_main_data_root.'/'.$original_file; + } // Wrapping for some images - if (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) + elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) { $accessallowed=1; $original_file=$conf->mycompany->dir_output.'/logos/'.$original_file; @@ -2369,13 +2381,6 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$conf->fckeditor->dir_output.'/'.$original_file; } - // Wrapping for miscellaneous medias files - elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) - { - $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; - } - // Wrapping for backups else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { diff --git a/htdocs/document.php b/htdocs/document.php index 46e27d57a67..206ea69688a 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -26,6 +26,7 @@ * \brief Wrapper to download data files * \remarks Call of this wrapper is made with URL: * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier + * document.php?modulepart=logs&file=dolibarr.log */ define('NOTOKENRENEWAL',1); // Disables token renewal @@ -106,7 +107,7 @@ $refname=basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); -$check_access = dol_check_secure_access_document($modulepart,$original_file,$entity,$refname); +$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; // original_file is now a full path name @@ -183,7 +184,7 @@ header('Pragma: public'); //ob_clean(); //flush(); - + readfile($original_file_osencoded); if (is_object($db)) $db->close(); From ce8a024d4484c5f42d141e5889f6d62b0eebf51e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 00:34:56 +0200 Subject: [PATCH 236/342] Fix limit on margin pages --- htdocs/margin/agentMargins.php | 22 ++++++++++++---------- htdocs/margin/customerMargins.php | 18 ++++++++++++------ htdocs/margin/productMargins.php | 28 ++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f474b7af340..e00eb4ae18b 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -44,8 +44,15 @@ if ($user->rights->margins->read->all) { $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) { @@ -54,11 +61,6 @@ if (! $sortfield) else $sortfield="u.lastname"; } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; $startdate=$enddate=''; @@ -170,13 +172,13 @@ if ($result) $num = $db->num_rows($result); print '
    '; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print ""; @@ -220,7 +222,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($agentid > 0) { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 64b0dd82ff2..ed76cde223c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -41,11 +41,17 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; -$page = GETPOST("page",'int'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +if (! $sortfield) $sortfield="s.nom"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; $startdate=$enddate=''; @@ -206,13 +212,13 @@ if ($result) $num = $db->num_rows($result); print '
    '; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $i = 0; print "
    "; @@ -260,7 +266,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($client) { @@ -295,7 +301,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; /*if ($totalMargin < 0) { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f1ed5afe573..43a9ef0f22e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -46,9 +46,15 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortfield) { if ($id > 0) @@ -63,12 +69,6 @@ if (! $sortfield) } } -$page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - $startdate=$enddate=''; if (!empty($_POST['startdatemonth'])) @@ -202,16 +202,16 @@ if ($result) $num = $db->num_rows($result); print '
    '; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,$num,''); + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); //var_dump($conf->global->MARGIN_TYPE); if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $i = 0; print '
    '; print '
    '."\n"; @@ -260,7 +260,7 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - + print ''; if ($id > 0) { @@ -308,7 +308,7 @@ if ($result) } // affichage totaux marges - + $totalMargin = $cumul_vente - $cumul_achat; $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; From 9ec792975396b708dd1e90fd535bcae94df26a9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 10:57:15 +0200 Subject: [PATCH 237/342] Look and feel v6 --- htdocs/margin/agentMargins.php | 25 +++- htdocs/margin/checkMargins.php | 237 +++++++++++++++--------------- htdocs/margin/customerMargins.php | 1 + htdocs/margin/productMargins.php | 1 + htdocs/theme/eldy/style.css.php | 5 +- htdocs/theme/md/style.css.php | 5 +- 6 files changed, 143 insertions(+), 131 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index e00eb4ae18b..6c3a246ad0d 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -34,14 +34,6 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); -} else { - $agentid = $user->id; -} - $mesg = ''; // Load variable for pagination @@ -69,6 +61,23 @@ if (!empty($_POST['startdatemonth'])) if (!empty($_POST['enddatemonth'])) $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +// Security check +if ($user->rights->margins->read->all) { + $agentid = GETPOST('agentid', 'int'); +} else { + $agentid = $user->id; +} +$result=restrictedArea($user,'margins'); + + +/* + * Actions + */ + +// None + + + /* * View */ diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index c576b3ce4a6..ab6394eb74c 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -34,72 +34,35 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->creer) { - $agentid = $user->id; -} else { - accessforbidden(); -} - -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortorder) - $sortorder = "DESC"; -if (! $sortfield) { - $sortfield = 'f.facnumber'; -} -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - -// Both test are required to be compatible with all browsers -if (GETPOST("button_search_x") || GETPOST("button_search")) { - $action = 'search'; -} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { - $action = 'update'; -} - -if ($action == 'update') { - $datapost = $_POST; - - foreach ( $datapost as $key => $value ) { - if (strpos($key, 'buyingprice_') !== false) { - $tmp_array = explode('_', $key); - if (count($tmp_array) > 0) { - $invoicedet_id = $tmp_array[1]; - if (! empty($invoicedet_id)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; - $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; - $sql .= ' WHERE rowid=' . $invoicedet_id; - $result = $db->query($sql); - if (!$result) { - setEventMessages($db->lasterror, null, 'errors'); - } - } - } - } - } -} +if (! $sortorder) $sortorder = "DESC"; +if (! $sortfield) $sortfield = 'f.facnumber'; $startdate = $enddate = ''; $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int')); -if (! empty($startdate)) { - $options .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); -} -if (! empty($enddate)) { - $options .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); -} - $search_ref = GETPOST('search_ref','alpha'); +// Security check +$result=restrictedArea($user,'margins'); + +// Both test are required to be compatible with all browsers +if (GETPOST("button_search_x") || GETPOST("button_search")) { + $action = 'search'; +} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { + $action = 'update'; +} + /* * Actions @@ -117,6 +80,28 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + if ($action == 'update') { + $datapost = $_POST; + + foreach ( $datapost as $key => $value ) { + if (strpos($key, 'buyingprice_') !== false) { + $tmp_array = explode('_', $key); + if (count($tmp_array) > 0) { + $invoicedet_id = $tmp_array[1]; + if (! empty($invoicedet_id)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; + $sql .= ' WHERE rowid=' . $invoicedet_id; + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror, null, 'errors'); + } + } + } + } + } + } + // 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 { @@ -155,6 +140,17 @@ llxHeader('', $title); // print_fiche_titre($text); +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($startdate)) { + $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +} +if (! empty($enddate)) { + $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; @@ -202,7 +198,7 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - + dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -212,31 +208,30 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } -$sql .= $db->plimit($conf->liste_limit + 1, $offset); +$sql .= $db->plimit($limit+1, $offset); -dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
    '; - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $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=''; - + print '
    '; print '
    '."\n"; - + print ''; print ''; print ''; @@ -249,66 +244,66 @@ if ($result) { print $searchpitco; print ''; print "\n"; - + print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $options, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - if ($num > 0) { - while ($objp = $db->fetch_object($result)) - { - $var = ! $var; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "\n"; - - $i ++; + + $i=0; + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $i ++; } + print "
    '; - $result_inner = $invoicestatic->fetch($objp->invoiceid); - if ($result_inner < 0) { - setEventMessages($invoicestatic->error, null, 'errors'); - } else { - print $invoicestatic->getNomUrl(1); - } - print ''; - if (! empty($objp->fk_product)) { - $result_inner = $productstatic->fetch($objp->fk_product); - if ($result_inner < 0) { - setEventMessages($productstatic->error, null, 'errors'); - } else { - print $productstatic->getNomUrl(1); - } - } else { - print $objp->label; - print ' '; - print $objp->description; - } - print ''; - print price($objp->subprice); - print ''; - print ''; - print ''; - print $objp->qty; - print ''; - print price($objp->total_ht); - print '
    '; + $result_inner = $invoicestatic->fetch($objp->invoiceid); + if ($result_inner < 0) { + setEventMessages($invoicestatic->error, null, 'errors'); + } else { + print $invoicestatic->getNomUrl(1); } + print ''; + if (! empty($objp->fk_product)) { + $result_inner = $productstatic->fetch($objp->fk_product); + if ($result_inner < 0) { + setEventMessages($productstatic->error, null, 'errors'); + } else { + print $productstatic->getNomUrl(1); + } + } else { + print $objp->label; + print ' '; + print $objp->description; + } + print ''; + print price($objp->subprice); + print ''; + print ''; + print ''; + print $objp->qty; + print ''; + print price($objp->total_ht); + print '
    "; - + print "
    "; } else { dol_print_error($db); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index ed76cde223c..643fdcb4704 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -37,6 +37,7 @@ $langs->load("margins"); $socid = GETPOST('socid','int'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); +$result = restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 43a9ef0f22e..77f7e23c84f 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -43,6 +43,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); +$result=restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c3bfa8b05cb..3f05f66c82b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4043,12 +4043,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e96fa032538..802eb46f6af 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4128,12 +4128,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } From 4102403482156add2e1342d7d8b02f8604678b6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 11:37:34 +0200 Subject: [PATCH 238/342] Look and feel v6 --- htdocs/categories/card.php | 11 +++++------ htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/ajax.lib.php | 20 ++++++++++---------- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/product/card.php | 4 +++- htdocs/product/stock/card.php | 4 +++- htdocs/societe/ajax/company.php | 5 +++-- htdocs/supplier_proposal/card.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- 14 files changed, 35 insertions(+), 31 deletions(-) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 55bf400ea3a..9f49e42f060 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2013 Florian Henry @@ -221,9 +221,7 @@ llxHeader("",$langs->trans("Categories"),$helpurl); if ($user->rights->categorie->creer) { - /* - * Fiche en mode creation - */ + // Create or add if ($action == 'create' || $_POST["addcat"] == 'addcat') { dol_set_focus('#label'); @@ -246,7 +244,7 @@ if ($user->rights->categorie->creer) // Ref print ''; - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print''; // Description @@ -263,7 +261,8 @@ if ($user->rights->categorie->creer) // Parent category print ''.$langs->trans("AddIn").''; - print $form->select_all_categories($type, $catorigin); + print $form->select_all_categories($type, $catorigin, 'parent'); + print ajax_combobox('parent'); print ''; $parameters=array(); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 67dbca101f8..0c9d97fc299 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1360,7 +1360,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f837119730c..a10de641ea1 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1477,7 +1477,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print ''; - print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty'); + print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7c8efcc8328..1a19d0da776 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -995,7 +995,7 @@ class Form unset($societetmp); } // mode 1 - $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype?'&showtype='.$showtype:''); $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out.=''."\n";*/ $contentforedit .= $objectpage->content; - + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); @@ -1056,23 +1071,23 @@ if ($action == 'preview') $objectpage->fetch($pageid); $out = "\n".''."\n"; - + $out.='
    '."\n"; - + $csscontent = @file_get_contents($filecss); - + $out.=''."\n"; - + $out.=$objectpage->content."\n"; - + $out.='
    '; - + $out.= "\n".''."\n\n"; - + print $out; - + /*file_put_contents($filetpl, $out); if (! empty($conf->global->MAIN_UMASK)) @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); @@ -1080,17 +1095,17 @@ if ($action == 'preview') // Output file on browser dol_syslog("index.php include $filetpl $filename content-type=$type"); $original_file_osencoded=dol_osencode($filetpl); // New file name encoded in OS encoding charset - + // This test if file exists should be useless. We keep it to find bug more easily if (! file_exists($original_file_osencoded)) { dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); exit; } - + //include_once $original_file_osencoded; */ - + /*print '';*/ } From efecb32ec98459e1810f61772bc72c8578841a59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 00:11:22 +0200 Subject: [PATCH 330/342] Fix migration --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 5d1948f318f..0b41cf739ef 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 @@ -25,7 +25,22 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +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 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; + -- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00'; +-- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN datefin datetime NULL; + +-- To remove a default value for date that is not valid when field is not null +-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime DEFAULT NULL; +-- VMYSQL4.1 ALTER TABLE llx_chargesociales MODIFY COLUMN date_ech datetime NOT NULL; + + + -- Clean corrupted values for tms -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; From aa1351d48393915c0c5fb992b374e9962151e988 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:10:09 +0200 Subject: [PATCH 331/342] Fix to be sure database is not created using utf8mb4 (not yet supported) --- htdocs/core/db/mysqli.class.php | 10 ++++++++-- htdocs/install/mysql/migration/repair.sql | 11 ++++++++--- .../mysql/tables/llx_product_attribute.key.sql | 3 ++- htdocs/install/step1.php | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 24ed1425f6b..526d43de0ab 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -857,6 +857,7 @@ class DoliDBMysqli extends DoliDB * Return charset used to store data in current database (same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";) * * @return string Charset + * @see getDefaultCollationDatabase */ function getDefaultCharacterSetDatabase() { @@ -867,7 +868,9 @@ class DoliDBMysqli extends DoliDB return $this->forcecharset; } $liste=$this->fetch_array($resql); - return $liste['Value']; + $tmpval = $liste['Value']; + + return $tmpval; } /** @@ -900,6 +903,7 @@ class DoliDBMysqli extends DoliDB * Return collation used in current database * * @return string Collation value + * @see getDefaultCharacterSetDatabase */ function getDefaultCollationDatabase() { @@ -910,7 +914,9 @@ class DoliDBMysqli extends DoliDB return $this->forcecollate; } $liste=$this->fetch_array($resql); - return $liste['Value']; + $tmpval = $liste['Value']; + + return $tmpval; } /** diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index f9ec23d4f69..95840f73cb8 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -13,12 +13,17 @@ -- flush privileges; --- Requests to change character set and collation of a varchar column. --- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) +-- Request to change default pagecode + colation of database +-- ALTER DATABASE name_of_database CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- Request to change default pagecode + colation of table +-- ALTER TABLE name_of_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; + +-- Request to change character set and collation of a varchar column. +-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- You can check with 'show full columns from llx_accounting_account'; +-- You can check with 'show full columns from mytablename'; diff --git a/htdocs/install/mysql/tables/llx_product_attribute.key.sql b/htdocs/install/mysql/tables/llx_product_attribute.key.sql index 28d687dbdda..f107a855e61 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute.key.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute.key.sql @@ -16,4 +16,5 @@ -- -- ============================================================================ -ALTER TABLE llx_product_attribute ADD CONSTRAINT unique_ref UNIQUE (ref); \ No newline at end of file +ALTER TABLE llx_product_attribute ADD UNIQUE INDEX uk_product_attribute_ref (ref); + diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 9ad30fe5d7b..a0fdc22a015 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -312,8 +312,11 @@ if (! $error && $db->connected) // Define $defaultCharacterSet and $defaultDBSortingCollation if (! $error && $db->connected) { - if (!empty($db_create_database)) { // If we create database, we force default value - $defaultCharacterSet=$db->forcecharset; + if (!empty($db_create_database)) // If we create database, we force default value + { + // Default values come from the database handler + + $defaultCharacterSet=$db->forcecharset; $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value @@ -322,6 +325,14 @@ if (! $error && $db->connected) $defaultDBSortingCollation=$db->getDefaultCollationDatabase(); } + // Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29) + // TODO Remove this when utf8mb4 is supported + if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci') + { + $defaultCharacterSet = 'utf8'; + $defaultDBSortingCollation = 'utf8_unicode_ci'; + } + print ''; print ''; $db_character_set=$defaultCharacterSet; From d57fe35efc0327ff4b7b191e40a508b2cd1a65f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:36:04 +0200 Subject: [PATCH 332/342] Add option to fix corrupted database with bad pagecode --- htdocs/install/repair.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 895d36d72f1..3cfbbda5d26 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -78,6 +78,7 @@ print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(G print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'
    '."\n"; print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'
    '."\n"; print 'Option force_disable_of_modules_not_found (0 or \'test\' or \'confirmed\') is '.(GETPOST('force_disable_of_modules_not_found','alpha')?GETPOST('force_disable_of_modules_not_found','alpha'):'0').'
    '."\n"; +print 'Option force_utf8_on_tables, for mysql/mariadb only(0 or \'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables','alpha')?GETPOST('force_utf8_on_tables','alpha'):'0').'
    '."\n"; print '
    '; print ''; @@ -890,6 +891,35 @@ if ($ok && GETPOST('force_disable_of_modules_not_found','alpha')) +// clean_old_module_entries: Clean data into const when files of module were removed without being +// clean_linked_elements: Check and clean linked elements +if ($ok && GETPOST('force_utf8_on_tables','alpha')) +{ + print ''; + + if ($db->type == "mysql") + { + $listoftables = $db->DDLListTables($db->database_name); + + foreach($listoftables as $table) + { + print ''; + } + } + else + { + print ''; + } +} + + print '

    *** Force page code and collation with utf8 (for mysql/mariadb only)
    '; + print $table; + $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; + if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed') + { + $db->query($sql); + } + print '
    Not available with database type '.$db->type.'
    '; From 8a96260892ae9b4f76026e8c065291c6ced85901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 01:57:28 +0200 Subject: [PATCH 333/342] Fix amount not filled into email confirmation --- htdocs/public/stripe/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index af0c880d3c8..962185b8397 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -297,7 +297,7 @@ if ($action == 'charge') } $_SESSION["onlinetoken"] = $stripeToken; - $_SESSION["FinalPaymentAmt"] = $amount; + $_SESSION["Payment_Amount"] = $amount; $_SESSION["currencyCodeType"] = $currency; $_SESSION["paymentType"] = ''; $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip From db1d97c9ac8e8d3f39e7c63876dfc6779b335a5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 02:09:14 +0200 Subject: [PATCH 334/342] Fix bad value for ref of old contracts --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) 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 0b41cf739ef..f418a5e6a1f 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 @@ -346,6 +346,8 @@ 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 TABLE llx_contrat set ref = rowid where ref is null or ref = ''; + create table llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, From 9e26e6b0a3600b1172a01f31a0772e9f5b4bc7bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 02:09:14 +0200 Subject: [PATCH 335/342] Fix bad value for ref of old contracts --- htdocs/admin/websites.php | 51 +++++++++++------- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/core/lib/website.lib.php | 33 ++++++++---- htdocs/core/modules/modWebsites.class.php | 6 +-- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + htdocs/langs/en_US/website.lang | 3 +- htdocs/public/error-404.php | 2 +- htdocs/public/websites/index.php | 52 +++++++++++++++---- htdocs/public/websites/styles.css.php | 21 +++++--- htdocs/websites/index.php | 13 ++++- 10 files changed, 132 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 4dbd154096f..0336a2533c0 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -25,8 +25,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -35,7 +37,6 @@ $langs->load("website"); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); $id=1; @@ -135,7 +136,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) { @@ -185,7 +186,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + unset($_POST); // Clean $_POST array, we keep only } else { @@ -204,6 +205,10 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } + $website=new Website($db); + $rowid=GETPOST('rowid','int'); + $website->fetch($rowid); + // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs @@ -229,7 +234,17 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if ($resql) + { + $newname = dol_sanitizeFileName(GETPOST('ref','aZ09')); + if ($newname != $website->ref) + { + $srcfile=DOL_DATA_ROOT.'/websites/'.$website->ref; + $destfile=DOL_DATA_ROOT.'/websites/'.$newname; + @rename($srcfile, $destfile); + } + } + else { setEventMessages($db->error(), null, 'errors'); } @@ -249,7 +264,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete $sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'"; $result = $db->query($sql); - + $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; $result = $db->query($sql); if (! $result) @@ -321,7 +336,7 @@ print "
    \n"; // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&id='.$id, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -355,7 +370,7 @@ if ($id) $fieldlist=explode(',',$tabfield[$id]); - print '
    '; + print ''; print ''; print ''; @@ -388,9 +403,7 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - if ($id == 4) print ''; print ''; print ''; @@ -444,19 +457,19 @@ if ($id) if ($num) { print '
    '; - - print ''; + + print ''; print ''; print ''; print ''; - + print '
    '; - print ''; print '
    '; - + // There is several pages if ($num > $listlimit) { print ''; } @@ -486,11 +499,11 @@ if ($id) // Affiche nom du champ if ($showfield) { - print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); + print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':''),"","align=".$align,$sortfield,$sortorder); } } - print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); + print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':''),"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -539,7 +552,7 @@ if ($id) // Can an entry be erased or disabled ? $iserasable=1;$isdisable=1; // true by default - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&'; // Active print '
    '; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], '&id='.$id, ($num > $listlimit), ''); + print_fleche_navigation($page, $_SERVER["PHP_SELF"], '', ($num > $listlimit), ''); print '
    '; @@ -558,9 +571,9 @@ if ($id) } $i++; } - + print '
    '; - + print '
    '; } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dedb169dc38..614379a2900 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Make a change into HTML code to allow to include images from medias directory. // // become - // + // $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ebbd261984e..37f01a0ffe3 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -31,21 +31,36 @@ function dolWebsiteOutput($content) { global $db, $langs, $conf, $user; + global $dolibarr_main_url_root; dol_syslog("dolWebsiteOutput start"); - + if (! defined('USEDOLIBARRSERVER')) { - // Replace link of Dolibarr medias with direct link for virtual server - - - - - + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $symlinktomediaexists=1; + + // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server + // + // become + // + $nbrep=0; + if (! $symlinktomediaexists) + { + $content=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + } + else + { + $content=preg_replace('/()/', '\1medias/\4\5', $content, -1, $nbrep); + } } - + dol_syslog("dolWebsiteOutput end"); - + print $content; } diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 877c78b85eb..57abe371314 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -42,15 +42,15 @@ class modWebsites extends DolibarrModules $this->db = $db; $this->numero = 10000; - + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; $this->module_position = 50; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Enable the public website with CMS features"; - $this->version = 'development'; // 'experimental' or 'dolibarr' or version + $this->description = "Enable to build and serve public websites with CMS features"; + $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) 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 0b41cf739ef..f418a5e6a1f 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 @@ -346,6 +346,8 @@ 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 TABLE llx_contrat set ref = rowid where ref is null or ref = ''; + create table llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 4482093b26d..dd6332b11a7 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -14,8 +14,9 @@ EditPageContent=Edit Content Website=Web site Webpage=Web page AddPage=Add page +HomePage=Home Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. -RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this. +RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this. PageDeleted=Page '%s' of website %s deleted PageAdded=Page '%s' added ViewSiteInNewTab=View site in new tab diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index 951f29b7dde..36547d26704 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -18,7 +18,7 @@

    Error


    - You requested a page that does not exists. + You requested a website or a page that does not exists.
    diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 4c2eec0edc5..0bc85dce463 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -67,23 +67,51 @@ if (empty($pageid)) { require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; - + $object=new Website($db); $object->fetch(0, $website); - - $objectpage=new WebsitePage($db); - $array=$objectpage->fetchAll($object->id); - - if (count($array) > 0) + if (empty($object->id)) { - $firstrep=reset($array); - $pageid=$firstrep->id; + if (empty($pageid)) + { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; + exit; + } + } + + $objectpage=new WebsitePage($db); + + if ($object->fk_default_home > 0) + { + $result=$objectpage->fetch($object->fk_default_home); + if ($result > 0) + { + $pageid = $objectpage->id; + } + } + + if (empty($pageid)) + { + $array=$objectpage->fetchAll($object->id); + if (is_array($array) && count($array) > 0) + { + $firstrep=reset($array); + $pageid=$firstrep->id; + } } } if (empty($pageid)) { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + $langs->load("website"); print $langs->trans("PreviewOfSiteNotYetAvailable"); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; } @@ -95,7 +123,7 @@ if ($pageid == 'css') // No more used ? header('Content-type: text/css'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); - //else + //else header('Cache-Control: no-cache'); $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php'; } @@ -136,9 +164,13 @@ $original_file_osencoded=dol_osencode($original_file); // New file name encoded // This test if file exists should be useless. We keep it to find bug more easily if (! file_exists($original_file_osencoded)) { + // Return header 404 + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404); + $langs->load("website"); print $langs->trans("RequestedPageHasNoContentYet", $pageid); - //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + + include DOL_DOCUMENT_ROOT.'/public/error-404.php'; exit; } diff --git a/htdocs/public/websites/styles.css.php b/htdocs/public/websites/styles.css.php index 5a736affc25..14014577cea 100644 --- a/htdocs/public/websites/styles.css.php +++ b/htdocs/public/websites/styles.css.php @@ -1,5 +1,5 @@ +/* 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 @@ -18,8 +18,7 @@ /** * \file htdocs/public/websites/styles.css.php * \ingroup website - * \brief Page to output style page - * \author Laurent Destailleur + * \brief Page to output style page. Called with */ define('NOTOKENRENEWAL',1); // Disables token renewal @@ -48,6 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; $website=GETPOST('website', 'alpha'); +$websiteid=GETPOST('websiteid', 'int'); $pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); $accessallowed = 1; @@ -67,13 +67,20 @@ if (empty($pageid)) { require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; - + $object=new Website($db); - $object->fetch(0, $website); - + if ($websiteid) + { + $object->fetch($websiteid); + $website=$object->ref; + } + else + { + $object->fetch(0, $website); + } $objectpage=new WebsitePage($db); $array=$objectpage->fetchAll($object->id); - + if (count($array) > 0) { $firstrep=reset($array); diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 183fa45298a..1a11ea2a4e1 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -414,7 +414,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; @@ -452,6 +452,15 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage { $object->fetch(0, $website); + // Check symlink to medias and restore it if ko + $pathtomedias=DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite=$pathofwebsite.'/medias'; + if (! is_link(dol_osencode($pathtomediasinwebsite))) + { + dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); + symlink($pathtomedias, $pathtomediasinwebsite); + } + /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) { $object->virtualhost = GETPOST('previewsite', 'alpha'); @@ -558,7 +567,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; From 8b91f4fb5ee537980ced85843a983ec98ccb4a9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 12:04:45 +0200 Subject: [PATCH 336/342] Debug module website --- htdocs/collab/index.php | 62 ++++++++++++++++----------------- htdocs/langs/en_US/website.lang | 3 +- htdocs/websites/index.php | 6 ++-- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index ea7abde4151..7f08beff955 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -49,7 +49,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); print ''; - + // top menu and left menu area if (empty($conf->dol_hide_topmenu)) { @@ -108,7 +108,7 @@ if (empty($action)) $action='preview'; */ if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. -if (GETPOST('refreshpage')) $action='preview'; +if (GETPOST('refreshpage')) $action='preview'; // Add a collab page @@ -146,7 +146,7 @@ if ($action == 'add') { $db->rollback(); } - + $action = 'preview'; $id = $objectpage->id; } @@ -173,7 +173,7 @@ if ($action == 'delete') { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); - + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); exit; } @@ -218,7 +218,7 @@ print '
    '; if (count($object->records) > 0) { // ***** Part for web sites - + print '
    '; print $langs->trans("Website").': '; print '
    '; @@ -252,20 +252,20 @@ if (count($object->records) > 0) $dataroot=DOL_DATA_ROOT.'/websites/'.$website; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; } - + if ($website && $action == 'preview') { $disabled=''; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; - + print '   '; - + //print ''; print ''; print ''; print ''; } - + print '
    '; // Button for websites @@ -279,7 +279,7 @@ if (count($object->records) > 0) $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); print $form->textwithpicto('', $htmltext); print '
    '; - + $urlext=$virtualurl; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; //if (! empty($object->virtualhost)) @@ -288,7 +288,7 @@ if (count($object->records) > 0) print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; //} - + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print ''; @@ -300,12 +300,12 @@ if (count($object->records) > 0) if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print ''; // ***** Part for pages - + if ($website) { print ''; @@ -313,13 +313,13 @@ if (count($object->records) > 0) $array=$objectpage->fetchAll($object->id); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); - + print '
    '; print '
    '; print $langs->trans("Page").': '; print '
    '; print '
    '; - + if ($action != 'add') { $out=''; @@ -336,7 +336,7 @@ if (count($object->records) > 0) } $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page } - + foreach($array as $key => $valpage) { $out.='
    '; print '
    '; print '
    '; @@ -389,17 +389,17 @@ if (count($object->records) > 0) { $websitepage = new WebSitePage($db); $websitepage->fetch($pageid); - + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $pagealias = $websitepage->pageurl; - + print '
    '; print ''; //print ''; $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); print $form->textwithpicto('', $htmltext); print '
    '; - + if (! empty($object->virtualhost)) { $urlext=$virtualurl.'/'.$pagealias.'.php'; @@ -413,12 +413,12 @@ if (count($object->records) > 0) print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print ''; } - + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print ''; // View page in new Tab //print ''; - + // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } if (! in_array($action, array('editcss','editmenu','create'))) @@ -427,7 +427,7 @@ if (count($object->records) > 0) if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print '
    '; if ($action == 'preview') @@ -454,7 +454,7 @@ if (count($object->records) > 0) }, context: document.body }); - + jQuery("#previewsiteext").attr("href",newurl); jQuery("#previewpageext").attr("href",newpage); }); @@ -483,15 +483,15 @@ if ($action == 'editcontent') /* * Editing global variables not related to a specific theme */ - + $csscontent = @file_get_contents($filecss); - + $contentforedit = ''; /*$contentforedit.=''."\n";*/ $contentforedit .= $objectpage->content; - + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor->Create(0, '', false); diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index dd6332b11a7..abb7f7e56d3 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -6,6 +6,7 @@ ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its page WEBSITE_PAGENAME=Page name/alias 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. MediaFiles=Media library EditCss=Edit Style/CSS EditMenu=Edit menu @@ -24,7 +25,7 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. +SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s
    then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. PreviewSiteServedByWebServer=Preview %s in a new tab.

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

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

    To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
    %s
    then enter the name of this virtual server and click on the other preview button. NoPageYet=No pages yet \ No newline at end of file diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 1a11ea2a4e1..a5c2ae4e046 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -727,7 +727,7 @@ if (count($object->records) > 0) print ''; //print ''; $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); - print $form->textwithpicto('', $htmltext); + print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print ''; $urlext=$virtualurl; @@ -846,8 +846,8 @@ if (count($object->records) > 0) print '
    '; print ''; //print ''; - $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); - print $form->textwithpicto('', $htmltext); + $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); + print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '
    '; if (! empty($object->virtualhost)) From cb1c461b69440755cd5241c02807c14f1318ebb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jul 2017 12:28:52 +0200 Subject: [PATCH 337/342] Work on module builder --- htdocs/langs/en_US/modulebuilder.lang | 15 ++++++---- htdocs/modulebuilder/index.php | 43 ++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 1c3a7932263..9eb910da360 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,8 +1,8 @@ # Dolibarr language file - Source file is en_US - loan -ModuleBuilderDesc=This tools give you utilites to build or edit your own module (More information here). +ModuleBuilderDesc=This tools must be used by experienced users or developers. It gives you utilities to build or edit your own module (Documentation for alternative manual development is here). EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...) -ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): %s +ModuleBuilderDesc2=Path where modules are generated/edited (first alternative directory defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s (they are detected as editable when the file %s exists in root of module directory). NewModule=New module NewObject=New object @@ -11,17 +11,19 @@ ObjectKey=Object key ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object initialized 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. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDeschooks=This tab is dedicated to hooks. ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets. -ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file. -EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module will be definitly lost ! +ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module and a "ready to distribute" documentation file. Just click on button to build the package or documentation file. +EnterNameOfModuleToDeleteDesc=You can delete your module. WARNING: All files of module but also structured data and documentation will be definitly lost ! EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files related to object will be definitly lost ! DangerZone=Danger zone -BuildPackage=Build package +BuildPackage=Build package/documentation +BuildDocumentation=Build documentation ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module to make it live) ModuleIsLive=This module has been activated. Any change on it may break a current active feature. DescriptionLong=Long description @@ -33,5 +35,6 @@ ApiClassFile=File for PHP API class PageForList=PHP page for list of record PageForCreateEditView=PHP page to create/edit/view a record PathToModulePackage=Path to zip of module/application package +PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. -PackageFileNotYetGenerated=Package file not yet generated \ No newline at end of file +FileNotYetGenerated=File not yet generated diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index caa99d4b089..8ea54b78454 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -579,6 +579,11 @@ elseif (! empty($module)) $head2[$h][2] = 'description'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module; + $head2[$h][1] = $langs->trans("Specifications"); + $head2[$h][2] = 'specifications'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module; $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; @@ -692,6 +697,13 @@ elseif (! empty($module)) print ''; } + + if ($tab == 'specifications') + { + print $langs->trans("FeatureNotYetAvailable"); + + } + if ($tab == 'objects') { $head3 = array(); @@ -849,7 +861,6 @@ elseif (! empty($module)) { print $langs->trans("FeatureNotYetAvailable"); - } if ($tab == 'permissions') @@ -900,7 +911,7 @@ elseif (! empty($module)) print ''; } - if ($tab == 'widget') + if ($tab == 'widgets') { print $langs->trans("FeatureNotYetAvailable"); @@ -947,17 +958,22 @@ elseif (! empty($module)) { $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; + + $FILENAMEDOC="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".md"; + $outputfiledoc = $conf->admin->dir_temp.'/'.$FILENAMEDOC; } + print '
    '; + print ' '. $langs->trans("PathToModulePackage") . ' : '; - if (! dol_is_file($outputfile)) print ''.$langs->trans("PackageFileNotYetGenerated").''; + if (! dol_is_file($outputfile)) print ''.$langs->trans("FileNotYetGenerated").''; else { print ''.$outputfile.''; print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; } print '
    '; - print '

    '; + print '
    '; print '
    '; print ''; @@ -965,6 +981,25 @@ elseif (! empty($module)) print ''; print ''; print '
    '; + + print '


    '; + + print ' '. $langs->trans("PathToModuleDocumentation") . ' : '; + if (! dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; + else { + print ''.$outputfiledoc.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; + } + print '
    '; + + print '
    '; + + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; } dol_fiche_end(); From 0ee93fb00c011243c2db224a6d3e8119dd412aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 10:29:38 +0200 Subject: [PATCH 338/342] Fix conflict between option login and logina and logint in agenda export --- htdocs/admin/agenda_xcal.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 64 +++++++++++-------- htdocs/langs/en_US/agenda.lang | 4 +- htdocs/public/agenda/agendaexport.php | 22 +++---- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 1895eb5b15d..99742b19f57 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -174,8 +174,8 @@ $message.='
    '; print $message; $message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
    '; -//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'
    '; $message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
    '; +$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'
    '; $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
    '; $message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8243268574c..70b2acb86b7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -38,7 +38,7 @@ class ActionComm extends CommonObject public $table_rowid = 'id'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='action'; - + /** * Id of the event * @var int @@ -168,7 +168,7 @@ class ActionComm extends CommonObject var $email_subject; var $errors_to; - + /** * Constructor * @@ -444,7 +444,7 @@ class ActionComm extends CommonObject $u->fetch($fuser); $fuser = $u; } - else + else { $fuser = $user; } @@ -657,11 +657,11 @@ class ActionComm extends CommonObject $this->error=$this->db->lasterror(); $error++; } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; $sql.= " WHERE fk_actioncomm=".$this->id; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $res=$this->db->query($sql); if ($res < 0) { @@ -669,7 +669,7 @@ class ActionComm extends CommonObject $error++; } } - + // Removed extrafields if (! $error) { $result=$this->deleteExtraFields(); @@ -1091,7 +1091,7 @@ class ActionComm extends CommonObject else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); } - + return ''; } @@ -1112,20 +1112,20 @@ class ActionComm extends CommonObject global $conf, $langs, $user, $hookmanager; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility $result=''; - + // Set label of typ $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - - + + $tooltip = '' . $langs->trans('ShowAction'.$objp->code) . ''; if (! empty($this->ref)) $tooltip .= '
    ' . $langs->trans('Ref') . ': ' . $this->ref; @@ -1137,7 +1137,7 @@ class ActionComm extends CommonObject $tooltip .= '
    ' . $langs->trans('Location') . ': ' . $this->location; $linkclose=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) @@ -1149,7 +1149,7 @@ class ActionComm extends CommonObject } $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; $linkclose.=' class="'.$classname.' classfortooltip"'; - + if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -1161,17 +1161,17 @@ class ActionComm extends CommonObject $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); } else $linkclose.=' class="'.$classname.'"'; - + $url=''; - if ($option=='birthday') + if ($option=='birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; - else + else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; - + $linkstart = ''; $linkend=''; - + //print 'rrr'.$this->libelle.'-'.$withpicto; if ($withpicto == 2) @@ -1279,7 +1279,7 @@ class ActionComm extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; // We must filter on assignement table - if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql.= " WHERE a.fk_action=c.id"; $sql.= " AND a.entity IN (".getEntity('agenda').")"; foreach ($filters as $key => $value) @@ -1291,20 +1291,34 @@ class ActionComm extends CommonObject if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0); if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0); // We must filter on assignement table - if ($key == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; + if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { $logina=$value; + $condition='='; + if (preg_match('/^!/',$logina)) + { + $logina=preg_replace('/^!/','',$logina); + $condition='<>'; + } $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND a.fk_user_author = ".$userforfilter->id; + $result=$userforfilter->fetch('',$logina); + if ($result > 0) $sql.= " AND a.fk_user_author ".$condition." ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql.= " AND a.fk_user_author = 0"; } - if ($key == 'logint' || $key == 'login') + if ($key == 'logint') { $logint=$value; + $condition='='; + if (preg_match('/^!/',$logint)) + { + $logint=preg_replace('/^!/','',$logint); + $condition='<>'; + } $userforfilter=new User($this->db); - $result=$userforfilter->fetch('',$value); - $sql.= " AND ar.fk_element = ".$userforfilter->id; + $result=$userforfilter->fetch('',$logint); + if ($result > 0) $sql.= " AND ar.fk_element = ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0"; } } $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 9e7af7b0d06..4e2e2acf378 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -80,9 +80,9 @@ AgendaModelModule=Document templates for event DateActionStart=Start date DateActionEnd=End date AgendaUrlOptions1=You can also add following parameters to filter output: -AgendaUrlOptions2=login=%s to restrict output to actions created by or assigned to user %s. AgendaUrlOptions3=logina=%s to restrict output to actions owned by a user %s. -AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s. +AgendaUrlOptionsNotAdmin=logina=!%s to restrict output to actions not owned by user %s. +AgendaUrlOptions4=logint=%s to restrict output to actions assigned to user %s (owner and others). AgendaUrlOptionsProject=project=PROJECT_ID to restrict output to actions associated to project PROJECT_ID. AgendaShowBirthdayEvents=Show birthdays of contacts AgendaHideBirthdayEvents=Hide birthdays of contacts diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index b3886824485..81a67204fdb 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -65,19 +65,18 @@ if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_A // Define format, type and filter $format='ical'; $type='event'; -if (! empty($_GET["format"])) $format=$_GET["format"]; -if (! empty($_GET["type"])) $type=$_GET["type"]; +if (GETPOST("format",'alpha')) $format=GETPOST("format",'apha'); +if (GETPOST("type",'apha')) $type=GETPOST("type",'alpha'); $filters=array(); -if (! empty($_GET["year"])) $filters['year']=$_GET["year"]; -if (! empty($_GET["id"])) $filters['id']=$_GET["id"]; -if (! empty($_GET["idfrom"])) $filters['idfrom']=$_GET["idfrom"]; -if (! empty($_GET["idto"])) $filters['idto']=$_GET["idto"]; -if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; -if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; -if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; -if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; -if (GETPOST("notolderthan")) $filters['notolderthan']=GETPOST("notolderthan","int"); +if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int'); +if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int'); +if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int'); +if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int'); +if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha'); +if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha'); +if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha'); +if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int"); else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; // Check config @@ -115,7 +114,6 @@ foreach ($filters as $key => $value) if ($key == 'idfrom') $filename.='-idfrom'.$value; if ($key == 'idto') $filename.='-idto'.$value; if ($key == 'project') $filename.='-project'.$value; - if ($key == 'login') $filename.='-login'.$value; if ($key == 'logina') $filename.='-logina'.$value; // Author if ($key == 'logint') $filename.='-logint'.$value; // Assigned to } From 95cf36c43bd814a7aeee09a17b432a4d8c8d778c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 10:55:53 +0200 Subject: [PATCH 339/342] Fix use the getUrl function instead of hard coded curl --- htdocs/categories/admin/categorie.php | 3 ++- .../categories/admin/categorie_extrafields.php | 2 +- htdocs/langs/en_US/products.lang | 8 +++++++- htdocs/product/admin/dynamic_prices.php | 2 ++ .../price_global_variable_updater.class.php | 18 ++++++------------ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index d16b081e6ae..55006a8b171 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -37,6 +37,7 @@ $action=GETPOST('action','aZ09'); /* * Actions */ + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -82,7 +83,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup') $head=categoriesadmin_prepare_head(); -dol_fiche_head($head, 'setup', $langs->trans("Categories"), 0, 'category'); +dol_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category'); print ''; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 2bc9f205334..6291d2065c2 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -68,7 +68,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup') $head = categoriesadmin_prepare_head(); -dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category'); +dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index ae9cd743c8f..3c47b188972 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -247,12 +247,18 @@ ComposedProduct=Sub-product MinSupplierPrice=Minimum supplier price MinCustomerPrice=Minimum customer price DynamicPriceConfiguration=Dynamic price configuration -DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. +DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value. AddVariable=Add Variable AddUpdater=Add Updater GlobalVariables=Global variables VariableToUpdate=Variable to update GlobalVariableUpdaters=Global variable updaters +GlobalVariableUpdaterType0=JSON data +GlobalVariableUpdaterHelp0=Parses JSON data from specified URL, VALUE specifies the location of relevant value, +GlobalVariableUpdaterHelpFormat0=Format for request {"URL": "http://example.com/urlofjson", "VALUE": "array1,array2,targetvalue"} +GlobalVariableUpdaterType1=WebService data +GlobalVariableUpdaterHelp1=Parses WebService data from specified URL, NS specifies the namespace, VALUE specifies the location of relevant value, DATA should contain the data to send and METHOD is the calling WS method +GlobalVariableUpdaterHelpFormat1=Format for request is {"URL": "http://example.com/urlofws", "VALUE": "array,targetvalue", "NS": "http://example.com/urlofns", "METHOD": "myWSMethod", "DATA": {"your": "data", "to": "send"}} UpdateInterval=Update interval (minutes) LastUpdated=Latest update CorrectlyUpdated=Correctly updated diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 24f1d64e30c..b044471e3e1 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -54,9 +54,11 @@ if ($action == 'edit_updater') { } } + /* * Actions */ + if (!empty($action) && empty($cancel)) { //Global variable actions if ($action == 'create_variable' || $action == 'edit_variable') { diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index 3c176f0530e..0948275ce2b 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -464,24 +464,18 @@ class PriceGlobalVariableUpdater } $result = ""; if ($this->type == 0) { - //CURL client - $handle = curl_init(); - curl_setopt_array($handle, array( - CURLOPT_URL => $url, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_TIMEOUT => 5, - CURLOPT_POST => false, - CURLOPT_HEADER => false, - )); + // Call JSON request + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + $tmpresult=getURLContent($url); + $code=$tmpresult['http_code']; + $result=$tmpresult['content']; - $result = curl_exec($handle); - $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); if (!isset($result)) { $this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response"); return -1; } if ($code !== 200) { - $this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code); + $this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']); return -1; } From 77f5952318a6fd58617dcd35d7c3ab44471ad271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 11:18:48 +0200 Subject: [PATCH 340/342] Fix pgsql compatibility --- htdocs/core/db/mysqli.class.php | 10 +++++----- htdocs/core/db/pgsql.class.php | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 526d43de0ab..4358e8695fe 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -735,13 +735,13 @@ class DoliDBMysqli extends DoliDB { // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); - $sql= "ALTER TABLE ".$table." ADD `".$field_name."` "; + $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql.= $field_desc['type']; if(preg_match("/^[^\s]/i",$field_desc['value'])) - if (! in_array($field_desc['type'],array('date','datetime'))) - { - $sql.= "(".$field_desc['value'].")"; - } + if (! in_array($field_desc['type'],array('date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } if(preg_match("/^[^\s]/i",$field_desc['attribute'])) $sql.= " ".$field_desc['attribute']; if(preg_match("/^[^\s]/i",$field_desc['null'])) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 4aa56b367f3..d02ff4a1341 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1048,8 +1048,11 @@ class DoliDBPgsql extends DoliDB // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql .= $field_desc['type']; - if ($field_desc['type'] != 'int' && preg_match("/^[^\s]/i",$field_desc['value'])) - $sql .= "(".$field_desc['value'].")"; + if(preg_match("/^[^\s]/i",$field_desc['value'])) + if (! in_array($field_desc['type'],array('int','date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } if (preg_match("/^[^\s]/i",$field_desc['attribute'])) $sql .= " ".$field_desc['attribute']; if (preg_match("/^[^\s]/i",$field_desc['null'])) From c1e747fa39d25490d6c1992684ebc7316fb70a0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jul 2017 13:05:02 +0200 Subject: [PATCH 341/342] Look and feel v6 --- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 2 +- htdocs/opensurvey/list.php | 14 +++++++++++--- htdocs/resource/list.php | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index f067b27b3d4..ded3dec120e 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -101,7 +101,7 @@ else $head = member_stats_prepare_head($adh); -dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), 0, 'user'); +dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user'); // Print title diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 1f9ff189068..1c6944c2a0a 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -198,7 +198,7 @@ if ($mode) $head = member_stats_prepare_head($adh); -dol_fiche_head($head, $tab, $langs->trans("Statistics"), 0, 'user'); +dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 0593f9ccd05..d5a17f02239 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -172,7 +172,7 @@ while ($i < min($num,$limit)) $opensurvey_static->id=$obj->id_sondage; $opensurvey_static->status=$obj->status; - + print ''; print ''; print''."\n"; - + print ''; print''."\n"; - + print''."\n"; print ''."\n"; $i++; } +// If no record found +if ($num == 0) +{ + $colspan=8; + //foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + print '
    '; print ''.img_picto('','object_opensurvey').' '.$obj->id_sondage.''; @@ -198,19 +198,27 @@ while ($i < min($num,$limit)) print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day'); if ($db->jdate($obj->date_fin) < time()) { print ' ('.$langs->trans("Expired").')'; } print ''.$opensurvey_static->getLibStatut(5).'
    '.$langs->trans("NoRecordFound").'
    '."\n"; print ''; print ''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 11405d15acc..53658c588c6 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -311,7 +311,9 @@ if ($ret) } else { - print ''.$langs->trans('NoResourceInDatabase').''; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; } print ''; From e7e4252244e9a2a04e1d2e2b03265a6d1e3e49ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Jul 2017 01:23:42 +0200 Subject: [PATCH 342/342] Fix deletion of category --- htdocs/categories/class/categorie.class.php | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 60ef207bb48..b294f7c4aeb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -447,9 +447,10 @@ class Categorie extends CommonObject * Delete a category from database * * @param User $user Object user that ask to delete - * @return int <0 KO >0 OK + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 KO >0 OK */ - function delete($user) + function delete($user, $notrigger=0) { global $conf,$langs; @@ -462,6 +463,14 @@ class Categorie extends CommonObject $this->db->begin(); + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + /* FIX #1317 : Check for child category and move up 1 level*/ if (! $error) { @@ -580,25 +589,16 @@ class Categorie extends CommonObject $this->error=$this->db->lasterror(); $error++; } - else + } + + // Removed extrafields + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) { - // Removed extrafields - if (! $error) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); - } - } - } - // Call trigger - $result=$this->call_trigger('CATEGORY_DELETE',$user); - if ($result < 0) { $error++; } - // End call triggers + $error++; + dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); } }