2
0
forked from Wavyzz/dolibarr

Move button to link to, in same part of code than code to output links.

This commit is contained in:
Laurent Destailleur
2016-08-05 15:30:28 +02:00
parent 851f8369cf
commit bcd055b378
20 changed files with 137 additions and 125 deletions

View File

@@ -322,9 +322,9 @@ if ($id && (empty($action) || $action == 'view' || $action == 'delete'))
// Example 2 : Adding links to objects
//$somethingshown=$form->showLinkedObjectBlock($object);
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('skeleton'));
//$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
}

View File

@@ -419,14 +419,16 @@ if ($rowid && $action != 'edit')
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
$somethingshown = $formfile->numoffiles;
*/
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
$somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('invoice', $object->ref);

View File

@@ -2320,12 +2320,9 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('propal'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -2585,12 +2585,10 @@ if ($action == 'create' && $user->rights->commande->creer)
$delallowed = $user->rights->commande->supprimer;
$somethingshown = $formfile->show_documents('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -4018,12 +4018,9 @@ else if ($id > 0 || ! empty($ref))
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
$somethingshown = $formfile->numoffiles;
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Link for paypal payment
if (! empty($conf->paypal->enabled) && $object->statut != 0) {

View File

@@ -1533,8 +1533,11 @@ else
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form->showLinkedObjectBlock($object, '');
print '</div></div>';

View File

@@ -1992,12 +1992,10 @@ else
$somethingshown = $formfile->show_documents('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -3196,20 +3196,6 @@ abstract class CommonObject
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
// --------------------
/**
* Show linked object block.
*
* @return int <0 if KO, >0 if OK
* @deprecated 3.8 Use instead $form->showLinkedObjectBlock($object)
* @see Form::showLinkedObjectBlock
*/
function showLinkedObjectBlock()
{
global $form;
return $form->showLinkedObjectBlock($this);
}
/* This is to show add lines */
/**

View File

@@ -5075,17 +5075,6 @@ class Form
<script type="text/javascript">
jQuery(document).ready(function () {
$(".dropdown dt a").on(\'click\', function () {
console.log($( this ).parent().parent().find(\'dd ul\'));
$( this ).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
// $(".dropdown dd ul").slideToggle(\'fast\');
});
$(document).bind(\'click\', function (e) {
var $clicked = $(e.target);
if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
});
$(\'.multiselectcheckbox'.$htmlname.' input[type="checkbox"]\').on(\'click\', function () {
console.log("A new field was added/removed")
$("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\')
@@ -5155,9 +5144,10 @@ class Form
* Show linked object block.
*
* @param CommonObject $object Object we want to show links to
* @return int <0 if KO, >0 if OK
* @param string $morehtmlright More html to show on right of title
* @return int <0 if KO, >=0 if OK
*/
function showLinkedObjectBlock($object)
function showLinkedObjectBlock($object, $morehtmlright='')
{
global $conf,$langs,$hookmanager;
global $bc;
@@ -5172,6 +5162,22 @@ class Form
if (empty($reshook))
{
$num = count($object->linkedObjects);
print '<br>';
print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '');
print '<table class="noborder allwidth">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td align="center"></td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
print '<td align="right">'.$langs->trans("Status").'</td>';
print '<td></td>';
print '</tr>';
$numoutput=0;
foreach($object->linkedObjects as $objecttype => $objects)
@@ -5227,40 +5233,27 @@ class Form
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
if (empty($numoutput))
{
$numoutput++;
print '<br>';
print load_fiche_titre($langs->trans('RelatedObjects'), '', '');
print '<table class="noborder allwidth">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td align="center"></td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
print '<td align="right">'.$langs->trans("Status").'</td>';
print '<td></td>';
print '</tr>';
}
// Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
if ($res) break;
if ($res)
{
$numoutput++;
break;
}
}
}
if ($numoutput)
if (! $numoutput)
{
print '</table>';
print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
return $num;
}
}
@@ -5293,6 +5286,7 @@ class Form
'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc = ".$object->thirdparty->id)
);
foreach($possiblelinks as $key => $possiblelink)
{
$num = 0;
@@ -5346,25 +5340,37 @@ class Form
print '</div>';
if ($num > 0)
{
print '
<!-- Add js to show linkto box for '.$key.' ('.$num.' records) -->
}
//$linktoelem.=($linktoelem?' &nbsp; ':'');
if ($num > 0) $linktoelem.='<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">' . $langs->trans($possiblelink['label']) .' ('.$num.')</a></li>';
//else $linktoelem.=$langs->trans($possiblelink['label']);
else $linktoelem.='<li><span class="linktodisabled">' . $langs->trans($possiblelink['label']) . ' (0)</span></li>';
}
}
$linktoelem='
<dl class="dropdown" id="linktoobjectname">
<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>
<dd>
<div class="multiselectlinkto">
<ul class="ulselectedfields">'.$linktoelem.'
</ul>
</div>
</dd>
</dl>';
print '<!-- Add js to show linkto box -->
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linkto'.$key.'").click(function() {
jQuery("#'.$key.'list").toggle();
jQuery("#linkto'.$key.'").toggle();
jQuery(".linkto").click(function() {
console.log("We choose to show/hide link for rel="+jQuery(this).attr(\'rel\'));
jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
jQuery(this).toggle();
});
});
</script>
';
}
$linktoelem.=($linktoelem?' &nbsp; ':'');
if ($num > 0) $linktoelem.='<a href="#linkto'.$key.'" id="linkto'.$key.'">' . $langs->trans($possiblelink['label']) .' ('.$num.')</a>';
//else $linktoelem.=$langs->trans($possiblelink['label']);
else $linktoelem.='<a href="#linkto'.$key.'" class="disabled" id="linkto'.$key.'">' . $langs->trans($possiblelink['label']) . '</a>';
}
}
return $linktoelem;
}

