This commit is contained in:
Laurent Destailleur 2011-05-18 12:34:48 +00:00
parent ea26c7a4c4
commit 85cadf443d

View File

@ -229,8 +229,8 @@ class CommonObject
} }
/** /**
* \brief Delete all links between an object $this and all its contacts * Delete all links between an object $this and all its contacts
* \return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function delete_linked_contact() function delete_linked_contact()
{ {
@ -312,10 +312,10 @@ class CommonObject
{ {
$tab[$i]=$obj->id; $tab[$i]=$obj->id;
} }
$i++; $i++;
} }
return $tab; return $tab;
} }
else else
@ -556,9 +556,9 @@ class CommonObject
function fetchObjectFromImportKey($table,$key) function fetchObjectFromImportKey($table,$key)
{ {
global $conf; global $conf;
$result=false; $result=false;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE import_key = '".$key."'"; $sql.= " WHERE import_key = '".$key."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@ -568,10 +568,10 @@ class CommonObject
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
$result = $this->fetch($row[0]); $result = $this->fetch($row[0]);
} }
return $result; return $result;
} }
/** /**
* Load object from external reference * Load object from external reference
* @param table Table element or element line * @param table Table element or element line
@ -581,9 +581,9 @@ class CommonObject
function fetchObjectFromRefExt($table,$ref) function fetchObjectFromRefExt($table,$ref)
{ {
global $conf; global $conf;
$result=false; $result=false;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE ref_ext = '".$ref."'"; $sql.= " WHERE ref_ext = '".$ref."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@ -593,7 +593,7 @@ class CommonObject
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
$result = $this->fetch($row[0]); $result = $this->fetch($row[0]);
} }
return $result; return $result;
} }
@ -1210,13 +1210,13 @@ class CommonObject
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR') function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{ {
global $conf; global $conf;
$this->linkedObjectsIds=array(); $this->linkedObjectsIds=array();
$this->linkedObjects=array(); $this->linkedObjects=array();
$justsource=false; $justsource=false;
$justtarget=false; $justtarget=false;
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true; if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true;
if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true; if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true;
@ -1260,7 +1260,7 @@ class CommonObject
} }
$i++; $i++;
} }
if (! empty($this->linkedObjectsIds)) if (! empty($this->linkedObjectsIds))
{ {
foreach($this->linkedObjectsIds as $objecttype => $objectids) foreach($this->linkedObjectsIds as $objecttype => $objectids)
@ -1272,9 +1272,9 @@ class CommonObject
$module = $element = $regs[1]; $module = $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }
$classpath = $element.'/class'; $classpath = $element.'/class';
// To work with non standard path // To work with non standard path
if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; }
if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; }
@ -1282,17 +1282,17 @@ class CommonObject
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; } if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; }
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; } if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
$classfile = strtolower($subelement); $classname = ucfirst($subelement); $classfile = strtolower($subelement); $classname = ucfirst($subelement);
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; } if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; } if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
if ($conf->$module->enabled && $element != $this->element) if ($conf->$module->enabled && $element != $this->element)
{ {
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
$num=sizeof($objectids); $num=sizeof($objectids);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$object = new $classname($this->db); $object = new $classname($this->db);
@ -1311,7 +1311,7 @@ class CommonObject
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
/** /**
* Set statut of an object * Set statut of an object
* @param statut Statut to set * @param statut Statut to set
@ -1462,7 +1462,7 @@ class CommonObject
} }
} }
} }
/** /**
* Get special code of line * Get special code of line
* @param lineid Id of line * @param lineid Id of line
@ -1495,7 +1495,7 @@ class CommonObject
function showLinkedObjectBlock() function showLinkedObjectBlock()
{ {
global $langs,$bc; global $langs,$bc;
$this->fetchObjectLinked(); $this->fetchObjectLinked();
$num = sizeof($this->linkedObjects); $num = sizeof($this->linkedObjects);
@ -1503,14 +1503,14 @@ class CommonObject
foreach($this->linkedObjects as $objecttype => $objects) foreach($this->linkedObjects as $objecttype => $objects)
{ {
$tplpath = $element = $subelement = $objecttype; $tplpath = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{ {
$element = $regs[1]; $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
$tplpath = $element.'/'.$subelement; $tplpath = $element.'/'.$subelement;
} }
// To work with non standard path // To work with non standard path
if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; } if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; }
if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; } if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; }
@ -1518,12 +1518,12 @@ class CommonObject
if ($objecttype == 'delivery') { $tplpath = 'livraison'; } if ($objecttype == 'delivery') { $tplpath = 'livraison'; }
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; } if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; }
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; } if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; }
$this->linkedObjectBlock = $objects; $this->linkedObjectBlock = $objects;
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php'); dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php');
} }
return $num; return $num;
} }
@ -1579,7 +1579,7 @@ class CommonObject
function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0) function printObjectLines($action='viewline',$seller,$buyer,$selected=0,$dateSelector=0)
{ {
global $conf,$langs; global $conf,$langs;
// TODO test using div instead of tables // TODO test using div instead of tables
/* /*
print '<div class="table" id="tablelines">'; print '<div class="table" id="tablelines">';
@ -1612,9 +1612,9 @@ class CommonObject
$num = count($this->lines); $num = count($this->lines);
$var = true; $var = true;
$i = 0; $i = 0;
//print '<div class="tbody">'; //print '<div class="tbody">';
foreach ($this->lines as $line) foreach ($this->lines as $line)
{ {
$var=!$var; $var=!$var;
@ -1630,7 +1630,7 @@ class CommonObject
$i++; $i++;
} }
//print '</div></div>'; //print '</div></div>';
} }