Try a fix for #3742
This commit is contained in:
parent
fa138ca526
commit
22979523db
@ -2347,8 +2347,8 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1);
|
print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1);
|
||||||
//We check if Origin document has already an invoice attached to it
|
// We check if Origin document (id and type is known) has already at least one invoice attached to it
|
||||||
$objectsrc->fetchObjectLinked($originid,'','','facture');
|
$objectsrc->fetchObjectLinked($originid,$origin,'','facture');
|
||||||
$cntinvoice=count($objectsrc->linkedObjects['facture']);
|
$cntinvoice=count($objectsrc->linkedObjects['facture']);
|
||||||
if ($cntinvoice>=1)
|
if ($cntinvoice>=1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2231,13 +2231,18 @@ abstract class CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds
|
* Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds
|
||||||
*
|
* Possible usage for parameters:
|
||||||
* @param int $sourceid Object source id
|
* - all parameters empty -> we look all link to current object (current object can be source or target)
|
||||||
* @param string $sourcetype Object source type
|
* - one couple id+type is provided -> this will set $justsource or $justtarget
|
||||||
* @param int $targetid Object target id
|
* - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type
|
||||||
* @param string $targettype Object target type
|
*
|
||||||
|
*
|
||||||
|
* @param int $sourceid Object source id (if not defined, id of object)
|
||||||
|
* @param string $sourcetype Object source type (if not defined, element name of object)
|
||||||
|
* @param int $targetid Object target id (if not defined, id of object)
|
||||||
|
* @param string $targettype Object target type (if not defined, elemennt name of object)
|
||||||
* @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided
|
* @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided
|
||||||
* @param int $alsosametype 0=Return only links to different object than source. 1=Include also link to objects of same type.
|
* @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type.
|
||||||
* @return void
|
* @return void
|
||||||
* @see add_object_linked, updateObjectLinked, deleteObjectLinked
|
* @see add_object_linked, updateObjectLinked, deleteObjectLinked
|
||||||
*/
|
*/
|
||||||
@ -2255,12 +2260,12 @@ abstract class CommonObject
|
|||||||
|
|
||||||
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid))
|
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid))
|
||||||
{
|
{
|
||||||
$justsource=true;
|
$justsource=true; // the source (id and type) is a search criteria
|
||||||
if (! empty($targettype)) $withtargettype=true;
|
if (! empty($targettype)) $withtargettype=true;
|
||||||
}
|
}
|
||||||
if (! empty($targetid) && ! empty($targettype) && empty($sourceid))
|
if (! empty($targetid) && ! empty($targettype) && empty($sourceid))
|
||||||
{
|
{
|
||||||
$justtarget=true;
|
$justtarget=true; // the target (id and type) is a search criteria
|
||||||
if (! empty($sourcetype)) $withsourcetype=true;
|
if (! empty($sourcetype)) $withsourcetype=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2309,13 +2314,27 @@ abstract class CommonObject
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if ($obj->fk_source == $sourceid)
|
if ($justsource || $justtarget)
|
||||||
{
|
{
|
||||||
$this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target;
|
if ($justsource)
|
||||||
|
{
|
||||||
|
$this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target;
|
||||||
|
}
|
||||||
|
else if ($justtarget)
|
||||||
|
{
|
||||||
|
$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($obj->fk_target == $targetid)
|
else
|
||||||
{
|
{
|
||||||
$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source;
|
if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype)
|
||||||
|
{
|
||||||
|
$this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target;
|
||||||
|
}
|
||||||
|
if ($obj->fk_target == $targetid && $obj->targettype == $targettype)
|
||||||
|
{
|
||||||
|
$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1515,8 +1515,8 @@ if ($action == 'create')
|
|||||||
$txt=$langs->trans("SupplierOrder");
|
$txt=$langs->trans("SupplierOrder");
|
||||||
}
|
}
|
||||||
print '<tr><td>'.$txt.'</td><td colspan="2">'.$objectsrc->getNomUrl(1);
|
print '<tr><td>'.$txt.'</td><td colspan="2">'.$objectsrc->getNomUrl(1);
|
||||||
//We check if Origin document has already an invoice attached to it
|
// We check if Origin document (id and type is known) has already at least one invoice attached to it
|
||||||
$objectsrc->fetchObjectLinked($originid,'','','invoice_supplier');
|
$objectsrc->fetchObjectLinked($originid,$origin,'','invoice_supplier');
|
||||||
$cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']);
|
$cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']);
|
||||||
if ($cntinvoice>=1)
|
if ($cntinvoice>=1)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user