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'; ?> - - trans("CustomerOrder"); ?> + + trans("CustomerOrder"); ?> + getNomUrl(0,'',0,1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > + getNomUrl(1); ?> ref_client; ?> date,'day'); ?> 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 ''; + + 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