From 5624257a6def5f4f79149d274d2f674989982d83 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 20 Feb 2018 16:49:49 +0100 Subject: [PATCH 01/84] 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/84] 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/84] 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/84] 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/84] 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/84] 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/84] 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/84] 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 b3d0b892e5d1ae3402f5550d6dd06b2d233dcf5a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 13 Mar 2018 18:02:36 +0100 Subject: [PATCH 09/84] NEW add internal stripe payment page for invoice WIP: dolibarize with new enhancements and functions --- htdocs/stripe/payment.php | 1108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 1108 insertions(+) create mode 100644 htdocs/stripe/payment.php diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php new file mode 100644 index 00000000000..56eb95cc578 --- /dev/null +++ b/htdocs/stripe/payment.php @@ -0,0 +1,1108 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2015 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/paiement.php + * \ingroup facture + * \brief Payment page for customers invoices + */ + +// Load Dolibarr environment +$res=@include("../main.inc.php"); // For root directory +if (! $res) $res=@include("../../main.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + +$langs->load('companies'); +$langs->load('bills'); +$langs->load('banks'); +$langs->load('multicurrency'); +$langs->load('stripe@stripe'); + +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm'); + +$facid = GETPOST('facid','int'); +$socname = GETPOST('socname'); +$source = GETPOST('source_id'); +$accountid = GETPOST('accountid'); +$paymentnum = GETPOST('num_paiement'); + +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); + +$amounts=array(); +$amountsresttopay=array(); +$addwarning=0; + +$multicurrency_amounts=array(); +$multicurrency_amountsresttopay=array(); + +if (! empty($conf->stripe->enabled)) +{ + $service = 'StripeTest'; + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) + { + $service = 'StripeLive'; + $servicestatus = 0; + } + + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get thirdparty cu_... +} + +// Security check +$socid=0; +if ($user->societe_id > 0) +{ + $socid = $user->societe_id; +} + +$object=new Facture($db); + +// Load object +if ($facid > 0) +{ + $ret=$object->fetch($facid); +} + +// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('paiementcard','globalcard')); + + +/* + * Actions + */ + +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + { + $error = 0; + + $datepaye = dol_now(); + $paiement_id = 0; + $totalpayment = 0; + $multicurrency_totalpayment = 0; + $atleastonepaymentnotnull = 0; + + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice=new Facture($db); + foreach ($_POST as $key => $value) + { + if (substr($key,0,7) == 'amount_') + { + $cursorfacid = substr($key,7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } + + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + } + elseif (substr($key,0,21) == 'multicurrency_amount_') + { + $cursorfacid = substr($key,21); + $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; + if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + if ($multicurrency_amounts[$cursorfacid]) + { + // Check amount + if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } + + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + } + } + + // Check parameters +// if (! GETPOST('paiementcode')) +// { +// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); +// $error++; +// } + + if (! empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), null, 'errors'); + $error++; + } + +// if (empty($datepaye)) +// { +// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); +// $error++; +// } + + // Check if payments in both currency + if ($totalpayment > 0 && $multicurrency_totalpayment > 0) + { + setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); + $error++; + } + } + + /* + * Action add_paiement + */ + if ($action == 'add_paiement') + { + if ($error) + { + $action = 'create'; + if (!$source) + { + setEventMessages($langs->transnoentities('NoSource'), null, 'errors'); + } + $error++; + } + // Le reste propre a cette action s'affiche en bas de page. + } + + /* + * Action confirm_paiement + */ + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + + $error=0; + + $datepaye = dol_now(); + + $db->begin(); + + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == 2) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } + + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $multicurrency_amounts[$key] = -$newvalue; + } + } + + if (! empty($conf->banque->enabled)) + { + // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement + if (GETPOST('accountid') <= 0) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } +$facture = new Facture($db); +$facture->fetch($facid); + + $error = 0; + + if (is_object($stripe) && $stripeacc) + { + $customerstripe=$stripe->customerStripe($object->socid, $stripeacc, $servicestatus); + + if ($customerstripe->id) { + $listofsources=$customerstripe->sources->data; + } + } + +$stripeamount=0; + foreach ($amounts as $key => $value) // How payment is dispatch + { +$stripeamount+=price2num($value,'MT'); +} + +if (preg_match('/acct_/i',$source)) +{ +$paiementcode ="VIR"; +} +elseif (preg_match('/card_/i',$source)) +{ +$paiementcode ="CB"; +} +elseif (preg_match('/src_/i',$source)) +{ +$customer2 = \Stripe\Customer::retrieve($customer->id,array("stripe_account" => $stripe->getStripeAccount($entity))); +$src = $customer2->sources->retrieve("$source"); +if ($src->type=='card'){ +$paiementcode ="CB"; +} +} +$societe = new Societe($db); +$societe->fetch($facture->socid); + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + +$charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity)); + + if (!$error) + { + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); + $paiement->num_paiement = $charge->message; + $paiement->note = GETPOST('comment'); + } + + if (! $error) + { + + $paiement_id = $paiement->create($user, 0); + if ($paiement_id < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($facture->lines)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$facture->modelpdf; + $ret = $facture->fetch($facid); // Reload to get new records + + $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + + } + + } + + if (! $error) + { + $label='(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; + $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),'',''); + if ($result < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + elseif (GETPOST('closepaidinvoices')=='on') { + $facture->set_paid($user); + } + } + + if (! $error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1); + $db->rollback(); + header('Location: '.$loc); + } + + } +} + + +/* + * View + */ + +llxHeader(); + + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) + { + $service = 'StripeLive'; + $servicestatus = 0; + } + else { +dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); + } + +$form=new Form($db); +if (GETPOST('error')){ +setEventMessages(GETPOST('error'), NULL, 'errors'); +} +if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') +{ + $facture = new Facture($db); + $result=$facture->fetch($facid); + + if ($result >= 0) + { + $facture->fetch_thirdparty(); + + $title=''; + if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); + print load_fiche_titre($title); + + // Initialize data for confirmation (this is used because data can be change during confirmation) + if ($action == 'add_paiement') + { + $i=0; + + $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); + $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + } + + + // Add realtime total information + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + + // Third party + print '\n"; + + // Bank account + if (! empty($conf->banque->enabled)) + { + //$form->select_comptes($accountid,'accountid',0,'',2); + print ''; + } + else + { + print ''; + } + + // Cheque number +// print ''; +// print ''; + + // Check transmitter +// print ''; +// print ''; + + // Bank name +// print ''; +// print ''; + + // Comments + print ''; + print ''; + + print '
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Numero'); +// print ' ('.$langs->trans("ChequeOrTransferNumber").')'; +// print '
'.$langs->trans('CheckTransmitter'); +// print ' ('.$langs->trans("ChequeMaker").')'; +// print '
'.$langs->trans('Bank'); +// print ' ('.$langs->trans("ChequeBank").')'; +// print '
'.$langs->trans('Comments').''; + print '
'; + + dol_fiche_end(); + + +$customerstripe=$stripe->customerStripe($facture->socid, $stripeacc, $servicestatus); + print '
'; + print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + + print ''."\n"; + // Titles with sort buttons + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + foreach ($customerstripe->sources->data as $src) { +print ''; + + print ''; + +print ''; +print ''; + // Default + print ''; +print ''; +} +// TODO more dolibarize with new stripe function and stripeconnect +//if ($stripe->getStripeCustomerAccount($facture->socid)) { +//$account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); +//} + +if (($account->type=='custom' or $account->type=='express') && $entity==1) { +print ''; + + print ''; + +print ''; + // Default + print ''; +print ''; +} +if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) +{ +print ''; +} + + print "
'.$langs->trans('Type').''.$langs->trans('Informations').'
id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} +print'>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + print ' disabled'; + } elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) { + print ' checked'; + } + print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} + +print' >'; +if ($src->object=='card'){ +if ($src->brand == 'Visa') {$brand='cc-visa';} +elseif ($src->brand == 'MasterCard') {$brand='cc-mastercard';} +elseif ($src->brand == 'American Express') {$brand='cc-amex';} +elseif ($src->brand == 'Discover') {$brand='cc-discover';} +elseif ($src->brand == 'JCB') {$brand='cc-jcb';} +elseif ($src->brand == 'Diners Club') {$brand='cc-diners-club';} +else {$brand='credit-card-alt';} +print ''; +} +elseif ($src->object=='source' && $src->type=='card'){ +if ($src->card->brand == 'Visa') {$brand='cc-visa';} +elseif ($src->card->brand == 'MasterCard') {$brand='cc-mastercard';} +elseif ($src->card->brand == 'American Express') {$brand='cc-amex';} +elseif ($src->card->brand == 'Discover') {$brand='cc-discover';} +elseif ($src->card->brand == 'JCB') {$brand='cc-jcb';} +elseif ($src->card->brand == 'Diners Club') {$brand='cc-diners-club';} +else {$brand='credit-card-alt';} + +print ''; +} +elseif ($src->object=='source' && $src->type=='sepa_debit'){ +print ''; +} +print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} +print' >'; +if ($src->object=='card'){ +print '**** '.$src->last4.'
Exp. '.$src->exp_month.'/'.$src->exp_year.''; +print '
'; + if ($src->country) + { + $img=picto_from_langcode($src->country); + print $img?$img.' ':''; + print getCountry($src->country,1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; +} +elseif ($src->object=='source' && $src->type=='card'){ + print $src->owner->name.'
**** '.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; +print '
'; + if ($src->card->country) + { + $img=picto_from_langcode($src->card->country); + print $img?$img.' ':''; + print getCountry($src->card->country,1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; +} +elseif ($src->object=='source' && $src->type=='sepa_debit'){ +print 'info sepa'; +print ''; + if ($src->sepa_debit->country) + { + $img=picto_from_langcode($src->sepa_debit->country); + print $img?$img.' ':''; + print getCountry($src->sepa_debit->country,1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; +} +print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { print'class="opacitymedium"';} +print'>'; + if (($customerstripe->default_source==$src->id)) { + print ""; + } + print '
getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} +print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { + print ' checked'; + } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { + print ' disabled'; + } + print '>getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} + print '>getStripeCustomerAccount($facture->socid)!=$source) { print'class="opacitymedium"';} +print'>'.$langs->trans('sold'); +print'id!=$source) { print'class="opacitymedium"';} +print'>'; + +print 'id!=$source) { print'class="opacitymedium"';} +print'>'; +// if (($customer->default_source!=$src->id)) { +// print img_picto($langs->trans("Disabled"),'off'); +// } else { +// print img_picto($langs->trans("Default"),'on'); +// } + print '
'.$langs->trans("NoSource").'
"; + /* + * List of unpaid invoices + */ + + $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; + $sql.= ' f.datef as df, f.fk_soc as socid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; + } + + $sql.= ' WHERE f.entity = '.$conf->entity; + $sql.= ' AND (f.fk_soc = '.$facture->socid; + + if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { + $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; + } + + $sql.= ') AND f.paye = 0'; + $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + if ($facture->type != 2) + { + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + } + else + { + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + } + + // Sort invoices by date and serial number: the older one comes first + $sql.=' ORDER BY f.datef ASC, f.facnumber ASC'; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num > 0) + { + $sign=1; + if ($facture->type == 2) $sign=-1; + + $arraytitle=$langs->trans('Invoice'); + if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes"); + $alreadypayedlabel=$langs->trans('Received'); + $multicurrencyalreadypayedlabel=$langs->trans('MulticurrencyReceived'); + if ($facture->type == 2) { $alreadypayedlabel=$langs->trans("PaidBack"); $multicurrencyalreadypayedlabel=$langs->trans("MulticurrencyPaidBack"); } + $remaindertopay=$langs->trans('RemainderToTake'); + $multicurrencyremaindertopay=$langs->trans('MulticurrencyRemainderToTake'); + if ($facture->type == 2) { $remaindertopay=$langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay=$langs->trans("MulticurrencyRemainderToPayBack"); } + + $i = 0; + //print ''; + print '
'; + print_barre_liste($langs->trans('StripeInvoiceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + print ''; + print "\n"; + + $var=true; + $total=0; + $totalrecu=0; + $totalrecucreditnote=0; + $totalrecudeposits=0; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + + $soc = new Societe($db); + $soc->fetch($objp->socid); + + $invoice=new Facture($db); + $invoice->fetch($objp->facid); + $paiement = $invoice->getSommePaiement(); + $creditnotes=$invoice->getSumCreditNotesUsed(); + $deposits=$invoice->getSumDepositsUsed(); + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); + + // Multicurrency Price + if (!empty($conf->multicurrency->enabled)) + { + $multicurrency_payment = $invoice->getSommePaiement(1); + $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); + $multicurrency_deposits=$invoice->getSumDepositsUsed(1); + $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT'); + $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT'); + } + + print ''; + + print '\n"; + + // Date + print '\n"; + + // Currency + if (!empty($conf->multicurrency->enabled)) print '\n"; + + // Multicurrency Price + if (!empty($conf->multicurrency->enabled)) + { + print ''; + + // Multicurrency Price + print ''; + + // Multicurrency Price + print ''; + } + + // Price + print ''; + + // Received or paid back + print ''; + + // Remain to take or to pay back + print ''; + //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); + + // Amount + print '"; + + // Multicurrency Price + if (! empty($conf->multicurrency->enabled)) + { + print '"; + } + + // Warning + print ''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$objp,$action); // Note that $action and $object may have been modified by hook + + print "\n"; + + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$paiement; + $totalrecucreditnote+=$creditnotes; + $totalrecudeposits+=$deposits; + $i++; + } + if ($i > 1) + { + $amount=round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT'))*100); + // Print total + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) {print '';} + print "\n"; + } + print "
'.$arraytitle.''.$langs->trans('Date').''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('AmountTTC').''.$alreadypayedlabel.''.$remaindertopay.''.$langs->trans('PaymentAmount').''.$langs->trans('MulticurrencyPaymentAmount').' 
'; + print $invoice->getNomUrl(1,''); + if($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + print "'.dol_print_date($db->jdate($objp->df),'day')."'.$objp->multicurrency_code."'; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); + print ''; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + print price($sign * $multicurrency_payment); + if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); + if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); + } + print ''; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); + print ''.price($sign * $objp->total_ttc).''.price($sign * $paiement); + if ($creditnotes) print '+'.price($creditnotes); + if ($deposits) print '+'.price($deposits); + print ''.price($sign * $remaintopay).''; + + // Add remind amount + $namef = 'amount_'.$objp->facid; + $nameRemain = 'remain_'.$objp->facid; + + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } + print "'; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } + } + print "'; + //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; + if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) + || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) + { + print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); + } + print '
'.$langs->trans('TotalTTC').''.price($sign * $total_ttc).''.price($sign * $totalrecu); + if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); + if ($totalrecudeposits) print '+'.price($totalrecudeposits); + print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).'
"; + //print "\n"; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + + + // Bouton Enregistrer + if ($action != 'add_paiement') + { + $checkboxlabel=$langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == 2) $checkboxlabel=$langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle=$langs->trans('ToMakePayment'); + if ($facture->type == 2) $buttontitle=$langs->trans('ToMakePaymentBack'); + + print '
'; + print ' '.$checkboxlabel; + /*if (! empty($conf->prelevement->enabled)) + { + $langs->load("withdrawals"); + if (! empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '
'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); + }*/ + print '


