From 5624257a6def5f4f79149d274d2f674989982d83 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 20 Feb 2018 16:49:49 +0100 Subject: [PATCH 01/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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 1afe567a01ddd76696039e966ec7b5ac07c6d106 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 3 Apr 2018 12:07:19 +0200 Subject: [PATCH 09/11] 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 e5664f9630d4aa9550a8f6c58837e139dcef7553 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 4 Apr 2018 20:32:36 +0200 Subject: [PATCH 10/11] 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 57db0d2a167847bc843766be779a7dd2563a662c Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 17:26:08 +0200 Subject: [PATCH 11/11] 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; ?>