Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop

This commit is contained in:
Laurent Destailleur 2012-07-05 15:48:02 +02:00
commit f9cef80942
2 changed files with 96 additions and 54 deletions

View File

@ -99,10 +99,10 @@ if (($conf->propal->enabled && $user->rights->propale->lire) ||
} }
// Recherche Propal // Recherche Propal
if ($conf->propal->enabled && $user->rights->propale->lire) if ($conf->propal->enabled && $user->rights->propal->lire)
{ {
$var=false; $var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>'; print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
@ -137,7 +137,7 @@ if ($conf->contrat->enabled && $user->rights->contrat->lire)
/* /*
* Draft proposals * Draft proposals
*/ */
if ($conf->propal->enabled && $user->rights->propale->lire) if ($conf->propal->enabled && $user->rights->propal->lire)
{ {
$sql = "SELECT p.rowid, p.ref, p.total_ht, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql = "SELECT p.rowid, p.ref, p.total_ht, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
@ -189,7 +189,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
} }
} }
print "</table><br>"; print "</table><br>";
$db->free($resql); $db->free($resql);
} }
else else
@ -252,7 +252,7 @@ if ($conf->commande->enabled && $user->rights->commande->lire)
} }
} }
print "</table><br>"; print "</table><br>";
$db->free($resql); $db->free($resql);
} }
} }
@ -468,7 +468,7 @@ if ($conf->contrat->enabled && $user->rights->contrat->lire && 0) // TODO A REFA
/* /*
* Opened proposals * Opened proposals
*/ */
if ($conf->propal->enabled && $user->rights->propale->lire) if ($conf->propal->enabled && $user->rights->propal->lire)
{ {
$langs->load("propal"); $langs->load("propal");

View File

@ -1809,15 +1809,43 @@ abstract class CommonObject
/** /**
* Delete all links between an object $this * Delete all links between an object $this
* *
* @param int $sourceid Object source id
* @param string $sourcetype Object source type
* @param int $targetid Object target id
* @param string $targettype Object target type
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function deleteObjectLinked() function deleteObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='')
{ {
$deletesource=false;
$deletetarget=false;
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource=true;
else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $deletetarget=true;
$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
$targetid = (! empty($targetid) ? $targetid : $this->id);
$targettype = (! empty($targettype) ? $targettype : $this->element);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE"; $sql.= " WHERE";
$sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')"; if ($deletesource)
$sql.= " OR"; {
$sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')"; $sql.= " fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'";
$sql.= " AND fk_target = ".$this->id." AND targettype = '".$this->element."'";
}
else if ($deletetarget)
{
$sql.= " fk_target = ".$targetid." AND targettype = '".$targettype."'";
$sql.= " AND fk_source = ".$this->id." AND sourcetype = '".$this->element."'";
}
else
{
$sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')";
$sql.= " OR";
$sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')";
}
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -2316,60 +2344,74 @@ abstract class CommonObject
* TODO Move this into html.class.php * TODO Move this into html.class.php
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* *
* @param HookManager $hookmanager Hook manager instance
* @return void * @return void
*/ */
function showLinkedObjectBlock() function showLinkedObjectBlock($hookmanager=false)
{ {
global $conf,$langs,$bc; global $conf,$langs,$bc;
$this->fetchObjectLinked(); $this->fetchObjectLinked();
$num = count($this->linkedObjects); // Bypass the default method
if (! is_object($hookmanager))
foreach($this->linkedObjects as $objecttype => $objects)
{ {
$tplpath = $element = $subelement = $objecttype; include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
// To work with non standard path
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
}
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
}
else if ($objecttype == 'shipping') {
$tplpath = 'expedition';
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
}
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
// 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.'/linkedobjectblock.tpl.php'));
if ($res) break;
}
} }
$hookmanager->initHooks(array('commonobject'));
$parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook
return $num; if (! $reshook)
{
$num = count($this->linkedObjects);
foreach($this->linkedObjects as $objecttype => $objects)
{
$tplpath = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
// To work with non standard path
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
}
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
}
else if ($objecttype == 'shipping') {
$tplpath = 'expedition';
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
}
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
// 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.'/linkedobjectblock.tpl.php'));
if ($res) break;
}
}
return $num;
}
} }