'; + print '
'; + } + + // Form to confirm payment + if ($action == 'add_paiement') + { + $preselectedchoice=$addwarning?'no':'yes'; + + print '
'; + if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); + if (!empty($multicurrency_totalpayment)) + { + $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + } + if (GETPOST('closepaidinvoices')) + { + $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + print ''; + } + print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type,$langs->trans('ReceivedCustomersPayments'),$text,'confirm_paiement',$formquestion,$preselectedchoice); + } + + print "
\n"; + } +} + + +/** + * Show list of payments + */ +if (! GETPOST('action')) +{ + if ($page == -1) $page = 0 ; + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $offset = $limit * $page ; + + if (! $sortorder) $sortorder='DESC'; + if (! $sortfield) $sortfield='p.datep'; + + $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.facnumber'; + $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; + $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; + $sql.= ' AND f.entity = '.$conf->entity; + if ($socid) + { + $sql.= ' AND f.fk_soc = '.$socid; + } + + $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql.= $db->plimit($limit+1, $offset); + $resql = $db->query($sql); + + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $var=true; + + print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"],'',$sortfield,$sortorder,'',$num); + print ''; + print ''; + print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'facnumber','','','',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','','','',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Type'),$_SERVER["PHP_SELF"],'libelle','','','',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'fa_amount','','','align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ''; + print '\n"; + print '\n"; + print '\n"; + print ''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$objp,$action); // Note that $action and $object may have been modified by hook + + print ''; + $i++; + } + print '
'.$objp->facnumber."'.dol_print_date($db->jdate($objp->dp))."'.$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount).' 
'; + } +} + +llxFooter(); + +$db->close(); From af7c1d8da17661a9a525521745d986f8f5c10e87 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 27 Mar 2018 18:39:18 +0200 Subject: [PATCH 10/84] 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 11/84] 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 12/84] 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 13/84] 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 14/84] 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 15/84] 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 16/84] 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 17/84] 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 18/84] 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 19/84] 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 20/84] 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 21/84] 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 443ffe315097543d594063b29e3631d5bc35898d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 17:51:23 +0200 Subject: [PATCH 22/84] Fix: remove html tags and decode html entities --- htdocs/user/class/usergroup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index f322d59a960..483086574a6 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -908,7 +908,7 @@ class UserGroup extends CommonObject // Champs if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; //if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name; - if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = $this->note; + if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note)); if (! empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) { $valueofldapfield=array(); From c4ce543294990de298ee3107e104b6f8880737ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:30:31 +0200 Subject: [PATCH 23/84] 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 24/84] 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 0e4d796f8833b86f8fcbf1a29584a11064fdcb17 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:47:53 +0200 Subject: [PATCH 25/84] Fix: more complete --- htdocs/adherents/class/adherent.class.php | 6 +++--- htdocs/user/class/user.class.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8ae6a18eb2f..6653d111363 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2316,15 +2316,15 @@ class Adherent extends CommonObject if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe; if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; - if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; + if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private; - if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public; + if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note_private)); + if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = html_entity_decode(strip_tags($this->note_public)); if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c70ab1acf13..5a24baae8dd 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2407,8 +2407,8 @@ class User extends CommonObject } if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip; - if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; - if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note_public; + if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; + if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note_public)); if ($this->socid > 0) { $soc = new Societe($this->db); From 34c484dea7aabf8821cbde40d2949286002117df Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 19:16:39 +0200 Subject: [PATCH 26/84] Fix: missing adherent type --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 4a032457f0d..af5790c41db 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -456,7 +456,7 @@ class AdherentType extends CommonObject // Champs if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; - if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = $this->note; + if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note)); if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) { $valueofldapfield=array(); From 546f3f8b96c79c3aacde02ea752b3ca7510cbe9f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Mar 2018 07:19:42 +0200 Subject: [PATCH 27/84] 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 28/84] 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 29/84] 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 30/84] 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 31/84] 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 32/84] 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 33/84] 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 a5428cc8c70f3327a389e1f417d6d4240c00a95a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 1 Apr 2018 21:26:52 +0200 Subject: [PATCH 34/84] NEW Module Assets --- htdocs/accountancy/admin/journals_list.php | 1 + .../class/accountingjournal.class.php | 2 +- htdocs/assets/admin/assets_extrafields.php | 113 ++++ htdocs/assets/admin/setup.php | 118 ++++ htdocs/assets/card.php | 436 ++++++++++++++ htdocs/assets/class/assets.class.php | 485 ++++++++++++++++ htdocs/assets/document.php | 153 +++++ htdocs/assets/info.php | 82 +++ htdocs/assets/list.php | 540 ++++++++++++++++++ htdocs/assets/note.php | 149 +++++ htdocs/core/lib/assets.lib.php | 115 ++++ htdocs/core/menus/init_menu_auguria.sql | 6 +- htdocs/core/menus/standard/auguria.lib.php | 3 +- htdocs/core/menus/standard/eldy.lib.php | 26 +- htdocs/core/modules/modAssets.class.php | 261 +++++++++ .../install/mysql/data/llx_accounting_abc.sql | 3 +- .../install/mysql/migration/7.0.0-8.0.0.sql | 34 ++ .../install/mysql/tables/llx_assets.key.sql | 21 + htdocs/install/mysql/tables/llx_assets.sql | 33 ++ .../mysql/tables/llx_assets_extrafields.sql | 23 + htdocs/langs/en_US/accountancy.lang | 3 +- htdocs/langs/en_US/assets.lang | 39 ++ 22 files changed, 2633 insertions(+), 13 deletions(-) create mode 100644 htdocs/assets/admin/assets_extrafields.php create mode 100644 htdocs/assets/admin/setup.php create mode 100644 htdocs/assets/card.php create mode 100644 htdocs/assets/class/assets.class.php create mode 100644 htdocs/assets/document.php create mode 100644 htdocs/assets/info.php create mode 100644 htdocs/assets/list.php create mode 100644 htdocs/assets/note.php create mode 100644 htdocs/core/lib/assets.lib.php create mode 100644 htdocs/core/modules/modAssets.class.php create mode 100644 htdocs/install/mysql/tables/llx_assets.key.sql create mode 100644 htdocs/install/mysql/tables/llx_assets.sql create mode 100644 htdocs/install/mysql/tables/llx_assets_extrafields.sql create mode 100644 htdocs/langs/en_US/assets.lang diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 14f345a8973..a7811a2d606 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -135,6 +135,7 @@ $elementList = array(); '3' => $langs->trans('AccountingJournalType3'), '4' => $langs->trans('AccountingJournalType4'), '5' => $langs->trans('AccountingJournalType5'), + '8' => $langs->trans('AccountingJournalType8'), '9' => $langs->trans('AccountingJournalType9') ); diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 3e2c0840f8a..2e48fc8a54a 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -36,7 +36,7 @@ class AccountingJournal extends CommonObject public $code; public $label; - public $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 4:expense-report, 9: has-new + public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new public $active; public $lines; diff --git a/htdocs/assets/admin/assets_extrafields.php b/htdocs/assets/admin/assets_extrafields.php new file mode 100644 index 00000000000..85c596b6e37 --- /dev/null +++ b/htdocs/assets/admin/assets_extrafields.php @@ -0,0 +1,113 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/assets/admin/assets_extrafields.php + * \ingroup assets + * \brief Page to setup extra fields of assets + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->loadLangs(array("assets","admin","companies")); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='don'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Assets"); + +llxHeader('',$langs->trans("AssetsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); + + +$head = AssetsAdminPrepareHead(); + +dol_fiche_head($head, 'attributes', $langs->trans("Assets"), 0, 'generic'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Create optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edit optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/assets/admin/setup.php b/htdocs/assets/admin/setup.php new file mode 100644 index 00000000000..19de7b3b752 --- /dev/null +++ b/htdocs/assets/admin/setup.php @@ -0,0 +1,118 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/assets/admin/setup.php + * \ingroup assets + * \brief Assets setup page. + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; + +global $langs, $user; + +// Translations +$langs->loadLangs(array("admin", "assets")); + +// Access control +if (! $user->admin) accessforbidden(); + +// Parameters +$action = GETPOST('action', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); + +$arrayofparameters=array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500')); + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + +/* + * View + */ + +llxHeader('',$langs->trans("AssetsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); + + +$head = AssetsAdminPrepareHead(); + +dol_fiche_head($head, 'settings', $langs->trans("Assets"), 0, 'generic'); + +// Setup page goes here +echo $langs->trans("AssetsSetupPage"); + + +if ($action == 'edit') +{ + print ''; + print ''; + print ''; + + print '
'; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print '
'; + + print '
'; + print ''; + print '
'; + + print ''; + print '
'; +} +else +{ + print ''; + print ''; + + foreach($arrayofparameters as $key => $val) + { + print ''; + } + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print '' . $conf->global->$key . '
'; + + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; +} + + +// Page end +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/assets/card.php b/htdocs/assets/card.php new file mode 100644 index 00000000000..c18f628b296 --- /dev/null +++ b/htdocs/assets/card.php @@ -0,0 +1,436 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file card.php + * \ingroup assets + * \brief Page to create/edit/view assets + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("assets")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new Assets($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetscard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'assets', $id); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + $permissiontoadd = $user->rights->assets->create; + $permissiontodelete = $user->rights->assets->delete; + $backurlforlist = dol_buildpath('/assets/list.php',1); + + // Actions cancel, add, update or delete + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MYOBJECT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trackid='assets'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +$title=$langs->trans("Assets").' - '.$langs->trans("Card"); +$help_url=''; +llxHeader('',$title,$help_url); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewAsset")); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("Assets")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals($object->id, $extralabels); + + $head = AssetsPrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + }*/ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + if (! $formconfirm) { + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->assets->creer) + { + if ($action != 'classify') + { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswithonsecondcolumn'; + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print '

'; + + dol_fiche_end(); + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + if ($user->rights->assets->write) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + /* + if ($user->rights->assets->create) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ + + if ($user->rights->assets->delete) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->assets->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->assets->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->assets->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('assets', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('assets')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'assets', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + + print '
'; + } + + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ +} + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/assets/class/assets.class.php b/htdocs/assets/class/assets.class.php new file mode 100644 index 00000000000..69b94cc3fd8 --- /dev/null +++ b/htdocs/assets/class/assets.class.php @@ -0,0 +1,485 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file assets/class/assets.class.php + * \ingroup assets + * \brief This file is a CRUD class file for assets (Create/Read/Update/Delete) + */ + +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for Assets + */ +class Assets extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'assets'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'assets'; + /** + * @var int Does assets support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + /** + * @var int Does assets support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** + * @var string String with name of icon for assets. Must be the part after the 'object_' into object_assets.png + */ + public $picto = 'assets'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'showoncombobox' if field must be shown into the label of combobox + */ + + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",), + 'amount' => array('type'=>'double(24,8)', 'label'=>'Amount', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), + 'description' => array('type'=>'text', 'label'=>'Descrption', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Active', '-1'=>'Cancel')), + ); + public $rowid; + public $ref; + public $entity; + public $label; + public $amount; + public $fk_soc; + public $description; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $import_key; + public $status; + + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'assetsdet'; + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_assets'; + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'Assetsline'; + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('assetsdet'); + /** + * @var AssetsLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $hookmanager, $langs; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object AssetsLine + + return count($this->lines)?1:0; + }*/ + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("Assets") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowAssets"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + static function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 6) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + + /** + * Action executed by scheduler + * CAN BE A CRON TASK + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doScheduledJob() + { + global $conf, $langs; + + $this->output = ''; + $this->error=''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // ... + + return 0; + } +} + +/** + * Class AssetsLine. You can also remove this and generate a CRUD class for lines objects. + */ +/* +class AssetsLine +{ + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; +} +*/ \ No newline at end of file diff --git a/htdocs/assets/document.php b/htdocs/assets/document.php new file mode 100644 index 00000000000..490fb8f36a4 --- /dev/null +++ b/htdocs/assets/document.php @@ -0,0 +1,153 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file document.php + * \ingroup assets + * \brief Tab for documents linked to Assets + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +// Load traductions files requiredby by page +$langs->loadLangs(array("assets","companies")); + + +$action=GETPOST('action','aZ09'); +$confirm=GETPOST('confirm'); +$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'assets', $id); + +// Get parameters +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + +// Initialize technical objects +$object=new Assets($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetsdocument')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('assets'); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + +//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->id); +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->ref); + + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +$title=$langs->trans("Assets").' - '.$langs->trans("Files"); +$help_url=''; +//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $title, $help_url); + +if ($object->id) +{ + /* + * Show tabs + */ + if (! empty($conf->notification->enabled)) $langs->load("mails"); + $head = AssetsPrepareHead($object); + + dol_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Number of files + print ''; + + // Total size + print ''; + + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'assets'; + //$permission = $user->rights->assets->create; + $permission = 1; + //$permtoedit = $user->rights->assets->create; + $permtoedit = 1; + $param = '&id=' . $object->id; + + //$relativepathwithnofile='assets/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='assets/' . dol_sanitizeFileName($object->ref).'/'; + + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('',0,0); +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/assets/info.php b/htdocs/assets/info.php new file mode 100644 index 00000000000..9017a9e6845 --- /dev/null +++ b/htdocs/assets/info.php @@ -0,0 +1,82 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file info.php + * \ingroup assets + * \brief Page to show an asset information + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; + +$langs->loadLangs(array("assets")); + +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'assets', $id, ''); + +$object = new Assets($db); +$object->fetch($id); + +/* + * Actions + */ + +/* + * View + */ +$title = $langs->trans('Asset') . " - " . $langs->trans('Info'); +$helpurl = ""; +llxHeader('', $title, $helpurl); + +$form = new Form($db); + +$object->info($id); + +$head = AssetsPrepareHead($object); + +dol_fiche_head($head, 'info', $langs->trans("Asset"), -1, 'generic'); + +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref='
'; +$morehtmlref.='
'; + +dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + +print '
'; +print '
'; + +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; + +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/assets/list.php b/htdocs/assets/list.php new file mode 100644 index 00000000000..c8ac1f869f1 --- /dev/null +++ b/htdocs/assets/list.php @@ -0,0 +1,540 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file list.php + * \ingroup assets + * \brief List page for assets + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + + +// Load Dolibarr environment +require '../main.inc.php'; +require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; + +// Load traductions files requiredby by page +$langs->loadLangs(array("assets")); + +$action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'assetslist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical objects +$object=new Assets($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetslist')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Protection if external user +$socid=0; +if ($user->societe_id > 0) +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'assets', $id,''); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + * + * Put here all code to do according to value of "$action" parameter + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // 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 + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Assets'; + $objectlabel='Assets'; + $permtoread = $user->rights->assets->read; + $permtodelete = $user->rights->assets->delete; + $uploaddir = $conf->assets->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + * + * Put here all code to render page + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_Assets|FR:Module_Assets_FR|ES:Módulo_Assets"; +$help_url=''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."assets_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")"; +else $sql.=" WHERE 1 = 1"; +foreach($search as $key => $val) +{ + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +*/ + +$sql.=$db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); + +$resql=$db->query($sql); +if (! $resql) +{ + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/assets/card.php?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->assets->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendAssetsRef"; +$modelmail="assets"; +$objecttmp=new Assets($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
';*/ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +foreach ($extrafields->attribute_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; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->assets->read; + $delallowed=$user->rights->assets->create; + + print $formfile->showdocuments('massfilesarea_assets','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/assets/note.php b/htdocs/assets/note.php new file mode 100644 index 00000000000..b0db48e2abe --- /dev/null +++ b/htdocs/assets/note.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file note.php + * \ingroup assets + * \brief Card with notes on Assets + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; + +// Load traductions files requiredby by page +$langs->loadLangs(array("assets","companies")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new Assets($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetsnote')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('assets'); + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'assets', $id); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->assets->multidir_output[$object->entity] . "/" . $object->id; + +$permissionnote=1; +//$permissionnote=$user->rights->assets->creer; // Used by the include of actions_setnotes.inc.php + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + + +/* + * View + */ + +$form = new Form($db); + +//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; +$help_url=''; +llxHeader('',$langs->trans('Assets'),$help_url); + +if ($id > 0 || ! empty($ref)) +{ + $object->fetch_thirdparty(); + + $head = AssetsPrepareHead($object); + + dol_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic'); + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->assets->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + + $cssclass="titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + dol_fiche_end(); +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/assets.lib.php b/htdocs/core/lib/assets.lib.php new file mode 100644 index 00000000000..07a749f9f75 --- /dev/null +++ b/htdocs/core/lib/assets.lib.php @@ -0,0 +1,115 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file core/lib/assets.lib.php + * \ingroup assets + * \brief Library files with common functions for Assets + */ + +/** + * Prepare admin pages header + * + * @return array + */ +function AssetsAdminPrepareHead() +{ + global $langs, $conf; + + $langs->load("assets"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT . '/assets/admin/setup.php'; + $head[$h][1] = $langs->trans("Settings"); + $head[$h][2] = 'settings'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); + + $head[$h][0] = DOL_URL_ROOT . '/assets/admin/assets_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove'); + + return $head; +} + +function AssetsPrepareHead() +{ + global $langs, $conf; + + $langs->load("assets"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT . '/assets/card.php'; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets'); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT.'/assets/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'documents'; + $h++; + + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/assets/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Notes"); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/assets/info.php?id=' . $object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets', 'remove'); + + return $head; +} diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 204af818d20..ccfac2c72e2 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -14,7 +14,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('propal|commande|fournisseur|contrat|ficheinter', '$conf->propal->enabled || $conf->commande->enabled || $conf->supplier_order->enabled || $conf->contrat->enabled || $conf->ficheinter->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('facture|don|tax|salaries|loan|banque', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->facture->lire|| $user->rights->don->lire || $user->rights->tax->charges->lire || $user->rights->salaries->read || $user->rights->loan->read || $user->rights->banque->lire', '', 2, 50, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('banque|prelevement', '$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/list.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 0, 52, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'Accountancy', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire', '', 2, 54, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|assets', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->assets->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'Accountancy', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->assets->read', '', 2, 54, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); @@ -275,6 +275,10 @@ 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->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2714__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->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->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2715__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __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->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2716__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); +-- Assets +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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'Assets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'NewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accounactancy', 'List', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); -- Check deposit 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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 69f98710b93..1b11cd7db07 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -380,12 +380,13 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank"; if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports"; if ($objp->nature == 1) $nature="various"; + if ($objp->nature == 8) $nature="inventory"; if ($objp->nature == 9) $nature="hasnew"; // To enable when page exists if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - if ($nature == 'various' || $nature == 'hasnew') $nature=''; + if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') $nature=''; } if ($nature) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0fe22806568..a34a67f0e19 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -188,9 +188,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $menuqualified=0; if (! empty($conf->comptabilite->enabled)) $menuqualified++; if (! empty($conf->accounting->enabled)) $menuqualified++; + if (! empty($conf->assets->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->assets->read)), 'module'=>'comptabilite|accounting'); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -986,15 +987,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52); } if (! empty($conf->tax->enabled)) { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53); } if (! empty($conf->expensereport->enabled)) { - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54); } if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60); @@ -1002,14 +1003,14 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 1) // Not yet used. In a future will lock some periods. { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); } // Binding if (! empty($conf->facture->enabled)) { $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("Binded"),2,$user->rights->accounting->bind->write); } if (! empty($conf->supplier_invoice->enabled)) @@ -1075,8 +1076,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } else { - // Should not happend. Entries are added - $newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); + // Should not happend. Entries are added + $newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); } } else dol_print_error($db); @@ -1135,6 +1136,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report",$langs->trans("SellsJournal"),1,$user->rights->compta->resultat->lire, '', '', '', 50); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report",$langs->trans("PurchasesJournal"),1,$user->rights->compta->resultat->lire, '', '', '', 51); } + + // Assets + if (! empty($conf->assets->enabled)) + { + $langs->load("assets"); + $newmenu->add("/assets/list.php?leftmenu=assets&mainmenu=accountancy",$langs->trans("Assets"), 0, $user->rights->assets->read, '', $mainmenu, 'assets'); + $newmenu->add("/assets/card.php?leftmenu=assets&action=create",$langs->trans("NewAsset"), 1, $user->rights->assets->write); + $newmenu->add("/assets/list.php?leftmenu=assets",$langs->trans("List"), 1, $user->rights->assets->read); + } } diff --git a/htdocs/core/modules/modAssets.class.php b/htdocs/core/modules/modAssets.class.php new file mode 100644 index 00000000000..84aed4669a2 --- /dev/null +++ b/htdocs/core/modules/modAssets.class.php @@ -0,0 +1,261 @@ + + * Copyright (C) 2018 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 . + */ + +/** + * \defgroup assets Module Assets + * \brief Assets module descriptor. + * + * \file htdocs/core/modules/modAssets.class.php + * \ingroup assets + * \brief Description and activation file for module Assets + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +// The class name should start with a lower case mod for Dolibarr to pick it up +// so we ignore the Squiz.Classes.ValidClassName.NotCamelCaps rule. +// @codingStandardsIgnoreStart +/** + * Description and activation class for module FixedAssets + */ +class modAssets extends DolibarrModules +{ + // @codingStandardsIgnoreEnd + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 51000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'assets'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' + // It is used to group modules by family in module setup page + $this->family = "financial"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + + // Module label (no space allowed), used if translation string 'ModuleAssetsName' not found (MyModue is name of module). + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleAssetsDesc' not found (MyModue is name of module). + $this->description = "Assets module"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Assets module to manage assets module and depreciation charge on Dolibarr"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'development'; + // Key used in llx_const table to save module status enabled/disabled (where ASSETS is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='generic'; + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /assets/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /assets/core/modules/barcode) + // for specific css file (eg: /assets/css/assets.css.php) + $this->module_parts = array(); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/assets/temp","/assets/subdir"); + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@assets"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->langfiles = array("assets"); + $this->phpmin = array(5,3); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'AssetsWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('ASSETS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + 1=>array('ASSETS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + + + if (! isset($conf->assets) || ! isset($conf->assets->enabled)) + { + $conf->assets=new stdClass(); + $conf->assets->enabled=0; + } + + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@assets:$user->rights->assets->read:/assets/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@assets:$user->rights->othermodule->read:/assets/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + + // Dictionaries + $this->dictionaries=array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@assets', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Table1","Table2","Table3"), // Label of tables + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order + 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->assets->enabled,$conf->assets->enabled,$conf->assets->enabled) // Condition to show each dictionary + ); + */ + + + // Boxes/Widgets + // Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget. + $this->boxes = array( + //0=>array('file'=>'assetswidget1.php@assets','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'assetswidget2.php@assets','note'=>'Widget provided by Assets'), + //2=>array('file'=>'assetswidget3.php@assets','note'=>'Widget provided by Assets') + ); + + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/assets/class/assets.class.php', 'objectname'=>'Assets', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) + ); + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) + // ); + + + // Permissions + $this->rights = array(); // Permission array used by this module + + $r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read assets'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update assets'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete assets'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + + // Exports + $r=1; + + /* + $langs->load("fixedassets@fixedassets"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='FixedAssetsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='fixedassets@fixedassets'; + $keyforclass = 'FixedAssets'; $keyforclassfile='/mymobule/class/fixedassets.class.php'; $keyforelement='fixedassets'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='fixedassets'; $keyforaliasextra='extra'; $keyforelement='fixedassets'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fixedassets as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('fixedassets').')'; + $r++; */ + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + global $conf; + + // Permissions + $this->remove($options); + + $sql = array(); + + return $this->_init($sql,$options); + } + +} diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index f6fd8ff5539..86ce4580d9e 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -5,7 +5,7 @@ -- Copyright (C) 2004 Guillaume Delecourt -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin --- Copyright (C) 2011-2017 Alexandre Spangaro +-- Copyright (C) 2011-2018 Alexandre Spangaro -- Copyright (C) 2015-2017 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify @@ -35,6 +35,7 @@ INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'Other Journal', 1, 1, 1); INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'Has new Journal', 9, 1, 1); INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'Expense Report Journal', 5, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'Inventory Journal' , 8, 1, 1); -- Description of chart of account FR PCG99-ABREGE 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 92a58472700..2065b35d438 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 @@ -335,3 +335,37 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u ALTER TABLE llx_product ADD COLUMN fk_default_warehouse integer DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); +-- Assets +CREATE TABLE llx_assets( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + amount double(24,8) DEFAULT NULL, + fk_soc integer, + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp NOT NULL, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_assets ADD INDEX idx_assets_rowid (rowid); +ALTER TABLE llx_assets ADD INDEX idx_assets_ref (ref); +ALTER TABLE llx_assets ADD INDEX idx_assets_entity (entity); +ALTER TABLE llx_assets ADD INDEX idx_assets_fk_soc (fk_soc); +ALTER TABLE llx_assets ADD INDEX idx_assets_status (status); + +create table llx_assets_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; + +INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1); diff --git a/htdocs/install/mysql/tables/llx_assets.key.sql b/htdocs/install/mysql/tables/llx_assets.key.sql new file mode 100644 index 00000000000..495a092244b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + + +ALTER TABLE llx_assets ADD INDEX idx_assets_rowid (rowid); +ALTER TABLE llx_assets ADD INDEX idx_assets_ref (ref); +ALTER TABLE llx_assets ADD INDEX idx_assets_entity (entity); +ALTER TABLE llx_assets ADD INDEX idx_assets_fk_soc (fk_soc); +ALTER TABLE llx_assets ADD INDEX idx_assets_status (status); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_assets.sql b/htdocs/install/mysql/tables/llx_assets.sql new file mode 100644 index 00000000000..1e72664be95 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets.sql @@ -0,0 +1,33 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + + +CREATE TABLE llx_assets( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + amount double(24,8) DEFAULT NULL, + fk_soc integer, + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp NOT NULL, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_assets_extrafields.sql b/htdocs/install/mysql/tables/llx_assets_extrafields.sql new file mode 100644 index 00000000000..dad66c47456 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + +create table llx_assets_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index fe593919be1..7cef35ea5f0 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -235,11 +235,12 @@ AccountingJournal=Accounting journal NewAccountingJournal=New accounting journal ShowAccoutingJournal=Show accounting journal Nature=Nature -AccountingJournalType1=Miscellaneous operation +AccountingJournalType1=Miscellaneous operations AccountingJournalType2=Sales AccountingJournalType3=Purchases AccountingJournalType4=Bank AccountingJournalType5=Expenses report +AccountingJournalType8=Inventory AccountingJournalType9=Has-new ErrorAccountingJournalIsAlreadyUse=This journal is already use AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu %s - %s diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang new file mode 100644 index 00000000000..8c9e28023ae --- /dev/null +++ b/htdocs/langs/en_US/assets.lang @@ -0,0 +1,39 @@ +# Copyright (C) 2018 Alexandre Spangaro +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# 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 . + +# +# Generic +# +Assets = Assets +NewAsset = New asset + +# Module label 'ModuleAssetsName' +ModuleAssetsName = Assets +# Module description 'ModuleAssetsDesc' +ModuleAssetsDesc = Assets description + +# +# Admin page +# +AssetsSetup = Assets setup +Settings = Settings +AssetsSetupPage = Assets setup page + +# +# Menu +# +MenuAssets = Assets +MenuNewAsset = New asset +MenuListAssets = List From 3799713c049a53f86a2aacee19bca98ad503711a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 2 Apr 2018 06:27:55 +0200 Subject: [PATCH 35/84] Update works --- htdocs/assets/card.php | 200 ++++++++---------------- htdocs/assets/class/assets.class.php | 166 +++++++++----------- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/langs/en_US/assets.lang | 3 + 4 files changed, 144 insertions(+), 227 deletions(-) diff --git a/htdocs/assets/card.php b/htdocs/assets/card.php index c18f628b296..4424ca0cf93 100644 --- a/htdocs/assets/card.php +++ b/htdocs/assets/card.php @@ -22,20 +22,6 @@ * \brief Page to create/edit/view assets */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; @@ -46,9 +32,9 @@ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); $langs->loadLangs(array("assets")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -66,7 +52,7 @@ $search_all=trim(GETPOST("search_all",'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } if (empty($action) && empty($id) && empty($ref)) $action='view'; @@ -186,7 +172,7 @@ if (($id || $ref) && $action == 'edit') print load_fiche_titre($langs->trans("Assets")); print '
'; - print ''; + print ''; print ''; print ''; print ''; @@ -225,28 +211,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); } // Confirmation of action xxxx if ($action == 'xxx') { - $formquestion=array(); - /* - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); - }*/ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + $formquestion=array(); + /* + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + }*/ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } if (! $formconfirm) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; } // Print form confirm @@ -264,47 +250,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->assets->creer) - { - if ($action != 'classify') - { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - } */ $morehtmlref.='
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; print '
'; print '
'; @@ -329,91 +279,77 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Buttons for actions if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - { - // Send - print '' . $langs->trans('SendMail') . ''."\n"; + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; - if ($user->rights->assets->write) - { - print ''.$langs->trans("Modify").''."\n"; - } - else - { - print ''.$langs->trans('Modify').''."\n"; - } + if ($user->rights->assets->write) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } - /* - if ($user->rights->assets->create) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; - } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ - - if ($user->rights->assets->delete) - { - print ''.$langs->trans('Delete').''."\n"; - } - else - { - print ''.$langs->trans('Delete').''."\n"; - } - } - print '
'."\n"; + if ($user->rights->assets->delete) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; } // Select mail models is same action as presend if (GETPOST('modelselected')) { - $action = 'presend'; + $action = 'presend'; } if ($action != 'presend') { - print '
'; - print ''; // ancre + print '
'; + print ''; // ancre - // Documents - /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->assets->dir_output . '/' . $objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->assets->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->assets->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('assets', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + // Documents + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->assets->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->assets->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->assets->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('assets', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('assets')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('assets')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
'; + print '
'; - $MAXEVENT = 10; + $MAXEVENT = 10; - $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'assets', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'assets', $socid, 1, '', $MAXEVENT, '', $morehtmlright); - print '
'; + print '
'; } //Select mail models is same action as presend diff --git a/htdocs/assets/class/assets.class.php b/htdocs/assets/class/assets.class.php index 69b94cc3fd8..efacac10822 100644 --- a/htdocs/assets/class/assets.class.php +++ b/htdocs/assets/class/assets.class.php @@ -75,14 +75,14 @@ class Assets extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), + 'ref' => array('type'=>'varchar(10)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",), 'amount' => array('type'=>'double(24,8)', 'label'=>'Amount', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), - 'description' => array('type'=>'text', 'label'=>'Descrption', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), @@ -106,8 +106,6 @@ class Assets extends CommonObject public $import_key; public $status; - - // If this object has a subtable with lines /** @@ -131,8 +129,6 @@ class Assets extends CommonObject */ //public $lines = array(); - - /** * Constructor * @@ -170,43 +166,42 @@ class Assets extends CommonObject public function createFromClone(User $user, $fromid) { global $hookmanager, $langs; - $error = 0; + $error = 0; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $object = new self($this->db); + $object = new self($this->db); - $this->db->begin(); + $this->db->begin(); - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; - // Create clone + // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -264,50 +259,50 @@ class Assets extends CommonObject /** * Return a link to the object card (with optionaly the picto) * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL */ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("Assets") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = '' . $langs->trans("Asset") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; + $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowAssets"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowAssets"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); $linkstart = ''; @@ -325,8 +320,8 @@ class Assets extends CommonObject /** * Retourne le libelle du status d'un user (actif, inactif) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status */ function getLibStatut($mode=0) { @@ -336,9 +331,9 @@ class Assets extends CommonObject /** * Return the status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ static function LibStatut($status,$mode=0) { @@ -463,23 +458,6 @@ class Assets extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - // ... - return 0; } -} - -/** - * Class AssetsLine. You can also remove this and generate a CRUD class for lines objects. - */ -/* -class AssetsLine -{ - // @var int ID - public $id; - // @var mixed Sample line property 1 - public $prop1; - // @var mixed Sample line property 2 - public $prop2; -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index ccfac2c72e2..179421d372f 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -278,7 +278,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Assets 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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'Assets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'NewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accounactancy', 'List', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'List', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); -- Check deposit 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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index 8c9e28023ae..ea8cc2a149a 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -18,6 +18,9 @@ # Assets = Assets NewAsset = New asset +AccountancyAccountAsset = Accounting code (asset) +AccountancyAccountDepreciationAsset = Accounting code (depreciation asset account) +AccountancyAccountDepreciationExpense = Accounting code (depreciation expense account) # Module label 'ModuleAssetsName' ModuleAssetsName = Assets From 3779b6ff1c4aab539f75958e617d24e6bdb12f00 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 2 Apr 2018 08:22:26 +0200 Subject: [PATCH 36/84] Update work on assets type --- .../assets/admin/assets_type_extrafields.php | 113 +++ htdocs/assets/type.php | 778 ++++++++++++++++++ htdocs/core/lib/assets.lib.php | 5 + htdocs/core/menus/init_menu_auguria.sql | 7 +- htdocs/core/menus/standard/eldy.lib.php | 7 +- .../install/mysql/migration/7.0.0-8.0.0.sql | 31 + .../mysql/tables/llx_assets_type.key.sql | 16 + .../install/mysql/tables/llx_assets_type.sql | 27 + .../llx_assets_type_extrafields.key.sql | 17 + .../tables/llx_assets_type_extrafields.sql | 23 + htdocs/langs/en_US/assets.lang | 6 + 11 files changed, 1024 insertions(+), 6 deletions(-) create mode 100644 htdocs/assets/admin/assets_type_extrafields.php create mode 100644 htdocs/assets/type.php create mode 100644 htdocs/install/mysql/tables/llx_assets_type.key.sql create mode 100644 htdocs/install/mysql/tables/llx_assets_type.sql create mode 100644 htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_assets_type_extrafields.sql diff --git a/htdocs/assets/admin/assets_type_extrafields.php b/htdocs/assets/admin/assets_type_extrafields.php new file mode 100644 index 00000000000..8d136ed1278 --- /dev/null +++ b/htdocs/assets/admin/assets_type_extrafields.php @@ -0,0 +1,113 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** +/** + * \file htdocs/assets/admin/assets_type_extrafields.php + * \ingroup assets + * \brief Page to setup extra fields type of assets + */ +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("assets"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='adherent_type'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("AssetsTypes"); + +llxHeader('',$langs->trans("AssetsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); + + +$head = AssetsAdminPrepareHead(); + +dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), 0, 'generic'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/assets/type.php b/htdocs/assets/type.php new file mode 100644 index 00000000000..48df382181d --- /dev/null +++ b/htdocs/assets/type.php @@ -0,0 +1,778 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/adherents/type.php + * \ingroup member + * \brief Member's type setup + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("members"); + +$rowid = GETPOST('rowid','int'); +$action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); +$backtopage = GETPOST('backtopage','alpha'); + +$search_lastname = GETPOST('search_lastname','alpha'); +$search_login = GETPOST('search_login','alpha'); +$search_email = GETPOST('search_email','alpha'); +$type = GETPOST('type','alpha'); +$status = GETPOST('status','alpha'); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) { $sortorder="DESC"; } +if (! $sortfield) { $sortfield="d.lastname"; } + +$label=GETPOST("label","alpha"); +$subscription=GETPOST("subscription","int"); +$vote=GETPOST("vote","int"); +$comment=GETPOST("comment"); +$mail_valid=GETPOST("mail_valid"); + +// Security check +$result=restrictedArea($user,'adherent',$rowid,'adherent_type'); + +$object = new AdherentType($db); + +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); + +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers +{ + $search_lastname=""; + $search_login=""; + $search_email=""; + $type=""; + $sall=""; +} + + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('membertypecard','globalcard')); + + +/* + * Actions + */ + +if ($cancel) { + + $action=''; + + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } +} + +if ($action == 'add' && $user->rights->adherent->configurer) +{ + $object->label = trim($label); + $object->subscription = (int) trim($subscription); + $object->note = trim($comment); + $object->mail_valid = trim($mail_valid); + $object->vote = (boolean) trim($vote); + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + if ($ret < 0) $error++; + + if (empty($object->label)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); + } + else { + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors'); + } + } + + if (! $error) + { + $id=$object->create($user); + if ($id > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; + } + } + else + { + $action = 'create'; + } +} + +if ($action == 'update' && $user->rights->adherent->configurer) +{ + $object->fetch($rowid); + + $object->oldcopy = clone $object; + + $object->label = trim($label); + $object->subscription = (int) trim($subscription); + $object->note = trim($comment); + $object->mail_valid = trim($mail_valid); + $object->vote = (boolean) trim($vote); + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + if ($ret < 0) $error++; + + $ret=$object->update($user); + + if ($ret >= 0 && ! count($object->errors)) + { + setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + + header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id); + exit; +} + +if ($action == 'confirm_delete' && $user->rights->adherent->configurer) +{ + $object->fetch($rowid); + $res=$object->delete(); + + if ($res > 0) + { + setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); + $action=''; + } +} + + +/* + * View + */ + +$form=new Form($db); + +llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + + +// List of members type +if (! $rowid && $action != 'create' && $action != 'edit') +{ + //dol_fiche_head(''); + + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $nbtotalofrecords = $num; + + $i = 0; + + $param = ''; + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + + $moreforfilter = ''; + + print '
'; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $membertype = new AdherentType($db); + + while ($i < $num) + { + $objp = $db->fetch_object($result); + + $membertype->id = $objp->rowid; + $membertype->ref = $objp->rowid; + $membertype->label = $objp->rowid; + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($user->rights->adherent->configurer) + print ''; + else + print ''; + print ""; + $i++; + } + print "
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("SubscriptionRequired").''.$langs->trans("VoteAllowed").' 
'; + print $membertype->getNomUrl(1); + //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' + print ''.dol_escape_htmltag($objp->label).''.yn($objp->subscription).''.yn($objp->vote).'rowid.'">'.img_edit().' 
"; + print '
'; + + print '
'; + } + else + { + dol_print_error($db); + } +} + + +/* ************************************************************************** */ +/* */ +/* Creation mode */ +/* */ +/* ************************************************************************** */ +if ($action == 'create') +{ + $object = new AdherentType($db); + + print load_fiche_titre($langs->trans("NewMemberType")); + + print '
'; + print ''; + print ''; + + dol_fiche_head(''); + + print ''; + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + print ''; + print "
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; + print $form->selectyesno("subscription",1,1); + print '
'.$langs->trans("VoteAllowed").''; + print $form->selectyesno("vote",0,1); + print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("WelcomeEMail").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); + $doleditor->Create(); + print '
\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print "
\n"; +} + +/* ************************************************************************** */ +/* */ +/* View mode */ +/* */ +/* ************************************************************************** */ +if ($rowid > 0) +{ + if ($action != 'edit') + { + $object = new AdherentType($db); + $object->fetch($rowid); + $object->fetch_optionals(); + + /* + * Confirmation suppression + */ + if ($action == 'delete') + { + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1); + } + + $head = member_type_prepare_head($object); + + dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'rowid', $linkback); + + print '
'; + print '
'; + + print ''; + + print ''; + + print ''; + + print '"; + + print '"; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("SubscriptionRequired").''; + print yn($object->subscription); + print '
'.$langs->trans("VoteAllowed").''; + print yn($object->vote); + print '
'.$langs->trans("Description").''; + print nl2br($object->note)."
'.$langs->trans("WelcomeEMail").''; + print nl2br($object->mail_valid)."
'; + print '
'; + + dol_fiche_end(); + + /* + * Buttons + */ + + print '
'; + + // Edit + if ($user->rights->adherent->configurer) + { + print ''; + } + + // Add + print ''; + + // Delete + if ($user->rights->adherent->configurer) + { + print ''; + } + + print "
"; + + + // Show list of members (nearly same code than in page list.php) + + $membertypestatic=new AdherentType($db); + + $now=dol_now(); + + $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, "; + $sql.= " d.datefin,"; + $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; + $sql.= " t.libelle as type, t.subscription"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql.= " WHERE d.fk_adherent_type = t.rowid "; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; + $sql.= " AND t.rowid = ".$object->id; + if ($sall) + { + $sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall); + } + if ($status != '') + { + $sql.= natural_search('d.statut', $status, 2); + } + if ($action == 'search') + { + if (GETPOST('search','alpha')) + { + $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha')); + } + } + if (! empty($search_lastname)) + { + $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname); + } + if (! empty($search_login)) + { + $sql.= natural_search("d.login", $search_login); + } + if (! empty($search_email)) + { + $sql.= natural_search("d.email", $search_email); + } + if ($filter == 'uptodate') + { + $sql.=" AND datefin >= '".$db->idate($now)."'"; + } + if ($filter == 'outofdate') + { + $sql.=" AND datefin < '".$db->idate($now)."'"; + } + // Count total nb of records + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($result); + else dol_print_error($db); + } + // Add order and limit + $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $titre=$langs->trans("MembersList"); + if ($status != '') + { + if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } + else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } + else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } + else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } + else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } + else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } + } + elseif ($action == 'search') + { + $titre=$langs->trans("MembersListQualified"); + } + + if ($type > 0) + { + $membertype=new AdherentType($db); + $result=$membertype->fetch($type); + $titre.=" (".$membertype->label.")"; + } + + $param="&rowid=".$object->id; + if (! empty($status)) $param.="&status=".$status; + if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; + if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; + if (! empty($search_login)) $param.="&search_login=".$search_login; + if (! empty($search_email)) $param.="&search_email=".$search_email; + if (! empty($filter)) $param.="&filter=".$filter; + + if ($sall) + { + print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } + + print '
'; + print ''; + + print '
'; + print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + + $moreforfilter = ''; + + print '
'; + print ''."\n"; + + // Lignes des champs de filtre + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print "\n"; + + print ''; + print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); + print "\n"; + + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($resql); + + $datefin=$db->jdate($objp->datefin); + + $adh=new Adherent($db); + $adh->lastname=$objp->lastname; + $adh->firstname=$objp->firstname; + + // Lastname + print ''; + if ($objp->societe != '') + { + print ''."\n"; + } + else + { + print ''."\n"; + } + + // Login + print "\n"; + + // Type + /*print ''; + */ + + // Moral/Physique + print "\n"; + + // EMail + print "\n"; + + // Statut + print '"; + + // Date end subscription + if ($datefin) + { + print ''; + } + else + { + print ''; + } + + // Actions + print '"; + + print "\n"; + $i++; + } + + print "
'; + print ''; + print ' '; + print ' '; + print ''; + print '  '; + print ''; + print '
'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).''.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'".$objp->login."'; + $membertypestatic->id=$objp->type_id; + $membertypestatic->label=$objp->type; + print $membertypestatic->getNomUrl(1,12); + print '".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email,0,0,1)."'; + print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); + print "'; + if ($datefin < dol_now() && $objp->statut > 0) + { + print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); + } + else + { + print dol_print_date($datefin,'day'); + } + print ''; + if ($objp->subscription == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print ''; + if ($user->rights->adherent->creer) + { + print ''.img_edit().''; + } + print ' '; + if ($user->rights->adherent->supprimer) + { + print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; + } + print "
\n"; + print '
'; + print '
'; + + if ($num > $conf->liste_limit) + { + print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); + } + } + else + { + dol_print_error($db); + } + + } + + /* ************************************************************************** */ + /* */ + /* Edition mode */ + /* */ + /* ************************************************************************** */ + + if ($action == 'edit') + { + $object = new AdherentType($db); + $object->fetch($rowid); + $object->fetch_optionals(); + + $head = member_type_prepare_head($object); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print '"; + + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + + print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; + print $form->selectyesno("subscription",$object->subscription,1); + print '
'.$langs->trans("VoteAllowed").''; + print $form->selectyesno("vote",$object->vote,1); + print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("WelcomeEMail").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%'); + $doleditor->Create(); + print "
'; + + // Extra field + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print '

