Fix: multicompany compatibility
This commit is contained in:
parent
cb0fa0ad11
commit
b204ad5b84
@ -525,20 +525,26 @@ class Categorie
|
|||||||
*
|
*
|
||||||
* @param string $field Field name for select in table. Full field name will be fk_field.
|
* @param string $field Field name for select in table. Full field name will be fk_field.
|
||||||
* @param string $classname PHP Class of object to store entity
|
* @param string $classname PHP Class of object to store entity
|
||||||
* @param string $table Table name for select in table. Full table name will be PREFIX_categorie_table.
|
* @param string $category_table Table name for select in table. Full table name will be PREFIX_categorie_table.
|
||||||
|
* @param string $object_table Table name for select in table. Full table name will be PREFIX_table.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function get_type($field,$classname,$table='')
|
function get_type($field,$classname,$category_table='',$object_table='')
|
||||||
{
|
{
|
||||||
$objs = array();
|
$objs = array();
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (empty($table)) $table=$field;
|
if (empty($category_table)) $category_table=$field;
|
||||||
|
if (empty($object_table)) $object_table=$field;
|
||||||
|
|
||||||
$sql = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table;
|
$sql = "SELECT c.fk_".$field;
|
||||||
$sql.= " WHERE fk_categorie = ".$this->id;
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$category_table." as c";
|
||||||
|
$sql.= ", ".MAIN_DB_PREFIX.$object_table." as o";
|
||||||
|
$sql.= " WHERE c.fk_categorie = ".$this->id;
|
||||||
|
$sql.= " AND c.fk_".$field." = o.rowid";
|
||||||
|
$sql.= " AND o.entity IN (".getEntity($field, 1).")";
|
||||||
|
|
||||||
dol_syslog("Categorie::get_type sql=".$sql);
|
dol_syslog(get_class($this)."::get_type sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -553,7 +559,7 @@ class Categorie
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error().' sql='.$sql;
|
$this->error=$this->db->error().' sql='.$sql;
|
||||||
dol_syslog("Categorie::get_type ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::get_type ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -322,7 +322,7 @@ if ($object->type == 3)
|
|||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||||
|
|
||||||
$prods = $object->get_type("member","Adherent");
|
$prods = $object->get_type("member","Adherent","","adherent");
|
||||||
if ($prods < 0)
|
if ($prods < 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$object->error);
|
dol_print_error($db,$object->error);
|
||||||
@ -358,7 +358,7 @@ if ($object->type == 3)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -32,9 +33,9 @@ $langs->load("other");
|
|||||||
if ($conf->notification->enabled) $langs->load("mails");
|
if ($conf->notification->enabled) $langs->load("mails");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = GETPOST('socid','int');
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'societe','','');
|
$result = restrictedArea($user, 'societe', $socid, '&societe');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -66,7 +66,7 @@ if (! empty($canvas))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$result = restrictedArea($user, 'societe', $socid, '&societe', '', '', '', $objcanvas);
|
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user