View File

@@ -948,6 +948,7 @@ function copyToClipboard(text,text2)
return false;
}
/*
* Function show document preview
*
@@ -1128,3 +1129,5 @@ function price2numjs(amount) {
return res;
}

View File

@@ -1831,12 +1831,11 @@ else if ($id || $ref)
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form->showLinkedObjectBlock($object, '');
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -2069,15 +2069,15 @@ if ($action != 'create' && $action != 'edit' && ($id || $ref))
$object->fetch_thirdparty();
$result = $object->add_object_linked('fichinter', GETPOST('LinkedFichinter'));
}
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelements=array();
if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) $linktoelements[]='fichinter';
$linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
}
llxFooter();
$db->close();

View File

@@ -1677,12 +1677,10 @@ else if ($id > 0 || ! empty($ref))
//print "<br>\n";
$somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -2831,12 +2831,10 @@ elseif (! empty($object->id))
print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$object->thirdparty->default_lang);
$somethingshown=$formfile->numoffiles;
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order_supplier'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -2236,12 +2236,10 @@ else
print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
$somethingshown=$formfile->numoffiles;
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice_supplier'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@@ -644,6 +644,7 @@ NewAttribute=New attribute
AttributeCode=Attribute code
URLPhoto=URL of photo/logo
SetLinkToAnotherThirdParty=Link to another third party
LinkTo=Link to
LinkToProposal=Link to proposal
LinkToOrder=Link to order
LinkToInvoice=Link to invoice

View File

@@ -680,12 +680,9 @@ else
$shipment = new Expedition($db);
$shipment->fetch($object->origin_id);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($shipment);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($shipment);
//if ($linktoelem) print '<br>'.$linktoelem;
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form->showLinkedObjectBlock($object, '');
}

View File

@@ -1930,6 +1930,45 @@ if (! function_exists("llxFooter"))
</script>' . "\n";
}
// Wrapper to manage dropdown
if ($conf->use_javascript_ajax)
{
print "\n<!-- JS CODE TO ENABLE dropdown -->\n";
print '<script type="text/javascript">
jQuery(document).ready(function () {
$(".dropdown dt a").on(\'click\', function () {
//console.log($(this).parent().parent().find(\'dd ul\'));
$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
// Note: Did not find a way to get exact height (value is update at exit) so i calculate a generic from nb of lines
heigthofcontent = 19 * $(this).parent().parent().find(\'dd div ul li\').length;
if (heigthofcontent > 300) heigthofcontent = 300; // limited by max-height on css .dropdown dd ul
posbottom = $(this).parent().parent().find(\'dd\').offset().top + heigthofcontent + 8;
//console.log(posbottom);
var scrollBottom = $(window).scrollTop() + $(window).height();
//console.log(scrollBottom);
diffoutsidebottom = (posbottom - scrollBottom);
console.log("diffoutsidebottom (positive = outside) = "+diffoutsidebottom);
if (diffoutsidebottom > 0)
{
pix = "-"+diffoutsidebottom+"px";
console.log(pix);
$(this).parent().parent().find(\'dd\').css("top", pix);
}
// $(".dropdown dd ul").slideToggle(\'fast\');
});
$(".dropdowncloseonclick").on(\'click\', function () {
console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul");
$(this).parent().parent().hide();
});
$(document).bind(\'click\', function (e) {
var $clicked = $(e.target);
if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
});
});
</script>';
}
// A div for the address popup
print "\n<!-- A div to allow dialog popup -->\n";
print '<div id="dialogforpopup" style="display: none;"></div>'."\n";

View File

@@ -362,12 +362,6 @@ print '<tr><td class="fieldrequired">'.$langs->trans("Fieldimport_key").'</td><t
}
print '</div>'."\n";
// Example 2 : Adding links to objects
//$somethingshown=$form->showLinkedObjectBlock($object);
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
}

View File

@@ -1805,12 +1805,10 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_proposal'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';