'; + foreach($extrafields->attribute_label as $key=>$label) + { + if (isset($_POST["options_" . $key])) { + if (is_array($_POST["options_" . $key])) { + // $_POST["options"] is an array but following code expects a comma separated string + $value = implode(",", $_POST["options_" . $key]); + } else { + $value = $_POST["options_" . $key]; + } + } else { + $value = $adht->array_options["options_" . $key]; + } + print '\n"; + } + print '
'.$label.''; + print $extrafields->showInputField($key,$value); + print "


'; + } + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print "
"; + } +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/lib/assets.lib.php b/htdocs/core/lib/assets.lib.php index 07a749f9f75..cc9ea922854 100644 --- a/htdocs/core/lib/assets.lib.php +++ b/htdocs/core/lib/assets.lib.php @@ -55,6 +55,11 @@ function AssetsAdminPrepareHead() $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT . '/assets/admin/assets_type_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); + $head[$h][2] = 'attributes_type'; + $h++; + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove'); return $head; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 179421d372f..5414eed0592 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -276,9 +276,10 @@ 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->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2715__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __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->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2716__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); -- Assets -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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'Assets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'NewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'List', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/type.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); -- Check deposit 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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __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($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a34a67f0e19..d832f57ec9a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1141,9 +1141,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->assets->enabled)) { $langs->load("assets"); - $newmenu->add("/assets/list.php?leftmenu=assets&mainmenu=accountancy",$langs->trans("Assets"), 0, $user->rights->assets->read, '', $mainmenu, 'assets'); - $newmenu->add("/assets/card.php?leftmenu=assets&action=create",$langs->trans("NewAsset"), 1, $user->rights->assets->write); - $newmenu->add("/assets/list.php?leftmenu=assets",$langs->trans("List"), 1, $user->rights->assets->read); + $newmenu->add("/assets/list.php?leftmenu=assets&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->assets->read, '', $mainmenu, 'assets'); + $newmenu->add("/assets/card.php?leftmenu=assets&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->assets->write); + $newmenu->add("/assets/type.php?leftmenu=assets&action=create",$langs->trans("MenuTypeAssets"), 1, $user->rights->assets->write); + $newmenu->add("/assets/list.php?leftmenu=assets",$langs->trans("MenuListAssets"), 1, $user->rights->assets->read); } } 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 2065b35d438..4b33728f6f0 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 @@ -368,4 +368,35 @@ create table llx_assets_extrafields import_key varchar(14) ) ENGINE=innodb; +create table llx_assets_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + tms timestamp, + statut smallint NOT NULL DEFAULT 0, + label varchar(50) NOT NULL, + accountancy_code_asset varchar(32), + accountancy_code_depreciation_asset varchar(32), + accountancy_code_depreciation_expense varchar(32), + note text +)ENGINE=innodb; + +ALTER TABLE llx_assets_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); + +create table llx_assets_type_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_assets_type_extrafields ADD INDEX idx_assets_type_extrafields (fk_object); + INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1); + +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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/type.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); + diff --git a/htdocs/install/mysql/tables/llx_assets_type.key.sql b/htdocs/install/mysql/tables/llx_assets_type.key.sql new file mode 100644 index 00000000000..782ae72c083 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets_type.key.sql @@ -0,0 +1,16 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . + +ALTER TABLE llx_assets_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); diff --git a/htdocs/install/mysql/tables/llx_assets_type.sql b/htdocs/install/mysql/tables/llx_assets_type.sql new file mode 100644 index 00000000000..fe035083ad6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets_type.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . + +create table llx_assets_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + tms timestamp, + statut smallint NOT NULL DEFAULT 0, + label varchar(50) NOT NULL, + accountancy_code_asset varchar(32), + accountancy_code_depreciation_asset varchar(32), + accountancy_code_depreciation_expense varchar(32), + note text +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql b/htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql new file mode 100644 index 00000000000..461946b9819 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql @@ -0,0 +1,17 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . + + +ALTER TABLE llx_assets_type_extrafields ADD INDEX idx_assets_type_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_assets_type_extrafields.sql b/htdocs/install/mysql/tables/llx_assets_type_extrafields.sql new file mode 100644 index 00000000000..8fcb7c51d41 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_assets_type_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2018 Alexandre Spangaro +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . + +create table llx_assets_type_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/langs/en_US/assets.lang b/htdocs/langs/en_US/assets.lang index ea8cc2a149a..cd310e48333 100644 --- a/htdocs/langs/en_US/assets.lang +++ b/htdocs/langs/en_US/assets.lang @@ -33,10 +33,16 @@ ModuleAssetsDesc = Assets description AssetsSetup = Assets setup Settings = Settings AssetsSetupPage = Assets setup page +ExtraFieldsAssetsType = Complementary attributes (Assets type) +AssetsType=Asset type +AssetsTypeId=Asset type id +AssetsTypeLabel=Asset type label +AssetsTypes=Assets types # # Menu # MenuAssets = Assets MenuNewAsset = New asset +MenuTypeAssets = Type MenuListAssets = List From 9f7fcdc8bf59eaf041e7aa248002f8a5df9b9fbd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 2 Apr 2018 09:44:45 +0200 Subject: [PATCH 37/84] 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 38/84] 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 dd04dae652b41ddda2bbdb536192bc233dd0a8ef Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 2 Apr 2018 14:03:12 +0200 Subject: [PATCH 39/84] Update work --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 6 ------ 1 file changed, 6 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 4b33728f6f0..2e3938a27e5 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 @@ -394,9 +394,3 @@ create table llx_assets_type_extrafields ALTER TABLE llx_assets_type_extrafields ADD INDEX idx_assets_type_extrafields (fk_object); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1); - -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->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/type.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 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->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); - From b39f617863991e03bf9e32b7c35a6d6a406e7292 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Mon, 2 Apr 2018 15:29:58 +0100 Subject: [PATCH 40/84] 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 41/84] 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 42/84] 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 ''; print "\n"; -// Add js auto fill amount on paiement form -/* always on now -$var=! $var; -print ''; -print $langs->trans("JSOnPaimentBill"); -print ''; -print $form->selectyesno("INVOICE_AUTO_FILLJS",$conf->global->INVOICE_AUTO_FILLJS,1); -print ''; -print "\n"; -*/ - 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 43/84] 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 44/84] 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 45/84] 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 46/84] 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 47/84] 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 48/84] 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 49/84] 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 b9a91c667faa21dac469093c355aaddd80d4896b Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 27 Mar 2018 16:04:56 +0200 Subject: [PATCH 50/84] NEW : Add link between credit note invoice and origin --- htdocs/compta/facture/card.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d438c505a8d..2f49526d1cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -916,9 +916,9 @@ if (empty($reshook)) $id = $object->create($user); + $facture_source = new Facture($db); // fetch origin object if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) { - $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source)>0) { $fk_parent_line = 0; @@ -969,7 +969,6 @@ if (empty($reshook)) if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { - $facture_source = new Facture($db); // fetch origin object if not previously defined if ($facture_source->fetch($object->fk_facture_source)>0) { $totalpaye = $facture_source->getSommePaiement(); @@ -980,6 +979,20 @@ if (empty($reshook)) $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); } } + + // Add link between credit note and origin + if(! empty($object->fk_facture_source)) { + $facture_source->fetch($object->fk_facture_source); + } + $facture_source->fetchObjectLinked(); + + if(! empty($facture_source->linkedObjectsIds)) { + $linkedObjectIds = $facture_source->linkedObjectsIds; + $sourcetype = key($linkedObjectIds); + $fk_origin = current($facture_source->linkedObjectsIds[$sourcetype]); + + $object->add_object_linked($sourcetype, $fk_origin); + } } } From 1719b43909768420153df8aaa2771b3e55a1ee5d Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 4 Apr 2018 09:52:10 +0200 Subject: [PATCH 51/84] FIX : Travis --- 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 9b61272bb76b6e75448bcc0a10c8bd3e002e76b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20J?= Date: Wed, 4 Apr 2018 12:32:49 +0200 Subject: [PATCH 52/84] Fix CommandeFournisseur::getDispachedLines line ID & return quantity --- htdocs/fourn/class/fournisseur.commande.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3e7f275741d..ba38187b30d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1959,7 +1959,7 @@ class CommandeFournisseur extends CommonOrder // List of already dispatched lines $sql = "SELECT p.ref, p.label,"; $sql.= " e.rowid as warehouse_id, e.ref as entrepot,"; - $sql.= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; + $sql.= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; @@ -1977,7 +1977,15 @@ class CommandeFournisseur extends CommonOrder while ($i < $num) { $objp = $this->db->fetch_object($resql); - if ($objp) $ret[]=array('id'=>$objp->dispatchedlineid, 'productid'=>$objp->fk_product, 'warehouseid'=>$objp->warehouse_id); + if ($objp) + { + $ret[] = array( + 'id' => $objp->dispatchedlineid, + 'productid' => $objp->fk_product, + 'warehouseid' => $objp->warehouse_id, + 'qty' => $objp->qty, + ); + } $i++; } From 041a21e829c568e8d1cb32421dab42dc93fb3455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20J?= Date: Wed, 4 Apr 2018 14:05:50 +0200 Subject: [PATCH 53/84] Add tag @since --- htdocs/fourn/class/fournisseur.commande.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ba38187b30d..04e22501b95 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1948,6 +1948,8 @@ class CommandeFournisseur extends CommonOrder /** * Return array of dispathed lines waiting to be approved for this order + * + * @since 8.0 Return dispatched quantity (qty). * * @param int $status Filter on stats (-1 = no filter, 0 = lines draft to be approved, 1 = approved lines) * @return array Array of lines 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 54/84] 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 55/84] 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 56/84] 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 57/84] 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 58/84] 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 59/84] 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 60/84] 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 61/84] 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 62/84] 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 63/84] 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 64/84] 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 65/84] 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 66/84] 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 16ae46e64ce514f72397ac6ac1470c2415484870 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Thu, 5 Apr 2018 15:23:17 +0100 Subject: [PATCH 67/84] define module part to include external modules menus --- htdocs/core/class/conf.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a1d051440c3..66a6f165dba 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -502,6 +502,10 @@ class Conf // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. + //Module part to include external modules menus + if(!empty($this->modules_parts['menuforexternal'])) + foreach($this->modules_parts['menuforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",$key"; + // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2'; From 8cf56a5b9c44120241408041cf6a65f520ced49a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 16:29:37 +0200 Subject: [PATCH 68/84] 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 69/84] 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 70/84] 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'); + } /** From 619805c7a5cd8fd8a382f776e92b129f7ea12824 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 5 Apr 2018 20:40:41 +0200 Subject: [PATCH 71/84] Update works --- htdocs/assets/class/assets_type.class.php | 421 ++++++++++++++++++ htdocs/assets/type.php | 102 ++--- htdocs/core/menus/standard/eldy.lib.php | 4 +- .../install/mysql/tables/llx_assets_type.sql | 1 - 4 files changed, 472 insertions(+), 56 deletions(-) create mode 100644 htdocs/assets/class/assets_type.class.php diff --git a/htdocs/assets/class/assets_type.class.php b/htdocs/assets/class/assets_type.class.php new file mode 100644 index 00000000000..5dd727ee950 --- /dev/null +++ b/htdocs/assets/class/assets_type.class.php @@ -0,0 +1,421 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/assets/class/assets_type.class.php + * \ingroup assets + * \brief File of class to manage assets types + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** + * Class to manage assets type + */ +class AssetsType extends CommonObject +{ + public $table_element = 'assets_type'; + public $element = 'assets_type'; + public $picto = 'group'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + /** @var string Label */ + public $label; + /** @var string Accountancy code asset */ + public $accountancy_code_asset; + /** @var string Accountancy code depreciation asset */ + public $accountancy_code_depreciation_asset; + /** @var string Accountancy code depreciation expense */ + public $accountancy_code_depreciation_expense; + /** @var string Public note */ + public $note; + /** @var array Array of assets */ + public $assets=array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + + /** + * Fonction qui permet de creer le type d'immobilisation + * + * @param User $user User making creation + * @param int $notrigger 1=do not execute triggers, 0 otherwise + * @return int >0 if OK, < 0 if KO + */ + function create($user,$notrigger=0) + { + global $conf; + + $error=0; + + $this->label=trim($this->label); + + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."assets_type ("; + $sql.= "label"; + $sql.= ", entity"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->escape($this->label)."'"; + $sql.= ", ".$conf->entity; + $sql.= ")"; + + dol_syslog("Assets_type::create", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."assets_type"); + + $result = $this->update($user,1); + if ($result < 0) + { + $this->db->rollback(); + return -3; + } + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ASSETS_TYPE_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + /** + * Met a jour en base donnees du type + * + * @param User $user Object user making change + * @param int $notrigger 1=do not execute triggers, 0 otherwise + * @return int >0 if OK, < 0 if KO + */ + function update($user,$notrigger=0) + { + global $conf, $hookmanager; + + $error=0; + + $this->label=trim($this->label); + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."assets_type "; + $sql.= "SET "; + $sql.= "label = '".$this->db->escape($this->label) ."',"; + $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; + $sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; + $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; + $sql.= " WHERE rowid =".$this->id; + + $result = $this->db->query($sql); + if ($result) + { + $action='update'; + + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('assetstypedao')); + $parameters=array('assetstype'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ASSETS_TYPE_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); + return -$error; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + /** + * Fonction qui permet de supprimer le status de l'adherent + * + * @return int >0 if OK, 0 if not found, < 0 if KO + */ + function delete() + { + global $user; + + $error = 0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."assets_type"; + $sql.= " WHERE rowid = ".$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + // Call trigger + $result=$this->call_trigger('ASSETS_TYPE_DELETE',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -2; } + // End call triggers + + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } + } + + /** + * Fonction qui permet de recuperer le status de l'adherent + * + * @param int $rowid Id of member type to load + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid) + { + $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; + $sql .= " FROM ".MAIN_DB_PREFIX."assets_type as d"; + $sql .= " WHERE d.rowid = ".(int) $rowid; + + dol_syslog("Assets_type::fetch", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->label = $obj->label; + $this->accountancy_code_asset = $obj->accountancy_code_asset; + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; + $this->note = $obj->note; + } + + return 1; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + + /** + * Return list of assets' type + * + * @return array List of types of members + */ + function liste_array() + { + global $conf,$langs; + + $assetstypes = array(); + + $sql = "SELECT rowid, label as label"; + $sql.= " FROM ".MAIN_DB_PREFIX."assets_type"; + $sql.= " WHERE entity IN (".getEntity('assets_type').")"; + + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); + + $assetstypes[$obj->rowid] = $langs->trans($obj->label); + $i++; + } + } + } + else + { + print $this->db->error(); + } + return $assetstypes; + } + + /** + * Return array of Asset objects for asset type this->id (or all if this->id not defined) + * + * @param string $excludefilter Filter to exclude + * @param int $mode 0=Return array of asset instance + * 1=Return array of asset instance without extra data + * 2=Return array of assets id only + * @return mixed Array of assets or -1 on error + */ + function listAssetsForAssetsType($excludefilter='', $mode=0) + { + global $conf, $user; + + $ret=array(); + + $sql = "SELECT a.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."assets as a"; + $sql.= " WHERE a.entity IN (".getEntity('assets').")"; + $sql.= " AND a.fk_assets_type = ".$this->id; + if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; + + dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql)) + { + if (! array_key_exists($obj->rowid, $ret)) + { + if ($mode < 2) + { + $assetsstatic=new Assets($this->db); + if ($mode == 1) { + $assetsstatic->fetch($obj->rowid,'','','',false, false); + } else { + $assetsstatic->fetch($obj->rowid); + } + $ret[$obj->rowid]=$assetsstatic; + } + else $ret[$obj->rowid]=$obj->rowid; + } + } + + $this->db->free($resql); + + $this->assets=$ret; + + return $ret; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL + */ + function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) + { + global $langs; + + $result=''; + $label=$langs->trans("ShowTypeCard",$this->label); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); + $result .= $linkend; + + return $result; + } + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + global $conf, $user, $langs; + + // Initialize parameters + $this->id = 0; + $this->ref = 'ATSPEC'; + $this->specimen=1; + + $this->label='ASSETS TYPE SPECIMEN'; + $this->note='This is a note'; + + // Assets of this asset type is just me + $this->assets=array( + $user->id => $user + ); + } + +} diff --git a/htdocs/assets/type.php b/htdocs/assets/type.php index 48df382181d..e5326029cfc 100644 --- a/htdocs/assets/type.php +++ b/htdocs/assets/type.php @@ -1,10 +1,5 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Alexandre Spangaro +/* Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,18 +16,18 @@ */ /** - * \file htdocs/adherents/type.php - * \ingroup member - * \brief Member's type setup + * \file htdocs/assets/type.php + * \ingroup assets + * \brief Asset's type setup */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/assets_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("members"); +$langs->load("assets"); $rowid = GETPOST('rowid','int'); $action = GETPOST('action','alpha'); @@ -43,7 +38,6 @@ $search_lastname = GETPOST('search_lastname','alpha'); $search_login = GETPOST('search_login','alpha'); $search_email = GETPOST('search_email','alpha'); $type = GETPOST('type','alpha'); -$status = GETPOST('status','alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -63,14 +57,14 @@ $comment=GETPOST("comment"); $mail_valid=GETPOST("mail_valid"); // Security check -$result=restrictedArea($user,'adherent',$rowid,'adherent_type'); +$result=restrictedArea($user,'assets',$rowid,'assets_type'); -$object = new AdherentType($db); +$object = new AssetsType($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); +$extralabels=$extrafields->fetch_name_optionals_label('assets_type'); 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 { @@ -83,7 +77,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x', // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membertypecard','globalcard')); +$hookmanager->initHooks(array('assetstypecard','globalcard')); /* @@ -101,13 +95,13 @@ if ($cancel) { } } -if ($action == 'add' && $user->rights->adherent->configurer) +if ($action == 'add' && $user->rights->assets->write) { - $object->label = trim($label); - $object->subscription = (int) trim($subscription); - $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -118,7 +112,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); } else { - $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."assets_type WHERE label='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -150,17 +144,17 @@ if ($action == 'add' && $user->rights->adherent->configurer) } } -if ($action == 'update' && $user->rights->adherent->configurer) +if ($action == 'update' && $user->rights->assets->write) { $object->fetch($rowid); $object->oldcopy = clone $object; - $object->label = trim($label); - $object->subscription = (int) trim($subscription); - $object->note = trim($comment); - $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->label = trim($label); + $object->accountancy_code_asset = trim($accountancy_code_asset); + $object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset); + $object->accountancy_code_depreciation_expense = trim($accountancy_code_depreciation_expense); + $object->note = trim($comment); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -170,7 +164,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) if ($ret >= 0 && ! count($object->errors)) { - setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs'); + setEventMessages($langs->trans("AssetsTypeModified"), null, 'mesgs'); } else { @@ -181,20 +175,20 @@ if ($action == 'update' && $user->rights->adherent->configurer) exit; } -if ($action == 'confirm_delete' && $user->rights->adherent->configurer) +if ($action == 'confirm_delete' && $user->rights->assets->write) { $object->fetch($rowid); $res=$object->delete(); if ($res > 0) { - setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs'); + setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { - setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); + setEventMessages($langs->trans("AssetsTypeCanNotBeDeleted"), null, 'errors'); $action=''; } } @@ -205,18 +199,18 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) */ $form=new Form($db); - -llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +$helpurl=''; +llxHeader('',$langs->trans("AssetsTypeSetup"),$helpurl); -// List of members type +// List of assets type if (! $rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; + $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; + $sql.= " FROM ".MAIN_DB_PREFIX."assets_type as d"; + $sql.= " WHERE d.entity IN (".getEntity('assets_type').")"; $result = $db->query($sql); if ($result) @@ -237,7 +231,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("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); $moreforfilter = ''; @@ -252,19 +246,19 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ' '; print "\n"; - $membertype = new AdherentType($db); + $assetstype = new AssetsType($db); while ($i < $num) { $objp = $db->fetch_object($result); - $membertype->id = $objp->rowid; - $membertype->ref = $objp->rowid; - $membertype->label = $objp->rowid; + $assetstype->id = $objp->rowid; + $assetstype->ref = $objp->rowid; + $assetstype->label = $objp->rowid; print ''; print ''; - print $membertype->getNomUrl(1); + print $assetstype->getNomUrl(1); //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''.dol_escape_htmltag($objp->label).''; @@ -432,7 +426,7 @@ if ($rowid > 0) // Show list of members (nearly same code than in page list.php) - $membertypestatic=new AdherentType($db); + $assetstypestatic=new AdherentType($db); $now=dol_now(); @@ -514,9 +508,9 @@ if ($rowid > 0) if ($type > 0) { - $membertype=new AdherentType($db); - $result=$membertype->fetch($type); - $titre.=" (".$membertype->label.")"; + $assetstype=new AdherentType($db); + $result=$assetstype->fetch($type); + $titre.=" (".$assetstype->label.")"; } $param="&rowid=".$object->id; @@ -603,9 +597,9 @@ if ($rowid > 0) // Type /*print ''; - $membertypestatic->id=$objp->type_id; - $membertypestatic->label=$objp->type; - print $membertypestatic->getNomUrl(1,12); + $assetstypestatic->id=$objp->type_id; + $assetstypestatic->label=$objp->type; + print $assetstypestatic->getNomUrl(1,12); print ''; */ diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d832f57ec9a..6d9d78e656b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1143,7 +1143,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("assets"); $newmenu->add("/assets/list.php?leftmenu=assets&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->assets->read, '', $mainmenu, 'assets'); $newmenu->add("/assets/card.php?leftmenu=assets&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->assets->write); - $newmenu->add("/assets/type.php?leftmenu=assets&action=create",$langs->trans("MenuTypeAssets"), 1, $user->rights->assets->write); + $newmenu->add("/assets/type.php?leftmenu=assets",$langs->trans("MenuTypeAssets"), 1, $user->rights->assets->read, '', $mainmenu, 'assets_type'); + $newmenu->add("/assets/type.php?leftmenu=assets_type&action=create",$langs->trans("MenuNewTypeAssets"), 1, $user->rights->assets->write); + $newmenu->add("/assets/type.php?leftmenu=assets_type",$langs->trans("MenuListTypeAssets"), 1, $user->rights->assets->read); $newmenu->add("/assets/list.php?leftmenu=assets",$langs->trans("MenuListAssets"), 1, $user->rights->assets->read); } } diff --git a/htdocs/install/mysql/tables/llx_assets_type.sql b/htdocs/install/mysql/tables/llx_assets_type.sql index fe035083ad6..d637085488b 100644 --- a/htdocs/install/mysql/tables/llx_assets_type.sql +++ b/htdocs/install/mysql/tables/llx_assets_type.sql @@ -18,7 +18,6 @@ create table llx_assets_type rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, - statut smallint NOT NULL DEFAULT 0, label varchar(50) NOT NULL, accountancy_code_asset varchar(32), accountancy_code_depreciation_asset varchar(32), From 5d6d019fe7d39b764f2b49896775be956e31b5c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 00:21:40 +0200 Subject: [PATCH 72/84] Fix phpunit --- test/phpunit/FunctionsLibTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index da6fe60d787..e96cda7d6e5 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -830,8 +830,7 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $s=img_picto('title', 'delete', '', 0, 1); print __METHOD__." s=".$s."\n"; - $this->assertEquals('',$s,'testImgPicto3'); - + $this->assertEquals('/theme/eldy/img/delete.png',$s,'testImgPicto5'); } /** From 2524a699eb981e6bd6e4652c933e29cd881820df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 00:36:52 +0200 Subject: [PATCH 73/84] Standardize file name of lists --- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 8 ++++---- htdocs/core/menus/standard/eldy.lib.php | 8 ++++---- htdocs/core/search.php | 4 ++-- htdocs/expensereport/list.php | 2 +- htdocs/holiday/list.php | 2 +- htdocs/index.php | 2 +- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/bank.php | 4 ++-- htdocs/user/card.php | 2 +- htdocs/user/clicktodial.php | 2 +- htdocs/user/document.php | 2 +- htdocs/user/group/card.php | 2 +- htdocs/user/group/ldap.php | 2 +- htdocs/user/group/{index.php => list.php} | 2 +- htdocs/user/group/perms.php | 2 +- htdocs/user/hierarchy.php | 2 +- htdocs/user/info.php | 2 +- htdocs/user/ldap.php | 2 +- htdocs/user/{index.php => list.php} | 2 +- htdocs/user/note.php | 2 +- htdocs/user/notify/card.php | 2 +- htdocs/user/param_ihm.php | 4 ++-- htdocs/user/perms.php | 2 +- 24 files changed, 33 insertions(+), 33 deletions(-) rename htdocs/user/group/{index.php => list.php} (99%) rename htdocs/user/{index.php => list.php} (99%) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 4256d14f203..1bc527ff555 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -126,7 +126,7 @@ if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_ // HR if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { - $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); + $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); } if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index f98db95405b..e36404f75bc 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -63,9 +63,9 @@ 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 ('', '$leftmenu=="admintools"', __HANDLER__, 'left', 320__+MAX_llx_menu__, 'home', '', 300__+MAX_llx_menu__, '/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools', 'ProductVatMassChange', 1, 'products', '', '', 2, 15, __ENTITY__); -- Home - Menu users and groups insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/list.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 1, __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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/list.php?leftmenu=users', 'Groups', 1, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 1, __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 ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__); -- Third parties 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->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); @@ -345,9 +345,9 @@ 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->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5200__+MAX_llx_menu__, 'members', 'cat', 13__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=3', 'MembersCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __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->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5201__+MAX_llx_menu__, 'members', '', 5200__+MAX_llx_menu__, '/categories/card.php?action=create&type=3', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- HRM - Employee -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->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/index.php?leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->hrm->employee->read', '', 0, 1, __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->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->hrm->employee->read', '', 0, 1, __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->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->hrm->employee->write', '', 0, 1, __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->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/index.php?$leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __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->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?$leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __ENTITY__); -- HRM - Holiday 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->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __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->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 633f85e6094..3ffc4c4a10c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -599,11 +599,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, ($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home'); - $newmenu->add("/user/index.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); + $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); - $newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); + $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); } } @@ -1357,9 +1357,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("hrm"); - $newmenu->add("/user/index.php?leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); + $newmenu->add("/user/list.php?leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); $newmenu->add("/user/card.php?action=create&employee=1", $langs->trans("NewEmployee"), 1,$user->rights->hrm->employee->write); - $newmenu->add("/user/index.php?leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1,$user->rights->hrm->employee->read); + $newmenu->add("/user/list.php?leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1,$user->rights->hrm->employee->read); } // Leave/Holiday/Vacation module diff --git a/htdocs/core/search.php b/htdocs/core/search.php index 05b03064096..e1be41b36ac 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -132,12 +132,12 @@ if (GETPOST('search_task') != '') if (GETPOST('search_user') != '') { - header("Location: ".DOL_URL_ROOT.'/user/index.php?mode=search&sall='.urlencode(GETPOST('search_user'))); + header("Location: ".DOL_URL_ROOT.'/user/list.php?mode=search&sall='.urlencode(GETPOST('search_user'))); exit; } if (GETPOST('search_group') != '') { - header("Location: ".DOL_URL_ROOT.'/user/group/index.php?mode=search&sall='.urlencode(GETPOST('search_group'))); + header("Location: ".DOL_URL_ROOT.'/user/group/list.php?mode=search&sall='.urlencode(GETPOST('search_group'))); exit; } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index e358e69e453..54565932521 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -380,7 +380,7 @@ if ($resql) if ($id > 0) // For user tab { $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $head = user_prepare_head($fuser); dol_fiche_head($head, 'expensereport', $title, -1, 'user'); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index e00c182f949..cc5bb9bb55b 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -342,7 +342,7 @@ if ($id > 0) print ''; if ($id > 0) // For user tab { $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $head = user_prepare_head($fuser); dol_fiche_head($head, 'paidholidays', $title, -1, 'user'); diff --git a/htdocs/index.php b/htdocs/index.php index 29e716d31ad..99b5f1ade7d 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -262,7 +262,7 @@ if (empty($user->societe_id)) ); // Dashboard Link lines $links=array( - DOL_URL_ROOT.'/user/index.php', + DOL_URL_ROOT.'/user/list.php', DOL_URL_ROOT.'/societe/list.php?type=c&mainmenu=companies', DOL_URL_ROOT.'/societe/list.php?type=p&mainmenu=companies', DOL_URL_ROOT.'/societe/list.php?type=f&mainmenu=companies', diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index c39dbaafc97..ced0e759f31 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -158,7 +158,7 @@ dol_fiche_head($head, 'extsites', $langs->trans("User"), -1, 'user'); $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 0f26169adf3..9356828f884 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -200,7 +200,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); @@ -486,7 +486,7 @@ if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->u $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index db17f7eaab5..d711fd8b4b4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1240,7 +1240,7 @@ else $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } } diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 64919029536..51e4364e2ba 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -102,7 +102,7 @@ if ($id > 0) $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index b8fc923acae..5d89ef1b162 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -133,7 +133,7 @@ if ($object->id) $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index a8bc562d4a2..9110f758442 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -330,7 +330,7 @@ else { dol_fiche_head($head, 'group', $title, -1, 'group'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index baf30a02399..2deab4b56a2 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -105,7 +105,7 @@ $head = group_prepare_head($object); dol_fiche_head($head, 'ldap', $langs->trans("Group"), -1, 'group'); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/group/index.php b/htdocs/user/group/list.php similarity index 99% rename from htdocs/user/group/index.php rename to htdocs/user/group/list.php index fe68167f7a4..ba7b30c9ca8 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/user/group/index.php + * \file htdocs/user/group/list.php * \ingroup core * \brief Page of user groups */ diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index fd33d4d5427..ef5d286ca11 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -190,7 +190,7 @@ if ($object->id > 0) dol_print_error($db); } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index ec85428bcab..930e911afaa 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -64,7 +64,7 @@ $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css') llxHeader('',$langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')','','',0,0,$arrayofjs,$arrayofcss); -print load_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')', ''); +print load_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')', '
'); diff --git a/htdocs/user/info.php b/htdocs/user/info.php index d20624063f2..9e349675625 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -71,7 +71,7 @@ dol_fiche_head($head, 'info', $title, -1, 'user'); $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index c9bee3dd47c..79a1fd38bb5 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -100,7 +100,7 @@ dol_fiche_head($head, 'ldap', $title, 0, 'user'); $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/index.php b/htdocs/user/list.php similarity index 99% rename from htdocs/user/index.php rename to htdocs/user/list.php index 964ac2df367..4386b97ac8f 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/list.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/user/index.php + * \file htdocs/user/list.php * \ingroup core * \brief Page of users */ diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 0868c6435cf..2f027f38504 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -95,7 +95,7 @@ if ($id) $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 04e524cef92..096567d728a 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -139,7 +139,7 @@ if ($result > 0) dol_fiche_head($head, 'notify', $langs->trans("User"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', '', '', 0, '', '', 0, ''); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 7c59b3e8f34..c797a11ccad 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -187,7 +187,7 @@ if ($action == 'edit') $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); @@ -302,7 +302,7 @@ else { dol_fiche_head($head, 'guisetup', $title, -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 7c855e0c80f..77277b54102 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -239,7 +239,7 @@ else $linkback = ''; if ($user->rights->user->user->lire || $user->admin) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; } dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); From 3e66f5e25be6a30749e145cc2ae5264d64fd6fef Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 6 Apr 2018 06:04:03 +0200 Subject: [PATCH 74/84] Update works --- .../{assets.class.php => asset.class.php} | 0 ...ts_type.class.php => asset_type.class.php} | 122 +++---- htdocs/assets/type.php | 319 +++++++++--------- .../install/mysql/migration/7.0.0-8.0.0.sql | 28 +- .../{llx_assets.key.sql => llx_asset.key.sql} | 13 +- .../tables/{llx_assets.sql => llx_asset.sql} | 3 +- ...rafields.sql => llx_asset_extrafields.sql} | 2 +- ...ts_type.key.sql => llx_asset_type.key.sql} | 2 +- ...llx_assets_type.sql => llx_asset_type.sql} | 2 +- ...sql => llx_asset_type_extrafields.key.sql} | 2 +- ...lds.sql => llx_asset_type_extrafields.sql} | 2 +- 11 files changed, 246 insertions(+), 249 deletions(-) rename htdocs/assets/class/{assets.class.php => asset.class.php} (100%) rename htdocs/assets/class/{assets_type.class.php => asset_type.class.php} (72%) rename htdocs/install/mysql/tables/{llx_assets.key.sql => llx_asset.key.sql} (62%) rename htdocs/install/mysql/tables/{llx_assets.sql => llx_asset.sql} (95%) rename htdocs/install/mysql/tables/{llx_assets_extrafields.sql => llx_asset_extrafields.sql} (96%) rename htdocs/install/mysql/tables/{llx_assets_type.key.sql => llx_asset_type.key.sql} (89%) rename htdocs/install/mysql/tables/{llx_assets_type.sql => llx_asset_type.sql} (97%) rename htdocs/install/mysql/tables/{llx_assets_type_extrafields.key.sql => llx_asset_type_extrafields.key.sql} (88%) rename htdocs/install/mysql/tables/{llx_assets_type_extrafields.sql => llx_asset_type_extrafields.sql} (95%) diff --git a/htdocs/assets/class/assets.class.php b/htdocs/assets/class/asset.class.php similarity index 100% rename from htdocs/assets/class/assets.class.php rename to htdocs/assets/class/asset.class.php diff --git a/htdocs/assets/class/assets_type.class.php b/htdocs/assets/class/asset_type.class.php similarity index 72% rename from htdocs/assets/class/assets_type.class.php rename to htdocs/assets/class/asset_type.class.php index 5dd727ee950..9889ceeb5d1 100644 --- a/htdocs/assets/class/assets_type.class.php +++ b/htdocs/assets/class/asset_type.class.php @@ -16,21 +16,21 @@ */ /** - * \file htdocs/assets/class/assets_type.class.php + * \file htdocs/assets/class/asset_type.class.php * \ingroup assets - * \brief File of class to manage assets types + * \brief File of class to manage asset types */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** - * Class to manage assets type + * Class to manage asset type */ -class AssetsType extends CommonObject +class AssetType extends CommonObject { - public $table_element = 'assets_type'; - public $element = 'assets_type'; + public $table_element = 'asset_type'; + public $element = 'asset_type'; public $picto = 'group'; public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -44,8 +44,8 @@ class AssetsType extends CommonObject public $accountancy_code_depreciation_expense; /** @var string Public note */ public $note; - /** @var array Array of assets */ - public $assets=array(); + /** @var array Array of asset */ + public $asset=array(); /** @@ -76,7 +76,7 @@ class AssetsType extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."assets_type ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; $sql.= "label"; $sql.= ", entity"; $sql.= ") VALUES ("; @@ -84,11 +84,11 @@ class AssetsType extends CommonObject $sql.= ", ".$conf->entity; $sql.= ")"; - dol_syslog("Assets_type::create", LOG_DEBUG); + dol_syslog("Asset_type::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."assets_type"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type"); $result = $this->update($user,1); if ($result < 0) @@ -100,7 +100,7 @@ class AssetsType extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('ASSETS_TYPE_CREATE',$user); + $result=$this->call_trigger('ASSET_TYPE_CREATE',$user); if ($result < 0) { $error++; } // End call triggers } @@ -142,7 +142,7 @@ class AssetsType extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."assets_type "; + $sql = "UPDATE ".MAIN_DB_PREFIX."asset_type "; $sql.= "SET "; $sql.= "label = '".$this->db->escape($this->label) ."',"; $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; @@ -156,8 +156,8 @@ class AssetsType extends CommonObject $action='update'; // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('assetstypedao')); - $parameters=array('assetstype'=>$this->id); + $hookmanager->initHooks(array('assettypedao')); + $parameters=array('assettype'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { @@ -175,7 +175,7 @@ class AssetsType extends CommonObject if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('ASSETS_TYPE_MODIFY',$user); + $result=$this->call_trigger('ASSET_TYPE_MODIFY',$user); if ($result < 0) { $error++; } // End call triggers } @@ -211,14 +211,14 @@ class AssetsType extends CommonObject $error = 0; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."assets_type"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type"; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('ASSETS_TYPE_DELETE',$user); + $result=$this->call_trigger('ASSET_TYPE_DELETE',$user); if ($result < 0) { $error++; $this->db->rollback(); return -2; } // End call triggers @@ -234,7 +234,7 @@ class AssetsType extends CommonObject } /** - * Fonction qui permet de recuperer le status de l'adherent + * Fonction qui permet de recuperer le status de l'immobilisation * * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK @@ -242,10 +242,10 @@ class AssetsType extends CommonObject function fetch($rowid) { $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; - $sql .= " FROM ".MAIN_DB_PREFIX."assets_type as d"; + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; - dol_syslog("Assets_type::fetch", LOG_DEBUG); + dol_syslog("Asset_type::fetch", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -273,7 +273,7 @@ class AssetsType extends CommonObject } /** - * Return list of assets' type + * Return list of asset's type * * @return array List of types of members */ @@ -281,11 +281,11 @@ class AssetsType extends CommonObject { global $conf,$langs; - $assetstypes = array(); + $assettypes = array(); $sql = "SELECT rowid, label as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."assets_type"; - $sql.= " WHERE entity IN (".getEntity('assets_type').")"; + $sql.= " FROM ".MAIN_DB_PREFIX."asset_type"; + $sql.= " WHERE entity IN (".getEntity('asset_type').")"; $resql=$this->db->query($sql); if ($resql) @@ -299,7 +299,7 @@ class AssetsType extends CommonObject { $obj = $this->db->fetch_object($resql); - $assetstypes[$obj->rowid] = $langs->trans($obj->label); + $assettypes[$obj->rowid] = $langs->trans($obj->label); $i++; } } @@ -308,7 +308,7 @@ class AssetsType extends CommonObject { print $this->db->error(); } - return $assetstypes; + return $assettypes; } /** @@ -317,19 +317,19 @@ class AssetsType extends CommonObject * @param string $excludefilter Filter to exclude * @param int $mode 0=Return array of asset instance * 1=Return array of asset instance without extra data - * 2=Return array of assets id only - * @return mixed Array of assets or -1 on error + * 2=Return array of asset id only + * @return mixed Array of asset or -1 on error */ - function listAssetsForAssetsType($excludefilter='', $mode=0) + function listAssetForAssetType($excludefilter='', $mode=0) { global $conf, $user; $ret=array(); $sql = "SELECT a.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."assets as a"; - $sql.= " WHERE a.entity IN (".getEntity('assets').")"; - $sql.= " AND a.fk_assets_type = ".$this->id; + $sql.= " FROM ".MAIN_DB_PREFIX."asset as a"; + $sql.= " WHERE a.entity IN (".getEntity('asset').")"; + $sql.= " AND a.fk_asset_type = ".$this->id; if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); @@ -342,13 +342,13 @@ class AssetsType extends CommonObject { if ($mode < 2) { - $assetsstatic=new Assets($this->db); + $assetstatic=new Asset($this->db); if ($mode == 1) { - $assetsstatic->fetch($obj->rowid,'','','',false, false); + $assetstatic->fetch($obj->rowid,'','','',false, false); } else { - $assetsstatic->fetch($obj->rowid); + $assetstatic->fetch($obj->rowid); } - $ret[$obj->rowid]=$assetsstatic; + $ret[$obj->rowid]=$assetstatic; } else $ret[$obj->rowid]=$obj->rowid; } @@ -356,7 +356,7 @@ class AssetsType extends CommonObject $this->db->free($resql); - $this->assets=$ret; + $this->asset=$ret; return $ret; } @@ -367,31 +367,31 @@ class AssetsType extends CommonObject } } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL - */ - function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL + */ + function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) + { + global $langs; - $result=''; - $label=$langs->trans("ShowTypeCard",$this->label); + $result=''; + $label=$langs->trans("ShowTypeCard",$this->label); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); + $result .= $linkend; - return $result; - } + return $result; + } /** * Initialise an instance with random values. @@ -409,11 +409,11 @@ class AssetsType extends CommonObject $this->ref = 'ATSPEC'; $this->specimen=1; - $this->label='ASSETS TYPE SPECIMEN'; + $this->label='ASSET TYPE SPECIMEN'; $this->note='This is a note'; // Assets of this asset type is just me - $this->assets=array( + $this->asset=array( $user->id => $user ); } diff --git a/htdocs/assets/type.php b/htdocs/assets/type.php index e5326029cfc..51445f86254 100644 --- a/htdocs/assets/type.php +++ b/htdocs/assets/type.php @@ -23,8 +23,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/asset.class.php'; +require_once DOL_DOCUMENT_ROOT.'/assets/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("assets"); @@ -34,10 +34,7 @@ $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); -$search_lastname = GETPOST('search_lastname','alpha'); -$search_login = GETPOST('search_login','alpha'); -$search_email = GETPOST('search_email','alpha'); -$type = GETPOST('type','alpha'); +$type = GETPOST('type','alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -51,33 +48,27 @@ if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="d.lastname"; } $label=GETPOST("label","alpha"); -$subscription=GETPOST("subscription","int"); -$vote=GETPOST("vote","int"); $comment=GETPOST("comment"); -$mail_valid=GETPOST("mail_valid"); // Security check -$result=restrictedArea($user,'assets',$rowid,'assets_type'); +$result=restrictedArea($user,'assets',$rowid,'asset_type'); -$object = new AssetsType($db); +$object = new AssetType($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('assets_type'); +$extralabels=$extrafields->fetch_name_optionals_label('asset_type'); if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - $search_lastname=""; - $search_login=""; - $search_email=""; - $type=""; - $sall=""; + $type=""; + $sall=""; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('assetstypecard','globalcard')); +$hookmanager->initHooks(array('assettypecard','globalcard')); /* @@ -112,7 +103,7 @@ if ($action == 'add' && $user->rights->assets->write) setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors'); } else { - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."assets_type WHERE label='".$db->escape($object->label)."'"; + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."asset_type WHERE label='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -203,14 +194,14 @@ $helpurl=''; llxHeader('',$langs->trans("AssetsTypeSetup"),$helpurl); -// List of assets type +// List of asset type if (! $rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."assets_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('assets_type').")"; + $sql.= " FROM ".MAIN_DB_PREFIX."asset_type as d"; + $sql.= " WHERE d.entity IN (".getEntity('asset_type').")"; $result = $db->query($sql); if ($result) @@ -228,10 +219,10 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; - print ''; + print ''; print ''; - print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); $moreforfilter = ''; @@ -246,19 +237,19 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ' '; print "\n"; - $assetstype = new AssetsType($db); + $assettype = new AssetType($db); while ($i < $num) { $objp = $db->fetch_object($result); - $assetstype->id = $objp->rowid; - $assetstype->ref = $objp->rowid; - $assetstype->label = $objp->rowid; + $assettype->id = $objp->rowid; + $assettype->ref = $objp->rowid; + $assettype->label = $objp->rowid; print ''; print ''; - print $assetstype->getNomUrl(1); + print $assettype->getNomUrl(1); //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' print ''; print ''.dol_escape_htmltag($objp->label).''; @@ -298,7 +289,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(''); + dol_fiche_head(''); print ''; print ''; @@ -325,7 +316,7 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -426,17 +417,17 @@ if ($rowid > 0) // Show list of members (nearly same code than in page list.php) - $assetstypestatic=new AdherentType($db); + $assettypestatic=new AssetType($db); $now=dol_now(); - $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, "; + $sql = "SELECT a.rowid, d.login, d.firstname, d.lastname, d.societe, "; $sql.= " d.datefin,"; - $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; - $sql.= " t.libelle as type, t.subscription"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_adherent_type = t.rowid "; - $sql.= " AND d.entity IN (".getEntity('adherent').")"; + $sql.= " a.fk_asset_type as type_id,"; + $sql.= " t.label as type"; + $sql.= " FROM ".MAIN_DB_PREFIX."asset as a, ".MAIN_DB_PREFIX."asset_type as t"; + $sql.= " WHERE a.fk_asset_type = t.rowid "; + $sql.= " AND a.entity IN (".getEntity('asset').")"; $sql.= " AND t.rowid = ".$object->id; if ($sall) { @@ -444,7 +435,7 @@ if ($rowid > 0) } if ($status != '') { - $sql.= natural_search('d.statut', $status, 2); + $sql.= natural_search('d.statut', $status, 2); } if ($action == 'search') { @@ -467,19 +458,19 @@ if ($rowid > 0) } if ($filter == 'uptodate') { - $sql.=" AND datefin >= '".$db->idate($now)."'"; + $sql.=" AND datefin >= '".$db->idate($now)."'"; } if ($filter == 'outofdate') { - $sql.=" AND datefin < '".$db->idate($now)."'"; + $sql.=" AND datefin < '".$db->idate($now)."'"; } // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($result); - else dol_print_error($db); + if ($resql) $nbtotalofrecords = $db->num_rows($result); + else dol_print_error($db); } // Add order and limit $sql.= " ".$db->order($sortfield,$sortorder); @@ -488,54 +479,54 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $titre=$langs->trans("MembersList"); - if ($status != '') - { - if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } - else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } - } - elseif ($action == 'search') - { - $titre=$langs->trans("MembersListQualified"); - } + $titre=$langs->trans("AssetsList"); + if ($status != '') + { + if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); } + else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); } + else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } + else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } + else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } + else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); } + } + elseif ($action == 'search') + { + $titre=$langs->trans("MembersListQualified"); + } - if ($type > 0) - { - $assetstype=new AdherentType($db); - $result=$assetstype->fetch($type); - $titre.=" (".$assetstype->label.")"; - } + if ($type > 0) + { + $assettype=new AssetType($db); + $result=$assettype->fetch($type); + $titre.=" (".$assettype->label.")"; + } - $param="&rowid=".$object->id; - if (! empty($status)) $param.="&status=".$status; - if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; - if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; - if (! empty($search_login)) $param.="&search_login=".$search_login; - if (! empty($search_email)) $param.="&search_email=".$search_email; - if (! empty($filter)) $param.="&filter=".$filter; + $param="&rowid=".$object->id; + if (! empty($status)) $param.="&status=".$status; + if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname; + if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname; + if (! empty($search_login)) $param.="&search_login=".$search_login; + if (! empty($search_email)) $param.="&search_email=".$search_email; + if (! empty($filter)) $param.="&filter=".$filter; - if ($sall) - { - print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } + if ($sall) + { + print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } print ''; print ''; print '
'; - print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); - $moreforfilter = ''; + $moreforfilter = ''; - print '
'; - print '
'."\n"; + print '
'; + print '
'."\n"; // Lignes des champs de filtre print ''; @@ -555,96 +546,96 @@ if ($rowid > 0) print ''; print "\n"; print ''; - print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); - print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); - print "\n"; + print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); + print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); + print "\n"; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($resql); + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); + $datefin=$db->jdate($objp->datefin); - $adh=new Adherent($db); - $adh->lastname=$objp->lastname; - $adh->firstname=$objp->firstname; + $adh=new Adherent($db); + $adh->lastname=$objp->lastname; + $adh->firstname=$objp->firstname; - // Lastname - print ''; - if ($objp->societe != '') - { - print ''."\n"; - } - else - { - print ''."\n"; - } + // Lastname + print ''; + if ($objp->societe != '') + { + print ''."\n"; + } + else + { + print ''."\n"; + } - // Login - print "\n"; + // Login + print "\n"; - // Type - /*print ''; + // Type + /*print ''; */ - // Moral/Physique - print "\n"; + // Moral/Physique + print "\n"; - // EMail - print "\n"; + // EMail + print "\n"; - // Statut - print '"; + // Statut + print '"; - // Date end subscription - if ($datefin) - { - print ''; - } - else - { - print ''; - } + // Date end subscription + if ($datefin) + { + print ''; + } + else + { + print ''; + } - // Actions - print '"; - print "\n"; - $i++; - } + print "\n"; + $i++; + } - print "
'; print ''; - print '  '; - print ''; + print '  '; + print ''; print '
'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).''.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'
'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).''.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'".$objp->login."".$objp->login."'; - $assetstypestatic->id=$objp->type_id; - $assetstypestatic->label=$objp->type; - print $assetstypestatic->getNomUrl(1,12); - print ''; + $assettypestatic->id=$objp->type_id; + $assettypestatic->label=$objp->type; + print $assettypestatic->getNomUrl(1,12); + print '".$adh->getmorphylib($objp->morphy)."".$adh->getmorphylib($objp->morphy)."".dol_print_email($objp->email,0,0,1)."".dol_print_email($objp->email,0,0,1)."'; - print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); - print "'; + print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2); + print "'; - if ($datefin < dol_now() && $objp->statut > 0) - { - print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); - } - else - { - print dol_print_date($datefin,'day'); - } - print ''; - if ($objp->subscription == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; + if ($datefin < dol_now() && $objp->statut > 0) + { + print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate")); + } + else + { + print dol_print_date($datefin,'day'); + } + print ''; + if ($objp->subscription == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print ''; + // Actions + print ''; if ($user->rights->adherent->creer) { print ''.img_edit().''; @@ -653,25 +644,25 @@ if ($rowid > 0) if ($user->rights->adherent->supprimer) { print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; - } + } print "
\n"; - print '
'; - print ''; + print "\n"; + print '
'; + print ''; if ($num > $conf->liste_limit) { - print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); + print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); } } else { - dol_print_error($db); + dol_print_error($db); } } @@ -723,10 +714,10 @@ if ($rowid > 0) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields,'edit'); + print $object->showOptionals($extrafields,'edit'); } print ''; 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 9047ab050d3..c9ef9ff828d 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 @@ -340,15 +340,16 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); ALTER TABLE llx_product ADD COLUMN fk_default_warehouse integer DEFAULT NULL; -ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); +ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); -- Assets -CREATE TABLE llx_assets( +CREATE TABLE llx_asset( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), amount double(24,8) DEFAULT NULL, + fk_asset_type integer NOT NULL, fk_soc integer, description text, note_public text, @@ -361,13 +362,15 @@ CREATE TABLE llx_assets( status integer NOT NULL ) ENGINE=innodb; -ALTER TABLE llx_assets ADD INDEX idx_assets_rowid (rowid); -ALTER TABLE llx_assets ADD INDEX idx_assets_ref (ref); -ALTER TABLE llx_assets ADD INDEX idx_assets_entity (entity); -ALTER TABLE llx_assets ADD INDEX idx_assets_fk_soc (fk_soc); -ALTER TABLE llx_assets ADD INDEX idx_assets_status (status); +ALTER TABLE llx_asset ADD INDEX idx_asset_rowid (rowid); +ALTER TABLE llx_asset ADD INDEX idx_asset_ref (ref); +ALTER TABLE llx_asset ADD INDEX idx_asset_entity (entity); +ALTER TABLE llx_asset ADD INDEX idx_asset_fk_soc (fk_soc); -create table llx_assets_extrafields +ALTER TABLE llx_asset ADD INDEX idx_asset_fk_asset_type (fk_asset_type); +ALTER TABLE llx_asset ADD CONSTRAINT fk_asset_asset_type FOREIGN KEY (fk_asset_type) REFERENCES llx_asset_type (rowid); + +create table llx_asset_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -375,12 +378,11 @@ create table llx_assets_extrafields import_key varchar(14) ) ENGINE=innodb; -create table llx_assets_type +create table llx_asset_type ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, - statut smallint NOT NULL DEFAULT 0, label varchar(50) NOT NULL, accountancy_code_asset varchar(32), accountancy_code_depreciation_asset varchar(32), @@ -388,9 +390,9 @@ create table llx_assets_type note text )ENGINE=innodb; -ALTER TABLE llx_assets_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); +ALTER TABLE llx_asset_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); -create table llx_assets_type_extrafields +create table llx_asset_type_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -398,6 +400,6 @@ create table llx_assets_type_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; -ALTER TABLE llx_assets_type_extrafields ADD INDEX idx_assets_type_extrafields (fk_object); +ALTER TABLE llx_asset_type_extrafields ADD INDEX idx_asset_type_extrafields (fk_object); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1); diff --git a/htdocs/install/mysql/tables/llx_assets.key.sql b/htdocs/install/mysql/tables/llx_asset.key.sql similarity index 62% rename from htdocs/install/mysql/tables/llx_assets.key.sql rename to htdocs/install/mysql/tables/llx_asset.key.sql index 495a092244b..6befef7455f 100644 --- a/htdocs/install/mysql/tables/llx_assets.key.sql +++ b/htdocs/install/mysql/tables/llx_asset.key.sql @@ -14,8 +14,11 @@ -- along with this program. If not, see http://www.gnu.org/licenses/. -ALTER TABLE llx_assets ADD INDEX idx_assets_rowid (rowid); -ALTER TABLE llx_assets ADD INDEX idx_assets_ref (ref); -ALTER TABLE llx_assets ADD INDEX idx_assets_entity (entity); -ALTER TABLE llx_assets ADD INDEX idx_assets_fk_soc (fk_soc); -ALTER TABLE llx_assets ADD INDEX idx_assets_status (status); \ No newline at end of file +ALTER TABLE llx_asset ADD INDEX idx_asset_rowid (rowid); +ALTER TABLE llx_asset ADD INDEX idx_asset_ref (ref); +ALTER TABLE llx_asset ADD INDEX idx_asset_entity (entity); +ALTER TABLE llx_asset ADD INDEX idx_asset_fk_soc (fk_soc); + +ALTER TABLE llx_asset ADD INDEX idx_asset_fk_asset_type (fk_asset_type); +ALTER TABLE llx_asset ADD CONSTRAINT fk_asset_asset_type FOREIGN KEY (fk_asset_type) REFERENCES llx_asset_type (rowid); + diff --git a/htdocs/install/mysql/tables/llx_assets.sql b/htdocs/install/mysql/tables/llx_asset.sql similarity index 95% rename from htdocs/install/mysql/tables/llx_assets.sql rename to htdocs/install/mysql/tables/llx_asset.sql index 1e72664be95..a583bd9275e 100644 --- a/htdocs/install/mysql/tables/llx_assets.sql +++ b/htdocs/install/mysql/tables/llx_asset.sql @@ -14,12 +14,13 @@ -- along with this program. If not, see http://www.gnu.org/licenses/. -CREATE TABLE llx_assets( +CREATE TABLE llx_asset( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), amount double(24,8) DEFAULT NULL, + fk_asset_type integer NOT NULL, fk_soc integer, description text, note_public text, diff --git a/htdocs/install/mysql/tables/llx_assets_extrafields.sql b/htdocs/install/mysql/tables/llx_asset_extrafields.sql similarity index 96% rename from htdocs/install/mysql/tables/llx_assets_extrafields.sql rename to htdocs/install/mysql/tables/llx_asset_extrafields.sql index dad66c47456..bc5eedae6d6 100644 --- a/htdocs/install/mysql/tables/llx_assets_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_asset_extrafields.sql @@ -13,7 +13,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see http://www.gnu.org/licenses/. -create table llx_assets_extrafields +create table llx_asset_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, diff --git a/htdocs/install/mysql/tables/llx_assets_type.key.sql b/htdocs/install/mysql/tables/llx_asset_type.key.sql similarity index 89% rename from htdocs/install/mysql/tables/llx_assets_type.key.sql rename to htdocs/install/mysql/tables/llx_asset_type.key.sql index 782ae72c083..2186a4aafd2 100644 --- a/htdocs/install/mysql/tables/llx_assets_type.key.sql +++ b/htdocs/install/mysql/tables/llx_asset_type.key.sql @@ -13,4 +13,4 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -ALTER TABLE llx_assets_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); +ALTER TABLE llx_asset_type ADD UNIQUE INDEX uk_asset_type_label (label, entity); diff --git a/htdocs/install/mysql/tables/llx_assets_type.sql b/htdocs/install/mysql/tables/llx_asset_type.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_assets_type.sql rename to htdocs/install/mysql/tables/llx_asset_type.sql index d637085488b..6b6a8b23db1 100644 --- a/htdocs/install/mysql/tables/llx_assets_type.sql +++ b/htdocs/install/mysql/tables/llx_asset_type.sql @@ -13,7 +13,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -create table llx_assets_type +create table llx_asset_type ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id diff --git a/htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql b/htdocs/install/mysql/tables/llx_asset_type_extrafields.key.sql similarity index 88% rename from htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_asset_type_extrafields.key.sql index 461946b9819..dbcc2500df8 100644 --- a/htdocs/install/mysql/tables/llx_assets_type_extrafields.key.sql +++ b/htdocs/install/mysql/tables/llx_asset_type_extrafields.key.sql @@ -14,4 +14,4 @@ -- along with this program. If not, see . -ALTER TABLE llx_assets_type_extrafields ADD INDEX idx_assets_type_extrafields (fk_object); +ALTER TABLE llx_asset_type_extrafields ADD INDEX idx_asset_type_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_assets_type_extrafields.sql b/htdocs/install/mysql/tables/llx_asset_type_extrafields.sql similarity index 95% rename from htdocs/install/mysql/tables/llx_assets_type_extrafields.sql rename to htdocs/install/mysql/tables/llx_asset_type_extrafields.sql index 8fcb7c51d41..1b98bd3f524 100644 --- a/htdocs/install/mysql/tables/llx_assets_type_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_asset_type_extrafields.sql @@ -13,7 +13,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -create table llx_assets_type_extrafields +create table llx_asset_type_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, From b43aca0f8de0c914185f7a9af7d2d9b74de91296 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 6 Apr 2018 08:52:02 +0200 Subject: [PATCH 75/84] Fix: use dol_string_nohtmltag instead (with strip_tags) --- htdocs/adherents/class/adherent.class.php | 4 +-- .../adherents/class/adherent_type.class.php | 2 +- htdocs/core/lib/functions.lib.php | 27 +++++++++++-------- htdocs/user/class/user.class.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6653d111363..4ababc23f73 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2323,8 +2323,8 @@ class Adherent extends CommonObject if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note_private)); - if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = html_entity_decode(strip_tags($this->note_public)); + if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 0, 'UTF-8', 1); + if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1); if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index af5790c41db..f1b44d3f1e7 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -456,7 +456,7 @@ class AdherentType extends CommonObject // Champs if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; - if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note)); + if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) { $valueofldapfield=array(); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 14f147d7f48..1adefaca5ab 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5415,28 +5415,33 @@ function picto_required() * @param string $stringtoclean String to clean * @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed * @param string $pagecodeto Encoding of input/output string + * @param integer $strip_tags 1=Use strip_tags php function, 0=Use internal pattern * @return string String cleaned * * @see dol_escape_htmltag strip_tags */ -function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8') +function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8',$strip_tags=0) { - // TODO Try to replace with strip_tags($stringtoclean) - $pattern = "/<[^<>]+>/"; - $stringtoclean = preg_replace('/]*>/', "\n", $stringtoclean); - $temp = dol_html_entity_decode($stringtoclean,ENT_COMPAT,$pagecodeto); + if ($strip_tags) { + $temp = strip_tags($stringtoclean); + } else { + $pattern = "/<[^<>]+>/"; + $temp = preg_replace('/]*>/', "\n", $stringtoclean); - // Exemple of $temp: 0000-021 - $temp = preg_replace($pattern,"",$temp); // pass 1 - // $temp after pass 1: 0000-021 - $temp = preg_replace($pattern,"",$temp); // pass 2 - // $temp after pass 2: 0000-021 + // Exemple of $temp: 0000-021 + $temp = preg_replace($pattern,"",$temp); // pass 1 + // $temp after pass 1: 0000-021 + $temp = preg_replace($pattern,"",$temp); // pass 2 + // $temp after pass 2: 0000-021 + } + + $temp = dol_html_entity_decode($temp,ENT_COMPAT,$pagecodeto); // Supprime aussi les retours if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); // et les espaces doubles - while(strpos($temp," ")) + while (strpos($temp," ")) { $temp = str_replace(" "," ",$temp); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5a24baae8dd..a0a8597a535 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2408,7 +2408,7 @@ class User extends CommonObject if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip; if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; - if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note_public)); + if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1); if ($this->socid > 0) { $soc = new Societe($this->db); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 483086574a6..d852c7ac03a 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -908,7 +908,7 @@ class UserGroup extends CommonObject // Champs if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; //if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name; - if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = html_entity_decode(strip_tags($this->note)); + if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); if (! empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) { $valueofldapfield=array(); From 151245a5e4c61d07bfa28fad3b5f127e435d366a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 11:25:48 +0200 Subject: [PATCH 76/84] Update conf.class.php --- htdocs/core/class/conf.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 66a6f165dba..9707266f369 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -482,7 +482,7 @@ class Conf // Default pdf option if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines - if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text + if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text // Set default value to MAIN_SHOW_LOGO if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; @@ -502,9 +502,9 @@ class Conf // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. - //Module part to include external modules menus - if(!empty($this->modules_parts['menuforexternal'])) - foreach($this->modules_parts['menuforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",$key"; + // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list + if (! empty($this->modules_parts['moduleforexternal'])) + foreach($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",$key"; // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2'; From 956fc2376d112290a4eb220a3d019827a1bebb15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 12:27:55 +0200 Subject: [PATCH 77/84] FIX #8483 --- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/lib/functions.lib.php | 21 +++++++++--------- htdocs/user/class/user.class.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- test/phpunit/FunctionsLibTest.php | 26 +++++++++++++++++------ 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4ababc23f73..760791027cb 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2323,8 +2323,8 @@ class Adherent extends CommonObject if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 0, 'UTF-8', 1); - if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1); + if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2); if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6c841c267b8..7c30d7eb352 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -530,7 +530,7 @@ class Contact extends CommonObject if ($this->phone_mobile && ! empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && ! empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; if ($this->skype && ! empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = $this->note_private; + if ($this->note_private && ! empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); if ($this->email && ! empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1adefaca5ab..a24a454d54e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5408,26 +5408,27 @@ function picto_required() /** * Clean a string from all HTML tags and entities. * This function differs from strip_tags because: - * -
are replace with \n - * - if entities are found, they are decoded before the strip - * - you can decide to convert line feed into spaces + * -
are replaced with \n if removelinefeed=0 or 1 + * - if entities are found, they are decoded BEFORE the strip + * - you can decide to convert line feed into a space * * @param string $stringtoclean String to clean - * @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed + * @param integer $removelinefeed 1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with \n, 2=Ending new lines are removed but others are kept with a same number of \n than nb of
when there is both "...
\n..." * @param string $pagecodeto Encoding of input/output string - * @param integer $strip_tags 1=Use strip_tags php function, 0=Use internal pattern + * @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag) * @return string String cleaned * * @see dol_escape_htmltag strip_tags */ -function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8',$strip_tags=0) +function dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0) { + if ($removelinefeed == 2) $stringtoclean = preg_replace('/]*>\n+/ims', '
', $stringtoclean); + $temp = preg_replace('/]*>/i', "\n", $stringtoclean); + if ($strip_tags) { - $temp = strip_tags($stringtoclean); + $temp = strip_tags($temp); } else { $pattern = "/<[^<>]+>/"; - $temp = preg_replace('/]*>/', "\n", $stringtoclean); - // Exemple of $temp:
0000-021 $temp = preg_replace($pattern,"",$temp); // pass 1 // $temp after pass 1: 0000-021 @@ -5438,7 +5439,7 @@ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF- $temp = dol_html_entity_decode($temp,ENT_COMPAT,$pagecodeto); // Supprime aussi les retours - if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); + if ($removelinefeed == 1) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); // et les espaces doubles while (strpos($temp," ")) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a0a8597a535..6d992246eea 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2408,7 +2408,7 @@ class User extends CommonObject if ($this->address && ! empty($conf->global->LDAP_FIELD_ADDRESS)) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; if ($this->zip && ! empty($conf->global->LDAP_FIELD_ZIP)) $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip; if ($this->town && ! empty($conf->global->LDAP_FIELD_TOWN)) $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; - if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1); + if ($this->note_public && ! empty($conf->global->LDAP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 2); if ($this->socid > 0) { $soc = new Societe($this->db); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index d852c7ac03a..859c5267d04 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -908,7 +908,7 @@ class UserGroup extends CommonObject // Champs if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_FULLNAME)) $info[$conf->global->LDAP_GROUP_FIELD_FULLNAME] = $this->name; //if ($this->name && ! empty($conf->global->LDAP_GROUP_FIELD_NAME)) $info[$conf->global->LDAP_GROUP_FIELD_NAME] = $this->name; - if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); + if ($this->note && ! empty($conf->global->LDAP_GROUP_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 2); if (! empty($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)) { $valueofldapfield=array(); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index e96cda7d6e5..71b39fc6e51 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -437,17 +437,21 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase */ public function testDolStringNohtmltag() { - $text="A\nstring\n"; + $text="A\nstring\n\nand more\n"; $after=dol_string_nohtmltag($text,0); - $this->assertEquals("A\nstring",$after,"test1"); + $this->assertEquals("A\nstring\n\nand more",$after,"test1a"); - $text="A string\n\nwith html tag and '<' chars
\n"; + $text="A string
\n
\n\nwith html tag
\n"; $after=dol_string_nohtmltag($text, 0); - $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test2"); + $this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n"); - $text="A string\n\nwith tag with < chars
\n"; + $text="A string
\n
\n\nwith html tag
\n"; $after=dol_string_nohtmltag($text, 1); - $this->assertEquals("A string with tag with < chars",$after,"test3"); + $this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space"); + + $text="A string
\n
\n\nwith html tag
\n"; + $after=dol_string_nohtmltag($text, 2); + $this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n"); $text="A string
Another string"; $after=dol_string_nohtmltag($text,0); @@ -469,6 +473,14 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $after=dol_string_nohtmltag($text,0); $this->assertEquals("HIJ",$after,"test8"); + $text="A string\n\nwith html tag and '<' chars
\n"; + $after=dol_string_nohtmltag($text, 0); + $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9"); + + $text="A string\n\nwith tag with < chars
\n"; + $after=dol_string_nohtmltag($text, 1); + $this->assertEquals("A string with tag with < chars",$after,"test10"); + return true; } @@ -830,7 +842,7 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $s=img_picto('title', 'delete', '', 0, 1); print __METHOD__." s=".$s."\n"; - $this->assertEquals('/theme/eldy/img/delete.png',$s,'testImgPicto5'); + $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5'); } /** From d3adbdfbbc2507f02d4866744d94919f9bc50004 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 14:04:52 +0200 Subject: [PATCH 78/84] FIX Restaure way to have empty entry menu --- htdocs/core/menus/standard/auguria.lib.php | 47 ++++++++++++++++------ htdocs/core/menus/standard/eldy.lib.php | 19 +++++---- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 69f98710b93..687505ab00d 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -464,6 +464,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM if (! is_array($menu_array)) return 0; // Show menu + $invert=empty($conf->global->MAIN_MENU_INVERT)?"":"invert"; if (empty($noout)) { $altok=0; $blockvmenuopened=false; $lastlevel0=''; @@ -485,11 +486,11 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM } if ($altok % 2 == 0) { - print '
'."\n"; + print '
'."\n"; } else { - print '
'."\n"; + print '
'."\n"; } } @@ -509,24 +510,43 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM $substitarray['__USERID__'] = $user->id; // For backward compatibility $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray); - // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser. - $url=dol_buildpath($menu_array[$i]['url'],1); - - if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) + $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url']; + if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url'])) { - if (! preg_match('/\?/',$url)) $url.='?'; - else $url.='&'; - $url.='mainmenu='.$mainmenu; + $tmp=explode('?',$menu_array[$i]['url'],2); + $url = $shorturl = $tmp[0]; + $param = (isset($tmp[1])?$tmp[1]:''); // params in url of the menu link + + // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu'])) + { + $param.=($param?'&':'').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu='; + } + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($menu_array[$i]['mainmenu'])) + { + $param.=($param?'&':'').'leftmenu='; + } + //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad + $url = dol_buildpath($url,1).($param?'?'.$param:''); + $shorturlwithoutparam = $shorturl; + $shorturl = $shorturl.($param?'?'.$param:''); } - print ''."\n"; + + print ''."\n"; // Menu level 0 if ($menu_array[$i]['level'] == 0) { if ($menu_array[$i]['enabled']) // Enabled so visible { - print ''; + print ''."\n"; $lastlevel0='enabled'; } else if ($showmenu) // Not enabled but visible (so greyed) @@ -543,6 +563,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM print ''."\n"; } } + // Menu level > 0 if ($menu_array[$i]['level'] > 0) { @@ -552,10 +573,10 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled. { print '