From 5624257a6def5f4f79149d274d2f674989982d83 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 20 Feb 2018 16:49:49 +0100 Subject: [PATCH 01/57] add new dom html5 elements and class --- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 16 ++++++++-------- htdocs/commande/tpl/linkedobjectblock.tpl.php | 16 ++++++++-------- .../compta/facture/tpl/linkedobjectblock.tpl.php | 16 ++++++++-------- htdocs/core/class/html.form.class.php | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index cc8c6fe0547..3f7e6f2ed8b 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,18 +52,18 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - - trans("Proposal"); ?> - getNomUrl(1); ?> - ref_client; ?> - date,'day'); ?> - " data-element="element; ?>" data-elementid="id; ?>" > + trans("Proposal"); ?> + getNomUrl(1); ?> + ref_client; ?> + date,'day'); ?> + rights->propale->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + getLibStatut(3); ?> + ">transnoentitiesnoconv("RemoveLink")); ?> $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - - trans("CustomerOrder"); ?> - getNomUrl(1); ?> - ref_client; ?> - date,'day'); ?> - " data-element="element; ?>" data-elementid="id; ?>" > + trans("CustomerOrder"); ?> + getNomUrl(1); ?> + ref_client; ?> + date,'day'); ?> + rights->commande->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - getLibStatut(3); ?> - + getLibStatut(3); ?> + element != 'shipping') { diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index ca3ec7c89c0..e77a4975789 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -47,12 +47,12 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - - trans("CustomerInvoice"); ?> - getNomUrl(1); ?> - ref_client; ?> - date,'day'); ?> - " data-element="element; ?>" data-elementid="id; ?>" > + trans("CustomerInvoice"); ?> + getNomUrl(1); ?> + ref_client; ?> + date,'day'); ?> + rights->facture->lire) { $sign = 1; if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; @@ -66,8 +66,8 @@ foreach($linkedObjectBlock as $key => $objectlink) echo ''.price($objectlink->total_ht).''; } } ?> - getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + getLibStatut(3); ?> + ">transnoentitiesnoconv("RemoveLink")); ?> '; - print ''; + print '
'; print ''; print ''; @@ -5933,7 +5933,7 @@ class Form global $noMoreLinkedObjectBlockAfter; $noMoreLinkedObjectBlockAfter=1; } - + $res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php'); if ($res) { From 09c5dc506a16302405bddcc4b5c6eb6463de4bd6 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 20 Feb 2018 17:46:32 +0100 Subject: [PATCH 02/57] Add html dom element and fix class --- .../comm/propal/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/commande/tpl/linkedobjectblock.tpl.php | 2 +- .../facture/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/core/class/commonobject.class.php | 18 ++++++++++++------ htdocs/core/tpl/objectline_view.tpl.php | 9 ++++++++- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 3f7e6f2ed8b..2de3fd6afe3 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,7 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - + diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 3fb6f2d0bba..4f072ae94c8 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -47,7 +47,7 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - + diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index e77a4975789..0dbc044b027 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -47,7 +47,7 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - + diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8def2194fb3..1fe99edb192 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5847,21 +5847,27 @@ abstract class CommonObject else { $csstyle=''; - $class=(!empty($extrafields->attribute_hidden[$key]) ? 'class="hideobject" ' : ''); + $class=(!empty($extrafields->attribute_hidden[$key]) ? 'hideobject ' : ''); if (is_array($params) && count($params)>0) { if (array_key_exists('style',$params)) { $csstyle=$params['style']; } } + + // add html5 elements + $domData = ' data-element="extrafield"'; + $domData .= ' data-targetelement="'.$this->element.'"'; + $domData .= ' data-targetid="'.$this->id.'"'; + + $html_id = !empty($this->id) ? 'extrarow-'.$this->element.'_'.$key.'_'.$this->id : ''; + + $out .= ''; + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { - $out .= ''; $colspan='0'; } - else - { - $out .= ''; - } + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 8d5b13ece7c..cdc7044cd42 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -56,10 +56,17 @@ if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; +// add html5 elements +$domData = ' data-element="'.$line->element.'"'; +$domData .= ' data-id="'.$line->id.'"'; +$domData .= ' data-qty="'.$line->qty.'"'; +$domData .= ' data-product_type="'.$line->product_type.'"'; + + ?> -> + > global->MAIN_VIEW_LINE_NUMBER)) { ?> From f313fb925ba2e04f31084c45a33792c968595a9f Mon Sep 17 00:00:00 2001 From: John Date: Wed, 21 Feb 2018 17:06:40 +0100 Subject: [PATCH 03/57] Add new checkbox for lines --- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/class/commonobject.class.php | 13 ++++++++++++- htdocs/core/tpl/objectline_view.tpl.php | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 54c7db7d6ca..440e69cb19d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2473,7 +2473,7 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Form to add new line */ - if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer) + if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer && $action != 'selectlines') { if ($action != 'editline') { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ab7e0826553..7d8997ee0c7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4224,7 +4224,7 @@ else if ($id > 0 || ! empty($ref)) // Form to add new line if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline' && ($object->is_first() || !$object->situation_cycle_ref)) { - if ($action != 'editline') + if ($action != 'editline' && $action != 'selectlines') { // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 18d2add801c..d5eb70c6811 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3594,7 +3594,7 @@ abstract class CommonObject if (empty($reshook)) { print ''; - + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; // Description @@ -3661,6 +3661,14 @@ abstract class CommonObject print ''; + if($action == 'selectlines') + { + print ''; + } + print "\n"; } @@ -5882,6 +5890,8 @@ abstract class CommonObject $colspan='0'; } + if($action == 'selectlines'){ $colspan++; } + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { @@ -5914,6 +5924,7 @@ abstract class CommonObject } $out .= ''; + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; else $out .= ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index cdc7044cd42..f68d6ea5cf8 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -251,7 +251,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; statut == 0 && ($object_rights->creer)) { ?> + if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) { ?> + + + Date: Thu, 22 Feb 2018 15:19:20 +0100 Subject: [PATCH 04/57] Add popin dialog --- htdocs/commande/tpl/linkedobjectblock.tpl.php | 6 +- htdocs/compta/facture/card.php | 19 +++- htdocs/core/class/html.form.class.php | 22 ++++- .../tpl/ajax/objectlinked_lineimport.tpl.php | 99 +++++++++++++++++++ 4 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 4f072ae94c8..43da34b3b24 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -47,8 +47,10 @@ foreach($linkedObjectBlock as $key => $objectlink) $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - - + + diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7d8997ee0c7..f0f2464904e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2087,6 +2087,13 @@ if (empty($reshook)) header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); } + + // add lines from objectlinked + elseif ($action == 'import_lines_from_object' && $user->rights->facture->creer) + { + + + } // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -4516,8 +4523,16 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + + $compatibleImportElementsList = false; + if($user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) + { + $compatibleImportElementsList = array('commande'); // import from linked elements + } + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); + // Show online payment link $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 116a5de5d25..166185d8de3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5833,9 +5833,10 @@ class Form * * @param CommonObject $object Object we want to show links to * @param string $morehtmlright More html to show on right of title + * @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action * @return int <0 if KO, >=0 if OK */ - function showLinkedObjectBlock($object, $morehtmlright='') + function showLinkedObjectBlock($object, $morehtmlright='',$compatibleImportElementsList=false) { global $conf,$langs,$hookmanager; global $bc; @@ -5844,7 +5845,9 @@ class Form // Bypass the default method $hookmanager->initHooks(array('commonobject')); - $parameters=array(); + $parameters=array( + 'compatibleImportElementsList' =>& $compatibleImportElementsList, + ); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) @@ -5873,7 +5876,13 @@ class Form foreach($object->linkedObjects as $objecttype => $objects) { $tplpath = $element = $subelement = $objecttype; - + + // to display inport button on tpl + $showImportButton=false; + if(!empty($compatibleImportElementsList) && in_array($element,$compatibleImportElementsList)){ + $showImportButton=true; + } + if ($objecttype != 'supplier_proposal' && preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) { $element = $regs[1]; @@ -5949,6 +5958,13 @@ class Form } print '
'.$langs->trans("Type").'
trans("Proposal"); ?> getNomUrl(1); ?> ref_client; ?>
trans("CustomerOrder"); ?> getNomUrl(1); ?> ref_client; ?>
trans("CustomerInvoice"); ?> getNomUrl(1); ?> ref_client; ?>
 '; + print ''; + print ''; + print '
info_bits & 2) == 2 || ! empty($disableedit)) { ?> @@ -291,6 +291,9 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
trans("CustomerOrder"); ?>
trans("CustomerOrder"); ?> + getNomUrl(0,'',0,1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > + getNomUrl(1); ?> ref_client; ?> date,'day'); ?>
'; + + if(!empty($compatibleImportElementsList)) + { + $res=@include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php'); + } + + print ''; return $nbofdifferenttypes; diff --git a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php new file mode 100644 index 00000000000..ee014797dd7 --- /dev/null +++ b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php @@ -0,0 +1,99 @@ + + * + * 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 . + */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + +?> + + + + +cursor: pointer; + \ No newline at end of file From c5b96e43c7dcf9f34035b4939c040d28fe665c63 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 22 Feb 2018 16:55:41 +0100 Subject: [PATCH 05/57] add new action to import order in invoice --- htdocs/compta/facture/card.php | 84 +++++++++++++++++-- .../tpl/ajax/objectlinked_lineimport.tpl.php | 4 +- 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f0f2464904e..5de04fb3068 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2087,14 +2087,84 @@ if (empty($reshook)) header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); } - - // add lines from objectlinked - elseif ($action == 'import_lines_from_object' && $user->rights->facture->creer) - { - - - } + // add lines from objectlinked + elseif($action == 'import_lines_from_object' + && $user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) + { + $fromElement = GETPOST('fromelement'); + $fromElementid = intval(GETPOST('fromelementid')); + $importLines = GETPOST('line_checkbox'); + + if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class'); + $lineClassName = 'OrderLine'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach($importLines as $lineId) + { + $originLine = new $lineClassName($db); + if($originLine->fetch( $fromElementid ) > 0) + { + $originLine->fetch_optionals(intval($fromElementid)); + + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type='HT'; + $pu_ttc=0; + $type = $object->type; + $rang=$nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line=0; + $fk_fournprice=$originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; + + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); + + if($res > 0){ + $importCount++; + }else{ + $error++; + } + } + else{ + $error++; + } + } + + if($error) + { + setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors'); + } + } + } + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; diff --git a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php index ee014797dd7..b05d2650bb5 100644 --- a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php +++ b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php @@ -51,11 +51,11 @@ $(document).ready(function(){ $("#ajaxloaded_tablelinesform #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute - $("#ajaxloaded_tablelines .linecheckbox").prop("checked", true); // checked by default + $("#ajaxloaded_tablelines .linecheckbox,#ajaxloaded_tablelines .linecheckboxtoggle").prop("checked", true); // checked by default // reload checkbox toggle function $("#ajaxloaded_tablelines .linecheckboxtoggle").click(function(){ - var checkBoxes = $(".ajaxloadedtablelines .linecheckbox"); + var checkBoxes = $("#ajaxloaded_tablelines .linecheckbox"); checkBoxes.prop("checked", this.checked); }); From b88e7fdcf9b6ebcfe0e48481ea45c76193c36c6d Mon Sep 17 00:00:00 2001 From: John Date: Thu, 22 Feb 2018 17:21:12 +0100 Subject: [PATCH 06/57] move button to dialog footer --- .../tpl/ajax/objectlinked_lineimport.tpl.php | 31 ++++++++++++------- htdocs/langs/en_US/other.lang | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php index b05d2650bb5..ad32f1b9aa8 100644 --- a/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php +++ b/htdocs/core/tpl/ajax/objectlinked_lineimport.tpl.php @@ -41,29 +41,25 @@ $(document).ready(function(){ var windowWidth = $(window).width()*0.8; //retrieve current window width var windowHeight = $(window).height()*0.8; //retrieve current window height var htmlLines; + var formId = "ajaxloaded_tablelinesform_" + fromelement + "_" + fromelementid; $.get(page, function (data) { htmlLines = $(data).find('#tablelines') ; }); - var $dialog = $('
') + var $dialog = $('
') .load( page + " #tablelines", function() { - $("#ajaxloaded_tablelinesform #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute + $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute - $("#ajaxloaded_tablelines .linecheckbox,#ajaxloaded_tablelines .linecheckboxtoggle").prop("checked", true); // checked by default + $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default // reload checkbox toggle function - $("#ajaxloaded_tablelines .linecheckboxtoggle").click(function(){ - var checkBoxes = $("#ajaxloaded_tablelines .linecheckbox"); + $("#" + formId + " .linecheckboxtoggle").click(function(){ + var checkBoxes = $("#" + formId + " .linecheckbox"); checkBoxes.prop("checked", this.checked); }); - var inputs = '
' - $('#ajaxloaded_tablelinesform').append( inputs ); - $('#ajaxloaded_tablelinesform').append(''); - $('#ajaxloaded_tablelinesform').append(''); - $('#ajaxloaded_tablelinesform').append(''); }) .html(htmlLines) @@ -72,7 +68,19 @@ $(document).ready(function(){ modal: true, height: windowHeight, width: windowWidth, - title: "trans('LinesToImport'); ?>" + title: "trans('LinesToImport'); ?>", + buttons: { + "trans('Import'); ?>": function() { + $( this ).dialog( "close" ); + $("#" + formId).append(''); + $("#" + formId).append(''); + $("#" + formId).append(''); + $("#" + formId).submit(); + }, + "trans('Cancel'); ?>": function() { + $( this ).dialog( "close" ); + } + } }); $dialog.dialog('open'); @@ -95,5 +103,4 @@ $(document).ready(function(){ cursor:pointer; } -cursor: pointer; \ No newline at end of file diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index c4cb693716d..78ffa8db15b 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -245,3 +245,4 @@ WEBSITE_PAGEURL=URL of page WEBSITE_TITLE=Title WEBSITE_DESCRIPTION=Description WEBSITE_KEYWORDS=Keywords +LinesToImport=Lines to import From 768c09bc7459610d99c510219efe83faa82675e2 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 23 Feb 2018 09:23:50 +0100 Subject: [PATCH 07/57] Fix import order --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f68d6ea5cf8..94c8cf36b3b 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -292,7 +292,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; - + Date: Fri, 23 Feb 2018 12:12:36 +0100 Subject: [PATCH 08/57] Fix type lines import --- htdocs/compta/facture/card.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5de04fb3068..2b8e39016a4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2095,7 +2095,7 @@ if (empty($reshook)) && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { $fromElement = GETPOST('fromelement'); - $fromElementid = intval(GETPOST('fromelementid')); + $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) @@ -2110,11 +2110,11 @@ if (empty($reshook)) $error = 0; foreach($importLines as $lineId) { + $lineId = intval($lineId); $originLine = new $lineClassName($db); - if($originLine->fetch( $fromElementid ) > 0) + if(intval($fromElementid) > 0 && $originLine->fetch( $lineId ) > 0) { - $originLine->fetch_optionals(intval($fromElementid)); - + $originLine->fetch_optionals($lineId); $desc = $originLine->desc; $pu_ht = $originLine->subprice; $qty = $originLine->qty; @@ -2130,7 +2130,7 @@ if (empty($reshook)) $fk_remise_except = $originLine->fk_remise_except; $price_base_type='HT'; $pu_ttc=0; - $type = $object->type; + $type = $originLine->product_type; $rang=$nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; @@ -2146,7 +2146,6 @@ if (empty($reshook)) $pu_ht_devise = $originLine->multicurrency_subprice; $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); - if($res > 0){ $importCount++; }else{ From af7c1d8da17661a9a525521745d986f8f5c10e87 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 27 Mar 2018 18:39:18 +0200 Subject: [PATCH 09/57] fix error log --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8d08b828fd1..7fc131fbd82 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4787,6 +4787,7 @@ abstract class CommonObject if (! $resql) { $this->error=$this->db->lasterror(); + dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); $this->db->rollback(); return -1; } @@ -5804,7 +5805,7 @@ abstract class CommonObject { $labeltoshow = ''.$labeltoshow.''; } - + if (empty($onetrtd)) $out .= ''; else $out .= ''; From f9bc5bf931a29f3d958ca4a791deae17cb0da5e5 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 28 Mar 2018 15:22:47 +0200 Subject: [PATCH 10/57] NEW: can send mail from project card --- htdocs/projet/card.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c5cfb9b3756..18d291a0bb9 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -446,6 +446,13 @@ if (empty($reshook)) $comefromclone=true; } } + + // Actions to send emails + $trigger_name='PROJECT_SENTBYMAIL'; + $paramname='id'; + $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add + $trackid='proj'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -1075,6 +1082,9 @@ elseif ($object->id > 0) print ''; }*/ + // Send + print ''; + // Modify if ($object->statut != 2 && $user->rights->projet->creer) { @@ -1244,6 +1254,14 @@ elseif ($object->id > 0) print ''; } + // Presend form + $modelmail='project'; + $defaulttopic='SendProjectRef'; + $diroutput = $conf->projet->dir_output; + $trackid = 'proj'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + // Hook to add more things on page $parameters=array(); $reshook=$hookmanager->executeHooks('mainCardTabAddMore',$parameters,$object,$action); // Note that $action and $object may have been modified by hook From a89983ef5c9cef908b5c4085463983a28fed4a45 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 28 Mar 2018 15:41:10 +0200 Subject: [PATCH 11/57] Fix error on creating company with external module in 'custom' folder with a file to generate accountancy code --- htdocs/societe/class/societe.class.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9a43c5b3cfa..fd6f062b609 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2515,17 +2515,12 @@ class Societe extends CommonObject $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - if (file_exists(DOL_DOCUMENT_ROOT.'/'.$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php")) - { - $file=$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php"; - break; - } + $res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); + if ($res) break; } - if (! empty($file)) + if ($res) { - dol_include_once($file); - $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; $mod = new $classname; From f5324bb15eb24e559776b644d542855e7c7877d9 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 28 Mar 2018 16:07:02 +0200 Subject: [PATCH 12/57] FIX: only send mail from open project --- htdocs/projet/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 18d291a0bb9..4d0f8c1e385 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1083,7 +1083,10 @@ elseif ($object->id > 0) }*/ // Send - print ''; + if ($object->statut != 2) + { + print ''; + } // Modify if ($object->statut != 2 && $user->rights->projet->creer) From 3aff363998b9de60e579984ad2d8fae2621eaaa1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 28 Mar 2018 17:08:26 +0200 Subject: [PATCH 13/57] NEW: mail templates for projects --- htdocs/admin/mails_templates.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 79c4d4765be..a7a9fe4e9bb 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -168,6 +168,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); +if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); $elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['none']=$langs->trans('VisibleNowhere'); From 913135cb20b344c99c00f3bdf9e9c74879ee8edc Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 28 Mar 2018 17:10:12 +0200 Subject: [PATCH 14/57] FIX: project mail: templates + hide actions when in presend --- htdocs/projet/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 4d0f8c1e385..466bb8729c2 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1071,7 +1071,7 @@ elseif ($object->id > 0) // modified by hook if (empty($reshook)) { - if ($action != "edit" ) + if ($action != "edit" && $action != 'presend' ) { // Create event @@ -1225,6 +1225,10 @@ elseif ($object->id > 0) print ""; + if (GETPOST('modelselected')) { + $action = 'presend'; + } + if ($action != 'presend') { print '
'; From 3dd9d47089271e26a20f9cb0a69375e37df4e64f Mon Sep 17 00:00:00 2001 From: Sean Wang Date: Thu, 29 Mar 2018 14:49:06 +0800 Subject: [PATCH 15/57] Fix wrong approve time in expense report The approve time showed was 8 hours more than the real time. Checking database turned out that it had the wrong data(+8 hours). After checking every timezone related settings were correct, I found that it do twice idate() in setApproved(). Since we have idate() in $sql, we don't need the idate() at the line 1249. --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9f51b04a1f1..c2eacf4aa76 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1246,7 +1246,7 @@ class ExpenseReport extends CommonObject $error = 0; // date approval - $this->date_approve = $this->db->idate($now); + $this->date_approve = $now; if ($this->fk_statut != 5) { $this->db->begin(); From 78812ef82687fa5ee9a0529ffb560879f896c50f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 29 Mar 2018 09:35:47 +0200 Subject: [PATCH 16/57] better error management --- htdocs/core/class/commonobject.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7fc131fbd82..44218f12dfd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2307,11 +2307,13 @@ abstract class CommonObject if (! $this->table_element) { + $this->error='update_note was called on objet with property table_element not defined'; dol_syslog(get_class($this)."::update_note was called on objet with property table_element not defined", LOG_ERR); return -1; } if (! in_array($suffix,array('','_public','_private'))) { + $this->error='update_note Parameter suffix must be empty, \'_private\' or \'_public\''; dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR); return -2; } From 9ba902504ef208263d6f33e7257bfc98ddca78a3 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 29 Mar 2018 09:38:16 +0200 Subject: [PATCH 17/57] FIX: langs --- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/projects.lang | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be46a1e15c8..655e5d46884 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1729,6 +1729,7 @@ MailToSendContract=To send a contract MailToThirdparty=To send email from third party page MailToMember=To send email from member page MailToUser=To send email from user page +MailToProject= To send email from project page ByDefaultInList=Show by default on list view YouUseLastStableVersion=You use the latest stable version TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 4e1f755894b..5cc94c39309 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -226,3 +226,4 @@ AllowCommentOnProject=Allow user comments on projects DontHavePermissionForCloseProject=You do not have permissions to close the project %s DontHaveTheValidateStatus=The project %s must be open to be closed RecordsClosed=%s project(s) closed +SendProjectRef=About project %s From 0e986b8f97c7e6d0af571d56e1168bab712e3d25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:48:09 +0200 Subject: [PATCH 18/57] Update societe.class.php --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fd6f062b609..729995a81d0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2511,7 +2511,7 @@ class Societe extends CommonObject if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) { - $file=''; + $res=false; $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { From bad970ff05b204347eebb27434460567b1b5db72 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 29 Mar 2018 15:04:48 +0200 Subject: [PATCH 19/57] cleaning code --- htdocs/adherents/index.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index fd418756bd6..c9e3d1936c6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -48,9 +48,6 @@ $subscriptionstatic=new Subscription($db); print load_fiche_titre($langs->trans("MembersArea")); - -$var=True; - $Adherents=array(); $AdherentsAValider=array(); $MemberUpToDate=array(); @@ -255,7 +252,6 @@ print ''.$langs->trans("AmountTotal").''; print ''.$langs->trans("AmountAverage").''; print "\n"; -$var=true; krsort($Total); foreach ($Total as $key=>$value) { From fdfcb96176d17f38a34ca5076eebfb610c332abe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 15:31:21 +0200 Subject: [PATCH 20/57] Fix length of combobox --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 82c3461848b..2c63101b6fd 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2088,7 +2088,7 @@ else if (! empty($conf->projet->enabled)) { print ''; - $formproject->select_projects(-1, $line->fk_projet,'fk_projet', 0, 0, 1, 1); + $formproject->select_projects(-1, $line->fk_projet,'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } From c4ce543294990de298ee3107e104b6f8880737ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:30:31 +0200 Subject: [PATCH 21/57] Fix: backward compatibility --- htdocs/core/class/commonobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5bdc58cc61a..5d6ecfd1dfc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1428,19 +1428,22 @@ abstract class CommonObject if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; + $fk_user_field = 'fk_user_modif'; + $error=0; $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; + if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; $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); else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); - if (! empty($fuser) && is_object($fuser)) $sql.=", fk_user_modif = ".$fuser->id; - elseif (empty($fuser) || $fuser != 'none') $sql.=", fk_user_modif = ".$user->id; + if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; + elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG); From 38912d6918a597c3a4b223ca22a2444066425f9c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:36:51 +0200 Subject: [PATCH 22/57] Fix: more complete --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5d6ecfd1dfc..a438830af17 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1436,7 +1436,9 @@ abstract class CommonObject // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { + $fk_user_field = 'fk_user_mod'; + } $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; From 546f3f8b96c79c3aacde02ea752b3ca7510cbe9f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Mar 2018 07:19:42 +0200 Subject: [PATCH 23/57] Fix: avoid space in email address --- htdocs/adherents/card.php | 6 +++--- htdocs/user/card.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a223d4b35ba..6f215e4ca14 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos GarcĂ­a * Copyright (C) 2012-2016 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro @@ -301,7 +301,7 @@ if (empty($reshook)) $object->phone = trim(GETPOST("phone",'alpha')); $object->phone_perso = trim(GETPOST("phone_perso",'alpha')); $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha')); - $object->email = trim(GETPOST("member_email",'alpha')); + $object->email = trim(str_replace(' ','',GETPOST("member_email",'alpha'))); $object->skype = trim(GETPOST("skype",'alpha')); $object->birth = $birthdate; @@ -445,7 +445,7 @@ if (empty($reshook)) $phone_perso=GETPOST("phone_perso",'alpha'); $phone_mobile=GETPOST("phone_mobile",'alpha'); $skype=GETPOST("member_skype",'alpha'); - $email=GETPOST("member_email",'alpha'); + $email=str_replace(' ','',GETPOST("member_email",'alpha')); $login=GETPOST("member_login",'alpha'); $pass=GETPOST("password",'alpha'); $photo=GETPOST("photo",'alpha'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8eda5d47d97..f4437ddc2c2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,7 +3,7 @@ * 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) 2005-2018 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent @@ -50,7 +50,7 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categor $id = GETPOST('id','int'); $action = GETPOST('action','aZ09'); $mode = GETPOST('mode','alpha'); -$confirm = GETPOST('confirm','alpha'); +$confirm = GETPOST('confirm','alpha'); $subaction = GETPOST('subaction','alpha'); $group = GETPOST("group","int",3); $cancel = GETPOST('cancel','alpha'); @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); + $object->email = str_replace(' ','',GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); @@ -347,7 +347,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); + $object->email = str_replace(' ','',GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); From 8c610904acbdf8660a347fdcbe18f0f665a10c78 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Mar 2018 07:36:23 +0200 Subject: [PATCH 24/57] Fix: remove multi spaces --- htdocs/adherents/card.php | 4 ++-- htdocs/user/card.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6f215e4ca14..0eaa3efff8f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -301,7 +301,7 @@ if (empty($reshook)) $object->phone = trim(GETPOST("phone",'alpha')); $object->phone_perso = trim(GETPOST("phone_perso",'alpha')); $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha')); - $object->email = trim(str_replace(' ','',GETPOST("member_email",'alpha'))); + $object->email = preg_replace('/\s+/', '', GETPOST("member_email",'alpha')); $object->skype = trim(GETPOST("skype",'alpha')); $object->birth = $birthdate; @@ -445,7 +445,7 @@ if (empty($reshook)) $phone_perso=GETPOST("phone_perso",'alpha'); $phone_mobile=GETPOST("phone_mobile",'alpha'); $skype=GETPOST("member_skype",'alpha'); - $email=str_replace(' ','',GETPOST("member_email",'alpha')); + $email=preg_replace('/\s+/', '', GETPOST("member_email",'alpha')); $login=GETPOST("member_login",'alpha'); $pass=GETPOST("password",'alpha'); $photo=GETPOST("photo",'alpha'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f4437ddc2c2..9f713cfb920 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = str_replace(' ','',GETPOST("email", 'alpha')); + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); @@ -347,7 +347,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = str_replace(' ','',GETPOST("email", 'alpha')); + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); From 0366e645d516191699b30188fa0028e27e80c0a3 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 30 Mar 2018 16:54:38 +0200 Subject: [PATCH 25/57] NEW: generalize button to create object from list, for most of the lists --- htdocs/comm/propal/list.php | 8 +++++++- htdocs/commande/list.php | 8 +++++++- htdocs/compta/bank/various_payment/index.php | 4 +++- htdocs/compta/facture/list.php | 8 +++++++- htdocs/compta/paiement/cheque/list.php | 8 +++++++- htdocs/compta/prelevement/bons.php | 4 +++- htdocs/compta/salaries/index.php | 4 +++- htdocs/compta/sociales/index.php | 10 ++++++++-- htdocs/compta/tva/list.php | 7 ++++++- htdocs/contact/list.php | 8 +++++++- htdocs/contrat/list.php | 8 +++++++- htdocs/don/list.php | 4 +++- htdocs/expedition/list.php | 8 +++++++- htdocs/expensereport/list.php | 9 ++++++++- htdocs/fichinter/list.php | 8 +++++++- htdocs/fourn/commande/list.php | 9 +++++++-- htdocs/fourn/facture/list.php | 8 +++++++- htdocs/holiday/list.php | 5 ++++- htdocs/langs/en_US/compta.lang | 1 + htdocs/loan/index.php | 8 +++++++- htdocs/product/list.php | 12 +++++++++++- htdocs/product/stock/list.php | 8 +++++++- htdocs/projet/list.php | 8 +++++++- htdocs/projet/tasks/list.php | 8 +++++++- htdocs/societe/list.php | 19 ++++++++++++++++++- htdocs/supplier_proposal/list.php | 8 +++++++- 26 files changed, 173 insertions(+), 27 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index de7715bdcf4..ab5c50d7056 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -395,6 +395,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if ($user->rights->propal->creer) + { + $newcardbutton=''.$langs->trans('NewPropal').''; + } + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -406,7 +412,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendPropalRef"; $modelmail="proposal_send"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 784f44aad4c..1a29fe712ae 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -420,6 +420,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if ($contextpage == 'orderlist' && $user->rights->commande->creer) + { + $newcardbutton=''.$langs->trans('NewOrder').''; + } + // Lines of title fields print ''; if ($optioncss != '') print ''; @@ -432,7 +438,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendOrderRef"; $modelmail="order_send"; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 5e24463566c..aa47d714bd9 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -153,6 +153,8 @@ if ($result) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $newcardbutton=''.$langs->trans('MenuNewVariousPayment').''; + print ''; if ($optioncss != '') print ''; @@ -163,7 +165,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("VariousPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("VariousPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print '
'; print ''."\n"; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a3576a438aa..0d2adec10b2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -590,6 +590,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if($user->rights->facture->creer) + { + $newcardbutton=''.$langs->trans('NewBill').''; + } + $i = 0; print ''."\n"; @@ -603,7 +609,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); $topicmail="SendBillRef"; $modelmail="facture_send"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 76c52215281..532d2e4c9b8 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -131,6 +131,12 @@ if ($resql) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $newcardbutton=''; + if ($user->rights->banque->cheque) + { + $newcardbutton = ''.$langs->trans('NewCheckDeposit').''; + } + print ''; if ($optioncss != '') print ''; print ''; @@ -140,7 +146,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', '', '', $limit); + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, $newcardbutton, '', $limit); $moreforfilter=''; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 9d3da39e5c3..31dfbd5b610 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -101,6 +101,8 @@ if ($result) $selectedfields=''; + $newcardbutton = ''.$langs->trans('NewStandingOrder').''; + // Lines of title fields print ''; if ($optioncss != '') print ''; @@ -112,7 +114,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); $moreforfilter=''; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 4cad9117040..f9b9adf616c 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -150,6 +150,8 @@ if ($result) if ($typeid) $param.='&typeid='.$typeid; if ($optioncss != '') $param.='&optioncss='.$optioncss; + $newcardbutton=''.$langs->trans('NewSalaryPayment').''; + print ''; if ($optioncss != '') print ''; print ''; @@ -159,7 +161,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print '
'; print '
'."\n"; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 281a0afb377..3850ddfe5c5 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -146,6 +146,12 @@ if ($resql) if ($year) $param.='&year='.$year; if ($typeid) $param.='&typeid='.$typeid; + $newcardbutton=''; + if($user->rights->tax->charges->creer) + { + $newcardbutton=''.$langs->trans('MenuNewSocialContribution').''; + } + print ''; if ($optioncss != '') print ''; print ''; @@ -158,11 +164,11 @@ if ($resql) if ($year) { $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":""); - print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); } else { - print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit); } if (empty($mysoc->country_id) && empty($mysoc->country_code)) diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 8f2044369a1..056e16b4d5b 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -148,6 +148,11 @@ if ($result) if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($typeid) $param.='&typeid='.$typeid; + $newcardbutton=''; + if ($user->rights->tax->charges->creer) + { + $newcardbutton=''.$langs->trans('NewVATPayment').''; + } print ''; if ($optioncss != '') print ''; @@ -157,7 +162,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit); print '
'; print '
'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e2ad6031937..1351afeba4e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -411,6 +411,12 @@ if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs-> if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->societe->contact->creer) +{ + $newcardbutton=''.$langs->trans('NewContactAddress').''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -420,7 +426,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit); +print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="contact"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 55dfacdf2c5..4b634042df1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -370,6 +370,12 @@ if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']=$langs-> if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->contrat->creer) +{ + $newcardbutton=''.$langs->trans('NewContractSubscription').''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -379,7 +385,7 @@ print ''; print ''; print ''; -print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); +print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendContractRef"; $modelmail="contract"; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 46692c9025b..9c5aec63951 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -131,7 +131,9 @@ if ($resql) //if ($page > 0) $param.= '&page='.$page; if ($optioncss != '') $param.='&optioncss='.$optioncss; - print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords); + $newcardbutton=''.$langs->trans('NewDonation').''; + + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords, 'title_generic.png', 0, $newcardbutton); print ''."\n"; if ($optioncss != '') print ''; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index d8e9925c08f..3058f0364fe 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -265,6 +265,12 @@ if ($resql) //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); + $newcardbutton=''; + if ($user->rights->expedition->creer) + { + $newcardbutton=''.$langs->trans('NewSending').''; + } + $i = 0; print ''."\n"; if ($optioncss != '') print ''; @@ -275,7 +281,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, '', '', $limit); + print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit); if ($sall) { diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 097a912b6c1..7c8e8199b50 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -466,7 +466,14 @@ if ($resql) else { $title = $langs->trans("ListTripsAndExpenses"); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + + $newcardbutton=''; + if ($user->rights->expensereport->creer) + { + $newcardbutton=''.$langs->trans('NewTrip').''; + } + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); } $topicmail="SendExpenseReport"; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7fc7ca244de..9320a6c2df1 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -272,6 +272,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if ($user->rights->ficheinter->creer) + { + $newcardbutton=''.$langs->trans('NewIntervention').''; + } + // Lines of title fields print ''."\n"; if ($optioncss != '') print ''; @@ -283,7 +289,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="intervention"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 760c80737f4..95ec5e835d6 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -646,6 +646,12 @@ if ($resql) if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + $newcardbutton=''; + if($user->rights->fournisseur->commande->creer) + { + $newcardbutton=''.$langs->trans('NewOrder').''; + } // Lignes des champs de filtre print ''; @@ -658,8 +664,7 @@ if ($resql) print ''; print ''; print ''; - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendOrderRef"; $modelmail="order_supplier_send"; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index efe029d7adf..f46fe9c83eb 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -474,6 +474,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if ($user->rights->fournisseur->facture->creer) + { + $newcardbutton=''.$langs->trans('NewBill').''; + } + $i = 0; print ''."\n"; if ($optioncss != '') print ''; @@ -486,7 +492,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); $topicmail="SendBillRef"; $modelmail="supplier_invoice_send"; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 03f4108e02e..e00c182f949 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -377,7 +377,10 @@ else $nbtotalofrecords = count($holiday->holiday); //print $num; //print count($holiday->holiday); - print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, '', '', $limit); + + $newcardbutton=''.$langs->trans('MenuAddCP').''; + + print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="leaverequest"; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 83f2b96c839..25e2849b949 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -103,6 +103,7 @@ LT2PaymentsES=IRPF Payments VATPayment=Sales tax payment VATPayments=Sales tax payments VATRefund=Sales tax refund +NewVATPayment=New sales tax payment Refund=Refund SocialContributionsPayments=Social/fiscal taxes payments ShowVatPayment=Show VAT payment diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index d1436287db3..24ea1ab72f9 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -111,6 +111,12 @@ if ($resql) if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $newcardbutton=''; + if ($user->rights->loan->write) + { + $newcardbutton=''.$langs->trans('NewLoan').''; + } + print ''."\n"; if ($optioncss != '') print ''; print ''; @@ -120,7 +126,7 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); + print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); print '
'; print '
'."\n"; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e31a88e6f5c..a21648e140d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -412,6 +412,16 @@ else if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + $rightskey='produit'; + if($type == Product::TYPE_SERVICE) $rightskey='service'; + if($user->rights->{$rightskey}->creer) + { + $label='NewProduct'; + if($type == Product::TYPE_SERVICE) $label='NewService'; + $newcardbutton=''.$langs->trans($label).''; + } + print ''; if ($optioncss != '') print ''; print ''; @@ -423,7 +433,7 @@ else print ''; if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, '', '', $limit); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="product"; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 58ea5eadc21..34121148544 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -130,6 +130,12 @@ if ($result) if ($search_status) $param.="&search_status=".urlencode($search_status); if ($sall) $param.="&sall=".urlencode($sall); + $newcardbutton=''; + if ($user->rights->stock->creer) + { + $newcardbutton=''.$langs->trans('MenuNewWarehouse').''; + } + print ''; print ''; print ''; @@ -137,7 +143,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_generic.png', 0, '', '', $limit); + print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_generic.png', 0, $newcardbutton, '', $limit); if ($sall) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 22887c5e42d..688628e4884 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -441,6 +441,12 @@ if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=arr $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->projet->creer) +{ + $newcardbutton = ''.$langs->trans('NewProject').''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -452,7 +458,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, $newcardbutton, '', $limit); // Show description of content print '
'; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 6ad2e51425f..1bdea8e3591 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -391,6 +391,12 @@ if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs-> if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->projet->creer) +{ + $newcardbutton = ''.$langs->trans('NewTask').''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -402,7 +408,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_project', 0, $newcardbutton, '', $limit); // Show description of content print '
'; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index d56e5b1e22a..710d997580c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -573,6 +573,23 @@ if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs-> if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->societe->creer) +{ + $typefilter=''; + $label='MenuNewThirdParty'; + + if(! empty($type)) + { + $typefilter = '&type='.$type; + if($type == 'p') $label='MenuNewProspect'; + if($type == 'c') $label='MenuNewCustomer'; + if($type == 'f') $label='NewSupplier'; + } + + $newcardbutton = ''.$langs->trans($label).''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -581,7 +598,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); $langs->load("other"); $textprofid=array(); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 685e9531072..fd9ac1a593f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -387,6 +387,12 @@ if ($resql) if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''; + if($user->rights->supplier_proposal->creer) + { + $newcardbutton=''.$langs->trans('NewAskPrice').''; + } + // Lignes des champs de filtre print ''; if ($optioncss != '') print ''; @@ -397,7 +403,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendSupplierProposalRef"; $modelmail="supplier_proposal_send"; From 84bb4c6ad7b7321a9b1b1315cfc1f6365fc94b5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Mar 2018 19:51:53 +0200 Subject: [PATCH 26/57] FIX With x extrafields, request for multicompany label was done x times --- htdocs/core/class/extrafields.class.php | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 3d934baaf75..4c3fb340264 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -733,11 +733,26 @@ class ExtraFields // To avoid conflicts with external modules. TODO Remove this. if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; + // Set array of label of entity + // TODO Remove completely loading of label. This should be done by presentation. + $labelmulticompany=array(); + if (!empty($conf->multicompany->enabled)) + { + $sql_entity_name='SELECT rowid, label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid in (0,'.$conf->entity.')'; + $resql_entity_name=$this->db->query($sql_entity_name); + if ($resql_entity_name) + { + while ($obj = $this->db->fetch_object($resql_entity_name)) + { + $labelmulticompany[$obj->rowid]=$obj->label; + } + } + } + // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed"; - $sql .= ",entity"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -772,6 +787,7 @@ class ExtraFields $this->attribute_langfile[$tab->name]=$tab->langs; $this->attribute_list[$tab->name]=$tab->list; $this->attribute_entityid[$tab->name]=$tab->entity; + $this->attribute_entitylabel[$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); // New usage $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; @@ -789,26 +805,12 @@ class ExtraFields $this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; + $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); - if (!empty($conf->multicompany->enabled)) - { - $sql_entity_name='SELECT label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid='.$tab->entity; - $resql_entity_name=$this->db->query($sql_entity_name); - if ($resql_entity_name) - { - if ($this->db->num_rows($resql_entity_name)) - { - if ($obj = $this->db->fetch_object($resql_entity_name)) - { - $this->attribute_entitylabel[$tab->name]=$obj->label; - $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=$obj->label; - } - } - } - } + $this->attributes[$tab->elementtype]['loaded']=1; } } - if ($elementtype) $this->attributes[$elementtype]['loaded']=1; + if ($elementtype) $this->attributes[$elementtype]['loaded']=1; // If nothing found, we also save tag 'loaded' } else { From 20e80a58a851bf33eb1cc20b4b207cd269d2380b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Apr 2018 11:43:39 +0200 Subject: [PATCH 27/57] Fix: limit access to internal users --- htdocs/admin/mails_templates.php | 3 +-- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 77f969181f4..915faa03c95 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -55,8 +55,7 @@ $search_lang=GETPOST('search_lang','alpha'); $search_fk_user=GETPOST('search_fk_user','intcomma'); $search_topic=GETPOST('search_topic','alpha'); -$allowed=1; -if (! $allowed) accessforbidden(); +if ($user->socid) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index c2dde1c8493..f4e0918051c 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -311,7 +311,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3804__+MAX_llx_menu__, 'project', 'cat', 7__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=6', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3805__+MAX_llx_menu__, 'project', '', 3804__+MAX_llx_menu__, '/categories/card.php?action=create&type=6', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Tools -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', __HANDLER__, 'left', 3900__+MAX_llx_menu__, 'tools', 'email_templates', 8__+MAX_llx_menu__, '/admin/mails_templates.php?leftmenu=email_templates', 'EMailTemplates', 0, '', '', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($user->socid)', __HANDLER__, 'left', 3900__+MAX_llx_menu__, 'tools', 'email_templates', 8__+MAX_llx_menu__, '/admin/mails_templates.php?leftmenu=email_templates', 'EMailTemplates', 0, '', '', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3910__+MAX_llx_menu__, 'tools', 'mailing', 8__+MAX_llx_menu__, '/comm/mailing/index.php?leftmenu=mailing', 'EMailings', 0, 'mails', '$user->rights->mailing->lire', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3911__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/card.php?leftmenu=mailing&action=create', 'NewMailing', 1, 'mails', '$user->rights->mailing->creer', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3912__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/list.php?leftmenu=mailing', 'List', 1, 'mails', '$user->rights->mailing->lire', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fd3668aeaac..e930a0ab8b9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1418,8 +1418,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu */ if ($mainmenu == 'tools') { - $langs->load("mails"); - $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates'); + if (empty($user->socid)) // limit to internal users + { + $langs->load("mails"); + $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates'); + } if (! empty($conf->mailing->enabled)) { From c720345e6d1af190b44552d5ae7793864ad41c4a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Apr 2018 11:47:10 +0200 Subject: [PATCH 28/57] Fix: better test --- htdocs/admin/mails_templates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 915faa03c95..fb2729bb77b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -55,7 +55,7 @@ $search_lang=GETPOST('search_lang','alpha'); $search_fk_user=GETPOST('search_fk_user','intcomma'); $search_topic=GETPOST('search_topic','alpha'); -if ($user->socid) accessforbidden(); +if (! empty($user->socid)) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; From e09c85cfdb740d7c6fe1613a7a9f0ac51e127175 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Apr 2018 13:45:39 +0200 Subject: [PATCH 29/57] Fix: possibility to change entity for new thirdparty --- htdocs/societe/card.php | 1 + htdocs/societe/class/societe.class.php | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 920dee364c7..663a1b80586 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1643,6 +1643,7 @@ else print ''; print ''; print ''; + print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bb9748b1af3..3147a53cfcf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -772,9 +772,10 @@ class Societe extends CommonObject // Clean parameters $this->id = $id; + $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); $this->name = $this->name?trim($this->name):trim($this->nom); $this->nom = $this->name; // For backward compatibility - $this->name_alias = trim($this->name_alias); + $this->name_alias = trim($this->name_alias); $this->ref_ext = trim($this->ref_ext); $this->address = $this->address?trim($this->address):trim($this->address); $this->zip = $this->zip?trim($this->zip):trim($this->zip); @@ -789,9 +790,9 @@ class Societe extends CommonObject $this->fax = preg_replace("/\./","",$this->fax); $this->email = trim($this->email); $this->skype = trim($this->skype); - $this->url = $this->url?clean_url($this->url,0):''; - $this->note_private = trim($this->note_private); - $this->note_public = trim($this->note_public); + $this->url = $this->url?clean_url($this->url,0):''; + $this->note_private = trim($this->note_private); + $this->note_public = trim($this->note_public); $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); @@ -896,7 +897,8 @@ class Societe extends CommonObject dol_syslog(get_class($this)."::update verify ok or not done"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required + $sql .= "entity = " . $this->entity; + $sql .= ",nom = '" . $this->db->escape($this->name) ."'"; // Required $sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'"; $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); $sql .= ",address = '" . $this->db->escape($this->address) ."'"; From 9f7fcdc8bf59eaf041e7aa248002f8a5df9b9fbd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Apr 2018 09:44:45 +0200 Subject: [PATCH 30/57] Fix: multiple avoid Warning and errors --- htdocs/core/lib/functions.lib.php | 39 ++++++++++--------- htdocs/expedition/list.php | 7 ++-- .../install/mysql/migration/7.0.0-8.0.0.sql | 6 +++ htdocs/product/inventory/list.php | 13 ++++--- htdocs/product/list.php | 8 +++- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/massstockmove.php | 1 + htdocs/product/stock/mouvement.php | 2 +- 8 files changed, 48 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dc9d179bb59..9138f886991 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6466,27 +6466,30 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti // Clean parameters $order=strtolower($order); - $sizearray=count($array); - if (is_array($array) && $sizearray>0) + if (is_array($array)) { - $temp = array(); - foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; - - if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); - else + $sizearray=count($array); + if ($sizearray>0) { - ($case_sensitive) ? natsort($temp) : natcasesort($temp); - if($order!='asc') $temp=array_reverse($temp,TRUE); + $temp = array(); + foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; + + if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); + else + { + ($case_sensitive) ? natsort($temp) : natcasesort($temp); + if($order!='asc') $temp=array_reverse($temp,TRUE); + } + + $sorted = array(); + + foreach(array_keys($temp) as $key) + { + (is_numeric($key) && empty($keepindex)) ? $sorted[]=$array[$key] : $sorted[$key]=$array[$key]; + } + + return $sorted; } - - $sorted = array(); - - foreach(array_keys($temp) as $key) - { - (is_numeric($key) && empty($keepindex)) ? $sorted[]=$array[$key] : $sorted[$key]=$array[$key]; - } - - return $sorted; } return $array; } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index dd6fa84ec4b..f8e082d3b66 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -148,12 +148,13 @@ if (empty($reshook)) { // Mass actions. Controls on number of lines checked $maxformassaction=1000; - if (! empty($massaction) && count($toselect) < 1) + $numtoselect = (is_array($toselect)?count($toselect):0); + if (! empty($massaction) && $numtoselect < 1) { $error++; setEventMessages($langs->trans("NoLineChecked"), null, "warnings"); } - if (! $error && count($toselect) > $maxformassaction) + if (! $error && $numtoselect > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $error++; @@ -541,7 +542,7 @@ if ($resql) { $shipment->fetchObjectLinked($shipment->id,$shipment->element); $receiving=''; - if (count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']); + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']); if (! empty($arrayfields['l.ref']['checked'])) { diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index d9513242969..c8681e7cac3 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -41,6 +41,12 @@ DROP TABLE llx_c_accountingaccount; update llx_propal set fk_statut = 1 where fk_statut = -1; +ALTER TABLE llx_inventory ADD COLUMN fk_user_author integer; +ALTER TABLE llx_inventory CHANGE COLUMN fk_user_author fk_user_creat integer; +ALTER TABLE llx_inventory ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_inventory ADD COLUMN fk_user_valid integer; +ALTER TABLE llx_inventory ADD COLUMN import_key varchar(14); + -- For 8.0 diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index a24ca1c8808..95670698380 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -185,7 +185,9 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->element]['label'])) { + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -409,12 +411,13 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -foreach ($extrafields->attributes[$object->element]['computed'] as $key => $val) -{ - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (! empty($extrafields->attributes[$object->element]['computed'])) { + foreach ($extrafields->attributes[$object->element]['computed'] as $key => $val) + { + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } } - // Loop on record // -------------------------------------------------------------------- $i=0; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c6a7835158d..f030ea3d53e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -278,7 +278,9 @@ else $sql .= ', pac.rowid prod_comb_id'; } // Add fields from extrafields - foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + if (! empty($extrafields->attributes[$object->element]['label'])) { + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['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 @@ -335,7 +337,9 @@ else $sql .= ', pac.rowid'; } // Add fields from extrafields - foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + if (! empty($extrafields->attributes[$object->element]['label'])) { + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + } // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldSelect',$parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 58ea5eadc21..20900e31826 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -43,7 +43,7 @@ $sortorder = GETPOST("sortorder"); if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; $page = GETPOST("page"); -if ($page < 0) $page = 0; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $year = strftime("%Y",time()); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index caea260118f..ebe1fbe5375 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -55,6 +55,7 @@ $idline = GETPOST('idline'); $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 if (!$sortfield) { $sortfield = 'p.ref'; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 0bed4022eb3..6093a252cb6 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -72,7 +72,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -if ($page < 0) $page = 0; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; From ef45983f731afe95eb22ec08d664b622083c9ae0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Apr 2018 10:25:15 +0200 Subject: [PATCH 31/57] Fix: just add fields if not exists --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index c8681e7cac3..c126976a673 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -41,8 +41,7 @@ DROP TABLE llx_c_accountingaccount; update llx_propal set fk_statut = 1 where fk_statut = -1; -ALTER TABLE llx_inventory ADD COLUMN fk_user_author integer; -ALTER TABLE llx_inventory CHANGE COLUMN fk_user_author fk_user_creat integer; +ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer; ALTER TABLE llx_inventory ADD COLUMN fk_user_modif integer; ALTER TABLE llx_inventory ADD COLUMN fk_user_valid integer; ALTER TABLE llx_inventory ADD COLUMN import_key varchar(14); From b39f617863991e03bf9e32b7c35a6d6a406e7292 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Mon, 2 Apr 2018 15:29:58 +0100 Subject: [PATCH 32/57] Added missing parentheses --- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/document.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 46ca99d3727..c39dbaafc97 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -69,7 +69,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','useragenda','globalcard'); +$hookmanager->initHooks(array('usercard','useragenda','globalcard')); /* * Actions diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3d63c308729..5709cb6df05 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('usercard','globalcard'); +$hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index d77b30a4721..b8fc923acae 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','userdoc','globalcard'); +$hookmanager->initHooks(array('usercard','userdoc','globalcard')); /* From 09f8a21773941d81fb1dbe9d477ca24762b62811 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Mon, 2 Apr 2018 15:30:19 +0100 Subject: [PATCH 33/57] Argument should be array --- htdocs/user/group/perms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 27170062198..fd33d4d5427 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -60,7 +60,7 @@ $object->fetch($id); $entity=$conf->entity; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks('groupperms','globalcard'); +$hookmanager->initHooks(array('groupperms','globalcard')); /** From fba40575f789e8cefbbafd15d0c557b03ed613cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Apr 2018 16:39:48 +0200 Subject: [PATCH 34/57] Remove dead code --- htdocs/admin/payment.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index fdf0e9f9bee..339b4fef566 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -257,17 +257,6 @@ print $form->selectyesno("FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$con print '
\n"; -// Add js auto fill amount on paiement form -/* always on now -$var=! $var; -print '\n"; -*/ - print '
'; print "
'; -print $langs->trans("JSOnPaimentBill"); -print ''; -print $form->selectyesno("INVOICE_AUTO_FILLJS",$conf->global->INVOICE_AUTO_FILLJS,1); -print ''; -print "
'; print '
'; From 8595d7621bd7d5a3801b8fa03522f6e5bc723f96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Apr 2018 23:30:23 +0200 Subject: [PATCH 35/57] Fix POST mut use method POST no GET --- htdocs/admin/modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 00c8d14219e..68764be5fc5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -79,9 +79,9 @@ $familyinfo=array( $param=''; if ($search_keyword) $param.='&search_keyword='.urlencode($search_keyword); -if ($search_status > -1) $param.='&search_status='.urlencode($search_status); -if ($search_nature > -1) $param.='&search_nature='.urlencode($search_nature); -if ($search_version > -1) $param.='&search_version='.urlencode($search_version); +if ($search_status && $search_status != '-1') $param.='&search_status='.urlencode($search_status); +if ($search_nature && $search_nature != '-1') $param.='&search_nature='.urlencode($search_nature); +if ($search_version && $search_version != '-1') $param.='&search_version='.urlencode($search_version); $dirins=DOL_DOCUMENT_ROOT.'/custom'; $urldolibarrmodules='https://www.dolistore.com/'; @@ -466,7 +466,7 @@ if ($mode == 'common') { dol_set_focus('#search_keyword'); - print ''; + print ''; if ($optioncss != '') print ''; print ''; print ''; From 1afe567a01ddd76696039e966ec7b5ac07c6d106 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 3 Apr 2018 12:07:19 +0200 Subject: [PATCH 36/57] Fix array parse error --- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/document.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 46ca99d3727..c39dbaafc97 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -69,7 +69,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','useragenda','globalcard'); +$hookmanager->initHooks(array('usercard','useragenda','globalcard')); /* * Actions diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3d63c308729..5709cb6df05 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('usercard','globalcard'); +$hookmanager->initHooks(array('usercard','globalcard')); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index d77b30a4721..b8fc923acae 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','userdoc','globalcard'); +$hookmanager->initHooks(array('usercard','userdoc','globalcard')); /* From e8a700caab35bd1ab9e9cdc7f2987843dc976b8d Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Tue, 3 Apr 2018 12:13:40 +0100 Subject: [PATCH 37/57] Fixed issue with img_picto no showing icon in agenda assigned users --- htdocs/core/lib/functions.lib.php | 151 ++++++++++++++++++++---------- 1 file changed, 104 insertions(+), 47 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dc9d179bb59..1a6ad456496 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3071,68 +3071,124 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ { global $conf, $langs; + // We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto + $url = DOL_URL_ROOT; + $theme = $conf->theme; + $path = 'theme/'.$theme; + // Define fullpathpicto to use into src - if ($pictoisfullpath) - { + if ($pictoisfullpath) { // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; - $fullpathpicto = $picto; + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) { + $picto .= '.png'; + } + $fullpathpicto = $url.'/'.$path.'/img/'.$picto; } - else - { + else { $pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) - if (in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) - { - $fakey = $pictowithoutext; $facolor=''; $fasize=''; - if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } - elseif ($pictowithoutext == 'switch_on') { $fakey = 'fa-toggle-on'; $facolor='#227722'; $fasize='2em'; } - elseif ($pictowithoutext == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; } - elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } - elseif ($pictowithoutext == 'bank') { $fakey = 'fa-bank'; $facolor='#444'; } - elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; } - elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; } - elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize='1.2em'; $facolor='#444'; } - elseif ($pictowithoutext == 'resize') { $fakey = 'fa-crop'; $facolor='#444'; } - elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor='#555'; } - elseif ($pictowithoutext == 'unlink') { $fakey = 'fa-chain-broken'; $facolor='#555'; } - elseif ($pictowithoutext == 'playdisabled') { $fakey = 'fa-play'; $facolor='#ccc'; } - else { $fakey = 'fa-'.$pictowithoutext; $facolor='#444'; } + if (in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { + $fakey = $pictowithoutext; + $facolor = ''; + $fasize = ''; + if ($pictowithoutext == 'switch_off') { + $fakey = 'fa-toggle-off'; + $facolor = '#999'; + $fasize = '2em'; + } + elseif ($pictowithoutext == 'switch_on') { + $fakey = 'fa-toggle-on'; + $facolor = '#227722'; + $fasize = '2em'; + } + elseif ($pictowithoutext == 'off') { + $fakey = 'fa-square-o'; + $fasize = '1.3em'; + } + elseif ($pictowithoutext == 'on') { + $fakey = 'fa-check-square-o'; + $fasize = '1.3em'; + } + elseif ($pictowithoutext == 'bank') { + $fakey = 'fa-bank'; + $facolor = '#444'; + } + elseif ($pictowithoutext == 'delete') { + $fakey = 'fa-trash'; + $facolor = '#444'; + } + elseif ($pictowithoutext == 'edit') { + $fakey = 'fa-pencil'; + $facolor = '#444'; + } + elseif ($pictowithoutext == 'printer') { + $fakey = 'fa-print'; + $fasize = '1.2em'; + $facolor = '#444'; + } + elseif ($pictowithoutext == 'resize') { + $fakey = 'fa-crop'; + $facolor = '#444'; + } + elseif ($pictowithoutext == 'uparrow') { + $fakey = 'fa-mail-forward'; + $facolor = '#555'; + } + elseif ($pictowithoutext == 'unlink') { + $fakey = 'fa-chain-broken'; + $facolor = '#555'; + } + elseif ($pictowithoutext == 'playdisabled') { + $fakey = 'fa-play'; + $facolor = '#ccc'; + } + else { + $fakey = 'fa-'.$pictowithoutext; + $facolor = '#444'; + } - if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.=($morecss?' ':'').$reg[1]; } - $enabledisablehtml =''; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$titlealt; - $enabledisablehtml.=''; + if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { + $morecss.= ($morecss?' ':'').$reg[1]; + } + $enabledisablehtml = ''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $enabledisablehtml.= $titlealt; + } + $enabledisablehtml.= ''; return $enabledisablehtml; } - // We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto - $url = DOL_URL_ROOT; - $theme = $conf->theme; - - $path = 'theme/'.$theme; - if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module - else if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme - else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module + } + else if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme + } + else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + } // If we ask an image into $url/$mymodule/img (instead of default path) - if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path = $regs[2]; // $path is $mymodule } // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) { + $picto .= '.png'; + } // If alt path are defined, define url where img file is, according to physical path - foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...) - { - if ($type == 'main') continue; - if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded - { - $url=DOL_URL_ROOT.$conf->file->dol_url_root[$type]; + // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...) + foreach ($conf->file->dol_document_root as $type => $dirroot) { + if ($type == 'main') { + continue; + } + // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded + if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) { + $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type]; break; } } @@ -3141,15 +3197,16 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fullpathpicto = $url.'/'.$path.'/img/'.$picto; } - if ($srconly) return $fullpathpicto; - else - { + if ($srconly) { + return $fullpathpicto; + } + else { // tag title is used for tooltip on , tag alt can be used with very simple text on image for bind people //$tmparray=array(0=>$titlealt); //if (empty($notitle) && preg_match('/:[^\s0-9]/',$titlealt)) $tmparray=explode(':',$titlealt); // We explode if we have TextA:TextB. Not if we have TextA: TextB //$title=$tmparray[0]; //$alt=empty($tmparray[1])?'':$tmparray[1]; - $title=$titlealt; + $title = $titlealt; return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } } From 4f9a8d5b0a43ee3fc99ff3fb0be960e1e3908e9a Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Tue, 3 Apr 2018 12:23:26 +0100 Subject: [PATCH 38/57] img_picto must return fullpath to picto.png --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aa27be2d727..8f9be1356d4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1703,7 +1703,7 @@ class Form $userstatic->fetch($value['id']); $out.= $userstatic->getNomUrl(-1); if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; } - if ($nbassignetouser > 1 && $action != 'view') $out.=' '; + if ($nbassignetouser > 1 && $action != 'view') $out.=' '; // Show my availability if ($showproperties) { From 39eab6d88d83f46278802f10a2064d03ca327003 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 3 Apr 2018 14:38:20 +0200 Subject: [PATCH 39/57] Fix service creation, right is tested regarding the product type --- htdocs/product/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f65898bda68..9db9c156bf8 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -94,6 +94,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } +} else { + $object->type = $type; } $modulepart='product'; From 0c3b92f09ace2a565877b89a753b6fc8c89f42c2 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 3 Apr 2018 14:53:57 +0200 Subject: [PATCH 40/57] Better fix --- htdocs/product/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9db9c156bf8..7ddf36f208b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -77,6 +77,7 @@ $duration_unit = GETPOST('duration_unit'); if (! empty($user->societe_id)) $socid=$user->societe_id; $object = new Product($db); +$object->type = $type; $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -94,8 +95,6 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } -} else { - $object->type = $type; } $modulepart='product'; From c2d3e2a701b7347f2f9e489b7ca431bf5464ae16 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 3 Apr 2018 15:28:12 +0200 Subject: [PATCH 41/57] NEW: generalize button to create object from list, for the remaining lists --- htdocs/adherents/list.php | 8 +++++++- htdocs/adherents/subscription/list.php | 4 +++- htdocs/adherents/type.php | 8 +++++++- htdocs/bookmarks/list.php | 14 +++----------- htdocs/comm/mailing/list.php | 5 ++++- htdocs/opensurvey/list.php | 8 +++++++- htdocs/resource/list.php | 8 +++++++- 7 files changed, 38 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b048d6ed551..f71a22ff5b8 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -344,6 +344,12 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs- if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$newcardbutton=''; +if ($user->rights->adherent->creer) +{ + $newcardbutton=''.$langs->trans('NewMember').''; +} + print ''; if ($optioncss != '') print ''; print ''; @@ -354,7 +360,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); +print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="member"; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1ed0b9a5c50..2a6c4fe2d71 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -181,6 +181,8 @@ if ($result) if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $newcardbutton=''.$langs->trans('NewSubscription').''; + print ''; if ($optioncss != '') print ''; print ''; @@ -191,7 +193,7 @@ if ($result) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); $topicmail="Information"; $modelmail="subscription"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 48df382181d..929dc706042 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -228,6 +228,12 @@ if (! $rowid && $action != 'create' && $action != 'edit') $param = ''; + $newcardbutton=''; + if ($user->rights->adherent->configurer) + { + $newcardbutton=''.$langs->trans('NewMemberType').''; + } + print ''; if ($optioncss != '') print ''; print ''; @@ -237,7 +243,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; - print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); $moreforfilter = ''; diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 2aa3024920f..b1262b7a554 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -81,7 +81,9 @@ $userstatic=new User($db); llxHeader('', $langs->trans("ListOfBookmarks")); -print load_fiche_titre($langs->trans("ListOfBookmarks")); +$newcardbutton=''.$langs->trans('NewBookmark').''; + +print_barre_liste($langs->trans("ListOfBookmarks"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', -1, '', 'title_generic.png', 0, $newcardbutton); $sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,"; $sql.= " u.login, u.lastname, u.firstname"; @@ -204,16 +206,6 @@ else } - -print "
\n"; - -if ($user->rights->bookmark->creer) -{ - print ''.$langs->trans("NewBookmark").''; -} - -print '
'; - llxFooter(); $db->close(); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index f2491b09336..4b01ddfaba8 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -103,7 +103,10 @@ if ($result) $title=$langs->trans("ListOfEMailings"); if ($filteremail) $title.=' ('.$langs->trans("SentTo",$filteremail).')'; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,"",$num); + + $newcardbutton=''.$langs->trans('NewMailing').''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num, '', 'title_generic.png', 0, $newcardbutton); $i = 0; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index a2bf0b106ed..051028c8f19 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -79,7 +79,13 @@ llxHeader('', $langs->trans("OpenSurveyArea")); $param=''; $fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; -print load_fiche_titre($langs->trans("OpenSurveyArea")); +$newcardbutton=''; +if ($user->rights->opensurvey->read) +{ + $newcardbutton=''.$langs->trans('NewSurvey').''; +} + +print_barre_liste($langs->trans("OpenSurveyArea"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', -1, '', 'title_generic.png', 0, $newcardbutton); // List of surveys into database diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 190659628f2..5697dee3b7b 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -196,7 +196,13 @@ if($ret == -1) { dol_print_error($db,$object->error); exit; } else { - print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret+1, $nbtotalofrecords,'title_generic.png', 0, '', '', $limit); + $newcardbutton=''; + if ($user->rights->resource->write) + { + $newcardbutton=''.$langs->trans('MenuResourceAdd').''; + } + + print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret+1, $nbtotalofrecords,'title_generic.png', 0, $newcardbutton, '', $limit); } $moreforfilter = ''; From fd6c1f129c7ff2f861fbed098693a524befad45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 4 Apr 2018 15:58:24 +0200 Subject: [PATCH 42/57] Update CMailFile.class.php --- htdocs/core/class/CMailFile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 47af9ba4ae0..af3dce343f4 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -776,7 +776,8 @@ class CMailFile dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res=false; } else { - $this->error = sprintf ("Sent %d messages\n", $result); + $this->error = $langs->trans("SentXXXmessages", $result); + $this->errors[] = $langs->trans("SentXXXmessages", $result); } } else From 90957b3a72f851678084a421608631fece7ddaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 4 Apr 2018 16:00:33 +0200 Subject: [PATCH 43/57] Update mails.lang --- htdocs/langs/en_US/mails.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 3c512ca7286..e38b038cfee 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -78,6 +78,7 @@ ResultOfMailSending=Result of mass EMail sending NbSelected=Nb selected NbIgnored=Nb ignored NbSent=Nb sent +SentXXXmessages=%s message(s) sent. ConfirmUnvalidateEmailing=Are you sure you want to change email %s to draft status? MailingModuleDescContactsWithThirdpartyFilter=Contact with customer filters MailingModuleDescContactsByCompanyCategory=Contacts by third party category From e5664f9630d4aa9550a8f6c58837e139dcef7553 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 4 Apr 2018 20:32:36 +0200 Subject: [PATCH 44/57] fix notrigger ignored on BILL_CREATE --- htdocs/compta/facture/class/facture.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3728908f01d..37dea88dc79 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -694,10 +694,16 @@ class Facture extends CommonInvoice } else if ($reshook < 0) $error++;*/ - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } + } if (! $error) { From 88b3e08b22f5349b26fcc808b8e15254d51f4e51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 11:34:26 +0200 Subject: [PATCH 45/57] FIX filter/sorting on extrafield on contact list from contact tab --- htdocs/core/lib/company.lib.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index c7b75521a59..663821db0c2 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -772,6 +772,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $form = new Form($db); + $optioncss = GETPOST('optioncss', 'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST('page','int'); @@ -823,7 +824,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') { if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } - + $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers @@ -870,9 +871,12 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".''."\n"; - $param="socid=".$object->id; - if ($search_status != '') $param.='&search_status='.$search_status; - if ($search_name != '') $param.='&search_name='.urlencode($search_name); + $param="socid=".urlencode($object->id); + if ($search_status != '') $param.='&search_status='.urlencode($search_status); + if ($search_name != '') $param.='&search_name='.urlencode($search_name); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.skype, t.statut, t.photo,"; $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; @@ -880,7 +884,9 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); - if ($search_name) $sql .= " AND (t.lastname LIKE '%".$db->escape($search_name)."%' OR t.firstname LIKE '%".$db->escape($search_name)."%')"; + if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); + // Add where from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; if ($sortfield == "t.name") $sql.=" ORDER BY t.lastname $sortorder, t.firstname $sortorder"; else $sql.= " ORDER BY $sortfield $sortorder"; @@ -1044,7 +1050,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') // Edit if ($user->rights->societe->contact->creer) { - print ''; + print ''; print img_edit(); print ''; } From 0de65b78226d66c9af898d95f5e2c4a43ca981ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 12:28:52 +0200 Subject: [PATCH 46/57] FIX Support or multicompany for sheduled jobs FIX Use priority to define order of sheduled jobs --- htdocs/core/modules/DolibarrModules.class.php | 5 ++- htdocs/core/modules/modCron.class.php | 6 +-- htdocs/cron/card.php | 16 ++++++++ htdocs/cron/class/cronjob.class.php | 39 +++++++++++++------ htdocs/cron/list.php | 2 +- scripts/cron/cron_run_jobs.php | 10 ++--- 6 files changed, 55 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 517cc9894f9..7fb9f76119b 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1313,6 +1313,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { foreach ($this->cronjobs as $key => $value) { + $entity = isset($this->cronjobs[$key]['entity'])?$this->cronjobs[$key]['entity']:$conf->entity; $label = isset($this->cronjobs[$key]['label'])?$this->cronjobs[$key]['label']:''; $jobtype = isset($this->cronjobs[$key]['jobtype'])?$this->cronjobs[$key]['jobtype']:''; $class = isset($this->cronjobs[$key]['class'])?$this->cronjobs[$key]['class']:''; @@ -1334,7 +1335,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'"; if ($command) $sql.= " AND command = '".$this->db->escape($command)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; // Must be exact entity $now=dol_now(); @@ -1371,7 +1372,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if(is_int($unitfrequency)){ $sql.= "'".$this->db->escape($unitfrequency)."', "; } if(is_int($priority)) {$sql.= "'".$this->db->escape($priority)."', ";} if(is_int($status)){ $sql.= "'".$this->db->escape($status)."', "; } - $sql.= $conf->entity.","; + $sql.= $entity.","; $sql.= "'".$this->db->escape($test)."'"; $sql.= ")"; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index b148149910f..2ce3cf9d9f6 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -95,9 +95,9 @@ class modCron extends DolibarrModules // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), - 1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) + 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), + 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), + // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) ); // Permissions diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 8c97bc4e2c8..707b75b95fe 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -614,6 +614,22 @@ else print $langs->trans($object->note); print ""; + if (! empty($conf->multicompany->enabled)) + { + print '"; + } + print '
'; + print $langs->trans('Entity').""; + if (! $object->entity) + { + print $langs->trans("AllEntities"); + } + else + { + $mc->getInfo($obj->entity); + print $mc->label; + } + print "
'; print '
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index be5ffbe965d..aeb0d7229b4 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -34,6 +34,7 @@ class Cronjob extends CommonObject public $table_element='cronjob'; //!< Name of table without prefix where object is stored public $picto = 'cron'; + public $entity; public $jobtype; public $tms=''; public $datec=''; @@ -158,7 +159,7 @@ class Cronjob extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob("; - + $sql.= "entity,"; $sql.= "datec,"; $sql.= "jobtype,"; $sql.= "label,"; @@ -188,6 +189,7 @@ class Cronjob extends CommonObject $sql.= "libname,"; $sql.= "test"; $sql.= ") VALUES ("; + $sql.= " ".(! isset($this->entity)?$conf->entity:$this->db->escape($this->entity)).","; $sql.= " '".$this->db->idate($now)."',"; $sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").","; $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; @@ -270,8 +272,8 @@ class Cronjob extends CommonObject function fetch($id) { $sql = "SELECT"; - $sql.= " t.rowid,"; - + $sql.= " t.rowid,"; + $sql.= " t.entity,"; $sql.= " t.tms,"; $sql.= " t.datec,"; $sql.= " t.jobtype,"; @@ -315,7 +317,7 @@ class Cronjob extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - + $this->entity = $obj->entity; $this->tms = $this->db->jdate($obj->tms); $this->datec = $this->db->jdate($obj->datec); $this->label = $obj->label; @@ -422,7 +424,7 @@ class Cronjob extends CommonObject } } - $sql.= " ORDER BY $sortfield $sortorder "; + $sql.= $this->db->order($sortfield,$sortorder); if (!empty($limit) && !empty($offset)) { $sql.= $this->db->plimit($limit + 1,$offset); } @@ -450,7 +452,6 @@ class Cronjob extends CommonObject $line->id = $obj->rowid; $line->ref = $obj->rowid; - $line->entity = $obj->entity; $line->tms = $this->db->jdate($obj->tms); $line->datec = $this->db->jdate($obj->datec); @@ -580,7 +581,7 @@ class Cronjob extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET"; - + $sql.= " entity=".(isset($this->entity)?$this->db->escape($this->entity):$conf->entity).","; $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " jobtype=".(isset($this->jobtype)?"'".$this->db->escape($this->jobtype)."'":"null").","; $sql.= " command=".(isset($this->command)?"'".$this->db->escape($this->command)."'":"null").","; @@ -778,7 +779,7 @@ class Cronjob extends CommonObject { $this->id=0; $this->ref=0; - + $this->entity=0; $this->tms=''; $this->datec=''; $this->label=''; @@ -935,6 +936,16 @@ class Cronjob extends CommonObject return -1; } + // Force the environment of running to the environment declared for job, so jobs launched from command line will run into correct environment + // When job is ran from GUI, the environment should already be same, except if job has entity 0 (visible into all environments) + if ($conf->entity != $this->entity && $this->entity > 0) + { + dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); + } + $savcurrententity = $conf->entity; + $conf->entity = $this->entity; + dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $user=new User($this->db); $result=$user->fetch('',$userlogin); @@ -942,6 +953,7 @@ class Cronjob extends CommonObject { $this->error="User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } else @@ -950,6 +962,7 @@ class Cronjob extends CommonObject { $this->error=" User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } } @@ -981,6 +994,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result<0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } @@ -1079,6 +1093,7 @@ class Cronjob extends CommonObject { $this->error = $langs->trans('CronCannotLoadLib') . ': ' . $libpath; dol_syslog(get_class($this) . "::run_jobs " . $this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } // Load langs @@ -1086,6 +1101,7 @@ class Cronjob extends CommonObject if ($result<0) { dol_syslog(get_class($this) . "::run_jobs Cannot load module langs" . $langs->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } dol_syslog(get_class($this) . "::run_jobs " . $this->libname . "::" . $this->methodename."(" . $this->params . ");", LOG_DEBUG); @@ -1148,13 +1164,12 @@ class Cronjob extends CommonObject if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } - else - { - return $error?-1:1; - } + $conf->entity = $savcurrententity; + return $error?-1:1; } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index b4df819b976..7bca10ff883 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -245,7 +245,7 @@ $sql.= " t.nbrun,"; $sql.= " t.libname,"; $sql.= " t.test"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; -$sql.= " WHERE 1 = 1"; +$sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($search_status >= 0 && $search_status < 2) $sql.= " AND t.status = ".(empty($search_status)?'0':'1'); if ($search_status == 2) $sql.= " AND t.status = 2"; //Manage filter diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 42f7a736b91..246fd3d75b4 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -85,7 +85,7 @@ if ($key != $conf->global->CRON_KEY) // If param userlogin is reserved word 'firstadmin' if ($userlogin == 'firstadmin') { - $sql='SELECT login from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1'; + $sql='SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1'; $resql=$db->query($sql); if ($resql) { @@ -93,7 +93,7 @@ if ($userlogin == 'firstadmin') if ($obj) { $userlogin = $obj->login; - echo "First admin user found is login '".$userlogin."'\n"; + echo "First admin user found is login '".$userlogin."', entity ".$obj->entity."\n"; } } else dol_print_error($db); @@ -132,7 +132,7 @@ if (! empty($id)) { $filter['t.rowid']=$id; } -$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter, 0); +$result = $object->fetch_all('ASC,ASC,ASC','t.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0); if ($result<0) { echo "Error: ".$object->error; @@ -159,8 +159,8 @@ if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) // Loop over job foreach($qualifiedjobs as $line) { - dol_syslog("cron_run_jobs.php cronjobid: ".$line->id, LOG_DEBUG); - echo "cron_run_jobs.php cronjobid: ".$line->id."\n"; + dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); + echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label."\n"; //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) From 0223d54107f4e57e2b88e71fb4c6f401f2a3bbb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 12:28:52 +0200 Subject: [PATCH 47/57] FIX Support or multicompany for sheduled jobs FIX Use priority to define order of sheduled jobs Conflicts: htdocs/cron/list.php --- htdocs/core/modules/DolibarrModules.class.php | 5 ++- htdocs/core/modules/modCron.class.php | 6 +-- htdocs/cron/card.php | 16 ++++++++ htdocs/cron/class/cronjob.class.php | 39 +++++++++++++------ htdocs/cron/list.php | 2 +- scripts/cron/cron_run_jobs.php | 10 ++--- 6 files changed, 55 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index eaf674d5eea..ef129a421ce 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1313,6 +1313,7 @@ class DolibarrModules // Can not be abstract, because we need to insta { foreach ($this->cronjobs as $key => $value) { + $entity = isset($this->cronjobs[$key]['entity'])?$this->cronjobs[$key]['entity']:$conf->entity; $label = isset($this->cronjobs[$key]['label'])?$this->cronjobs[$key]['label']:''; $jobtype = isset($this->cronjobs[$key]['jobtype'])?$this->cronjobs[$key]['jobtype']:''; $class = isset($this->cronjobs[$key]['class'])?$this->cronjobs[$key]['class']:''; @@ -1334,7 +1335,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if ($objectname) $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; if ($method) $sql.= " AND methodename = '".$this->db->escape($method)."'"; if ($command) $sql.= " AND command = '".$this->db->escape($command)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; // Must be exact entity $now=dol_now(); @@ -1371,7 +1372,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if(is_int($unitfrequency)){ $sql.= "'".$this->db->escape($unitfrequency)."', "; } if(is_int($priority)) {$sql.= "'".$this->db->escape($priority)."', ";} if(is_int($status)){ $sql.= "'".$this->db->escape($status)."', "; } - $sql.= $conf->entity.","; + $sql.= $entity.","; $sql.= "'".$this->db->escape($test)."'"; $sql.= ")"; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 8afcc26c80f..621b887ca3b 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -97,9 +97,9 @@ class modCron extends DolibarrModules // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), - 1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) + 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), + 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql', 'mysqli'))), + // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) ); // Permissions diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 8c97bc4e2c8..707b75b95fe 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -614,6 +614,22 @@ else print $langs->trans($object->note); print ""; + if (! empty($conf->multicompany->enabled)) + { + print ''; + print $langs->trans('Entity').""; + if (! $object->entity) + { + print $langs->trans("AllEntities"); + } + else + { + $mc->getInfo($obj->entity); + print $mc->label; + } + print ""; + } + print ''; print '
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 46ad08f849b..f890391431b 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -34,6 +34,7 @@ class Cronjob extends CommonObject public $table_element='cronjob'; //!< Name of table without prefix where object is stored public $picto = 'cron'; + public $entity; public $jobtype; public $tms=''; public $datec=''; @@ -153,7 +154,7 @@ class Cronjob extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob("; - + $sql.= "entity,"; $sql.= "datec,"; $sql.= "jobtype,"; $sql.= "label,"; @@ -183,6 +184,7 @@ class Cronjob extends CommonObject $sql.= "libname,"; $sql.= "test"; $sql.= ") VALUES ("; + $sql.= " ".(! isset($this->entity)?$conf->entity:$this->db->escape($this->entity)).","; $sql.= " '".$this->db->idate($now)."',"; $sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").","; $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; @@ -265,8 +267,8 @@ class Cronjob extends CommonObject function fetch($id) { $sql = "SELECT"; - $sql.= " t.rowid,"; - + $sql.= " t.rowid,"; + $sql.= " t.entity,"; $sql.= " t.tms,"; $sql.= " t.datec,"; $sql.= " t.jobtype,"; @@ -310,7 +312,7 @@ class Cronjob extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - + $this->entity = $obj->entity; $this->tms = $this->db->jdate($obj->tms); $this->datec = $this->db->jdate($obj->datec); $this->label = $obj->label; @@ -417,7 +419,7 @@ class Cronjob extends CommonObject } } - $sql.= " ORDER BY $sortfield $sortorder "; + $sql.= $this->db->order($sortfield,$sortorder); if (!empty($limit) && !empty($offset)) { $sql.= $this->db->plimit($limit + 1,$offset); } @@ -445,7 +447,6 @@ class Cronjob extends CommonObject $line->id = $obj->rowid; $line->ref = $obj->rowid; - $line->entity = $obj->entity; $line->tms = $this->db->jdate($obj->tms); $line->datec = $this->db->jdate($obj->datec); @@ -575,7 +576,7 @@ class Cronjob extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET"; - + $sql.= " entity=".(isset($this->entity)?$this->db->escape($this->entity):$conf->entity).","; $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " jobtype=".(isset($this->jobtype)?"'".$this->db->escape($this->jobtype)."'":"null").","; $sql.= " command=".(isset($this->command)?"'".$this->db->escape($this->command)."'":"null").","; @@ -773,7 +774,7 @@ class Cronjob extends CommonObject { $this->id=0; $this->ref=0; - + $this->entity=0; $this->tms=''; $this->datec=''; $this->label=''; @@ -930,6 +931,16 @@ class Cronjob extends CommonObject return -1; } + // Force the environment of running to the environment declared for job, so jobs launched from command line will run into correct environment + // When job is ran from GUI, the environment should already be same, except if job has entity 0 (visible into all environments) + if ($conf->entity != $this->entity && $this->entity > 0) + { + dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); + } + $savcurrententity = $conf->entity; + $conf->entity = $this->entity; + dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $user=new User($this->db); $result=$user->fetch('',$userlogin); @@ -937,6 +948,7 @@ class Cronjob extends CommonObject { $this->error="User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } else @@ -945,6 +957,7 @@ class Cronjob extends CommonObject { $this->error=" User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } } @@ -976,6 +989,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result<0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } @@ -1073,6 +1087,7 @@ class Cronjob extends CommonObject { $this->error = $langs->trans('CronCannotLoadLib') . ': ' . $libpath; dol_syslog(get_class($this) . "::run_jobs " . $this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } // Load langs @@ -1080,6 +1095,7 @@ class Cronjob extends CommonObject if ($result<0) { dol_syslog(get_class($this) . "::run_jobs Cannot load module langs" . $langs->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } dol_syslog(get_class($this) . "::run_jobs " . $this->libname . "::" . $this->methodename."(" . $this->params . ");", LOG_DEBUG); @@ -1142,13 +1158,12 @@ class Cronjob extends CommonObject if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $conf->entity = $savcurrententity; return -1; } - else - { - return $error?-1:1; - } + $conf->entity = $savcurrententity; + return $error?-1:1; } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index ba28d019958..6f4d469cc0a 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -187,7 +187,7 @@ $sql.= " t.nbrun,"; $sql.= " t.libname,"; $sql.= " t.test"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; -$sql.= " WHERE 1 = 1"; +$sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1'); if ($status == 2) $sql.= " AND t.status = 2"; //Manage filter diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 42f7a736b91..246fd3d75b4 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -85,7 +85,7 @@ if ($key != $conf->global->CRON_KEY) // If param userlogin is reserved word 'firstadmin' if ($userlogin == 'firstadmin') { - $sql='SELECT login from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1'; + $sql='SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1'; $resql=$db->query($sql); if ($resql) { @@ -93,7 +93,7 @@ if ($userlogin == 'firstadmin') if ($obj) { $userlogin = $obj->login; - echo "First admin user found is login '".$userlogin."'\n"; + echo "First admin user found is login '".$userlogin."', entity ".$obj->entity."\n"; } } else dol_print_error($db); @@ -132,7 +132,7 @@ if (! empty($id)) { $filter['t.rowid']=$id; } -$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter, 0); +$result = $object->fetch_all('ASC,ASC,ASC','t.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0); if ($result<0) { echo "Error: ".$object->error; @@ -159,8 +159,8 @@ if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) // Loop over job foreach($qualifiedjobs as $line) { - dol_syslog("cron_run_jobs.php cronjobid: ".$line->id, LOG_DEBUG); - echo "cron_run_jobs.php cronjobid: ".$line->id."\n"; + dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG); + echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label."\n"; //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) From b210360220edda065eba2b6b16e4a3cca7ee9b6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 12:59:01 +0200 Subject: [PATCH 48/57] More test --- test/phpunit/FunctionsLibTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index eb84f6cd348..dd492e4724c 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -465,6 +465,10 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $after=dol_string_nohtmltag($text,1); $this->assertEquals("DEF",$after,"test7"); + $text='HIJ'; + $after=dol_string_nohtmltag($text,0); + $this->assertEquals("HIJ",$after,"test8"); + return true; } From 156d26ddb9e1820fad684abc3e70fa03385faff4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:30:31 +0200 Subject: [PATCH 49/57] Fix: backward compatibility --- htdocs/core/class/commonobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1387c72adf0..9f252cf63a6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1358,19 +1358,22 @@ abstract class CommonObject if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; + $fk_user_field = 'fk_user_modif'; + $error=0; $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; + if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; $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); else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); - if (! empty($fuser) && is_object($fuser)) $sql.=", fk_user_modif = ".$fuser->id; - elseif (empty($fuser) || $fuser != 'none') $sql.=", fk_user_modif = ".$user->id; + if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; + elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG); From 5914bfdf18c44798adbb21484fd933f36b8a9bc2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:36:51 +0200 Subject: [PATCH 50/57] Fix: more complete --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9f252cf63a6..3d4720147d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1366,7 +1366,9 @@ abstract class CommonObject // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { + $fk_user_field = 'fk_user_mod'; + } $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; From 2b135dc951571bdea1cf6ae290112db29edfd159 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 13:13:45 +0200 Subject: [PATCH 51/57] FIX #8488 --- htdocs/core/class/hookmanager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 31833c113b4..7ae1043e7d1 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -175,7 +175,7 @@ class HookManager 'formatEvent', 'printObjectLine', 'printObjectSubLine', - 'createDictionaryFieldList', + 'createDictionaryFieldlist', 'editDictionaryFieldlist', 'getFormMail', 'showLinkToObjectBlock' From 1b1a8f7e8190f4b37484bcfa78d22e27514a2804 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 13:21:00 +0200 Subject: [PATCH 52/57] Fix trigger name --- htdocs/admin/mails_templates.php | 6 +++--- htdocs/admin/website.php | 16 ++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 79c4d4765be..32e6be85b11 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -521,7 +521,7 @@ $parameters = array( 'fieldlist' => $fieldlist, 'tabname' => $tabname[$id] ); -$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; @@ -732,7 +732,7 @@ if ($resql) { $tmpaction='edit'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('editEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; // Show fields @@ -791,7 +791,7 @@ if ($resql) { $tmpaction = 'view'; $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('viewEmailTemplateFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 54a91d6ee92..e3854c4eb11 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -64,7 +64,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admin')); +$hookmanager->initHooks(array('website')); // Name of SQL tables of dictionaries $tabname=array(); @@ -514,15 +514,7 @@ if ($id) } } - $tmpaction = 'create'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; - - if (empty($reshook)) - { - fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); print ''; if ($action != 'edit') @@ -602,7 +594,7 @@ if ($id) { $tmpaction='edit'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('editWebsiteFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; if (empty($reshook)) fieldListWebsites($fieldlist,$obj,$tabname[$id],'edit'); @@ -614,7 +606,7 @@ if ($id) { $tmpaction = 'view'; $parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('viewWebsiteFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; From 92cd314c0fd3c2a486007dd2cc2ad3e35bbec03c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 16:16:41 +0200 Subject: [PATCH 53/57] Fix to avoid warning --- htdocs/modulebuilder/template/myobject_list.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 4d1eb6829bd..7a4a04286f9 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -211,7 +211,8 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->element]['label'])) + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -242,7 +243,8 @@ foreach($object->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); +if (! empty($extrafields->attributes[$object->element]['label'])) { + foreach ($extrafields->attributes[$object->element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->element]['type'][$key] != 'separate' ? ",ef.".$key : ''); // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook From 55719cd166ba1ec0dc8211ebcacdf9d4eb888bfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 16:20:50 +0200 Subject: [PATCH 54/57] Update card.php --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7ddf36f208b..43b4ba581a2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -77,7 +77,7 @@ $duration_unit = GETPOST('duration_unit'); if (! empty($user->societe_id)) $socid=$user->societe_id; $object = new Product($db); -$object->type = $type; +$object->type = $type; // so test later to fill $usercancxxx is correct $extrafields = new ExtraFields($db); // fetch optionals attributes and labels From 8cf56a5b9c44120241408041cf6a65f520ced49a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 16:29:37 +0200 Subject: [PATCH 55/57] Fix regression --- htdocs/societe/class/societe.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 80a7f7cc46a..e36caf49a3e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2592,8 +2592,6 @@ class Societe extends CommonObject if ($res) { - dol_include_once($file); - $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; $mod = new $classname; From 57db0d2a167847bc843766be779a7dd2563a662c Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 17:26:08 +0200 Subject: [PATCH 56/57] Add hidden conf --- htdocs/commande/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 669bb7b9474..d481ac32d90 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -49,7 +49,7 @@ foreach($linkedObjectBlock as $key => $objectlink) ?> trans("CustomerOrder"); ?> - getNomUrl(0,'',0,1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' getNomUrl(1); ?> ref_client; ?> From 48ff89c63bde5c40622fffd3ede37de70743912c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 19:52:54 +0200 Subject: [PATCH 57/57] Fix regression --- htdocs/core/class/html.form.class.php | 5 ++++- htdocs/core/lib/functions.lib.php | 8 ++++---- htdocs/core/modules/action/rapport.pdf.php | 6 ++++-- test/phpunit/FunctionsLibTest.php | 9 +++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8f9be1356d4..60e0ea24967 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1703,7 +1703,10 @@ class Form $userstatic->fetch($value['id']); $out.= $userstatic->getNomUrl(-1); if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; } - if ($nbassignetouser > 1 && $action != 'view') $out.=' '; + if ($nbassignetouser > 1 && $action != 'view') + { + $out.=' '; + } // Show my availability if ($showproperties) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6afb6892679..14f147d7f48 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3059,7 +3059,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1) * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"') - * @param int $pictoisfullpath If 1, image path is a full path + * @param boolean|int $pictoisfullpath If true or 1, image path is a full path * @param int $srconly Return only content of the src attribute of img. * @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip. * @param string $alt Force alt for bind peoplae @@ -3082,13 +3082,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) { $picto .= '.png'; } - $fullpathpicto = $url.'/'.$path.'/img/'.$picto; + $fullpathpicto = $picto; } else { $pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) - if (in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { + if (empty($srconly) && in_array($pictowithoutext, array('bank', 'delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { $fakey = $pictowithoutext; $facolor = ''; $fasize = ''; @@ -3151,7 +3151,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.= ($morecss?' ':'').$reg[1]; } - $enabledisablehtml = ''; + $enabledisablehtml = ''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml.= $titlealt; } diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index c6b652e265e..504164cd431 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -179,7 +179,7 @@ class CommActionRapport @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; } } @@ -291,7 +291,9 @@ class CommActionRapport if ($code == 'AC_OTH_AUTO') $code='AC_AUTO'; } $pdf->SetXY(60,$y); - $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Action".$code)),32), 0, 'L', 0); + $labelactiontype = $outputlangs->transnoentitiesnoconv("Action".$code); + $labelactiontypeshort = $outputlangs->transnoentitiesnoconv("Action".$code.'Short'); + $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($labelactiontypeshort == "Action".$code.'Short' ? $labelactiontype : $labelactiontypeshort),32), 0, 'L', 0); $y2 = $pdf->GetY(); // Description of event diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index dd492e4724c..da6fe60d787 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -820,13 +820,18 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $this->assertContains('theme',$s,'testImgPicto2'); $this->assertContains('style="float: right"',$s,'testImgPicto2'); - $s=img_picto('title','/fullpath/img.png','',1); + $s=img_picto('title', '/fullpath/img.png', '', 1); print __METHOD__." s=".$s."\n"; $this->assertEquals('',$s,'testImgPicto3'); - $s=img_picto('title','/fullpath/img.png','',true); + $s=img_picto('title', '/fullpath/img.png', '', true); print __METHOD__." s=".$s."\n"; $this->assertEquals('',$s,'testImgPicto4'); + + $s=img_picto('title', 'delete', '', 0, 1); + print __METHOD__." s=".$s."\n"; + $this->assertEquals('',$s,'testImgPicto3'); + } /**