Skip to content

Commit

Permalink
Merge pull request #4546 from bafbes/bra
Browse files Browse the repository at this point in the history
provide link section in expense reports and add option for intervention
  • Loading branch information
eldy committed Feb 2, 2016
2 parents 55c3728 + 773ee5c commit 82cc0b4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
63 changes: 62 additions & 1 deletion htdocs/core/class/html.form.class.php
Expand Up @@ -5100,7 +5100,68 @@ function showLinkToObjectBlock($object, $restrictlinksto=array())
print '</div>';
}

if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto))
if ((in_array('fichinter',$restrictlinksto)) && ! empty($conf->ficheinter->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedFichinter') . '</a>';

print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';

print '<div id="orderlist"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';

$sql = "SELECT s.rowid as socid, s.nom as name, s.client, f.rowid, f.ref";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "fichinter as f";
$sql .= ' WHERE f.fk_soc = s.rowid';

$resqlorderlist = $this->db->query($sql);
if ($resqlorderlist)
{
$num = $this->db->num_rows($resqlorderlist);
$i = 0;

print '<br><form action="" method="POST" name="LinkedFichinter">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num)
{
$objp = $this->db->fetch_object($resqlorderlist);

$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="LinkedFichinter" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';

$i ++;
}
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$this->db->free($resqlorderlist);
} else {
dol_print_error($this->db);
}

print '</div>';
}

if (((! is_array($restrictlinksto)) || in_array('supplier_order',$restrictlinksto))
&& ! empty($conf->fournisseur->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#linktoorder" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
Expand Down
21 changes: 21 additions & 0 deletions htdocs/expensereport/card.php
Expand Up @@ -2086,7 +2086,28 @@

print '</div>';

if ($action != 'create' && $action != 'edit' && ($id || $ref))
{
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once

// Link invoice to intervention
if (GETPOST('LinkedFichinter')) {
$object->fetch($id);
$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($conf->global->EXPENSES_LINK_TO_INTERVENTION) $linktoelements[]='fichinter';
$linktoelem='';
$linktoelem = $form->showLinkToObjectBlock($object,$linktoelements);
if ($linktoelem) print '<br>'.$linktoelem;

}
llxFooter();

$db->close();
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/compta.lang
Expand Up @@ -220,4 +220,5 @@ AddExtraReport=Extra reports
OtherCountriesCustomersReport=Foreign customers report
BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry=Based on the two first letters of the VAT number being different from your own company's country code
SameCountryCustomersWithVAT=National customers report
BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Based on the two first letters of the VAT number being the same as your own company's country code
BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Based on the two first letters of the VAT number being the same as your own company's country code
LinkedFichinter=Link to an intervention
1 change: 1 addition & 0 deletions htdocs/langs/fr_FR/compta.lang
Expand Up @@ -221,3 +221,4 @@ OtherCountriesCustomersReport=Rapport client étranger
BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry=Basé sur les deux premières lettres du numéro de TVA étant différent du code de pays de votre propre entreprise
SameCountryCustomersWithVAT=Rapport clients nationaux
BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry=Basé sur les deux premières lettres du numéro de TVA étant les mêmes que le code pays de votre propre entreprise
LinkedFichinter=Lier à une intervention

0 comments on commit 82cc0b4

Please sign in to comment.