diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
index 625fe1da908..90316dec2a7 100644
--- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.8 2011/08/03 00:46:31 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.9 2011/08/22 22:04:28 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
echo '
';
print_titre($langs->trans('RelatedCommercialProposals'));
diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php
index 8d3c0e04e50..ed66107a2fd 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.10 2011/08/03 00:46:36 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.11 2011/08/22 22:04:25 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("orders");
echo '
';
diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
index 82a69280d08..88f6629180e 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.11 2011/08/03 00:46:35 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.12 2011/08/22 22:04:27 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("bills");
echo '
';
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index c37b9258f11..d0b0f4dabf4 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -23,7 +23,7 @@
* \file htdocs/contact/fiche.php
* \ingroup societe
* \brief Card of a contact
- * \version $Id: fiche.php,v 1.225 2011/08/13 00:48:00 eldy Exp $
+ * \version $Id: fiche.php,v 1.226 2011/08/22 22:04:26 eldy Exp $
*/
require("../main.inc.php");
@@ -38,20 +38,18 @@ $langs->load("users");
$langs->load("other");
$langs->load("commercial");
-$error=0; $errors=array();
+$mesg=''; $error=0; $errors=array();
$action = GETPOST('action');
-$socid = GETPOST("socid");
$id = GETPOST("id");
-
-// Security check
+$socid = GETPOST("socid");
if ($user->societe_id) $socid=$user->societe_id;
$object = new Contact($db);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
-if (!empty($id)) $object->getCanvas($id);
-$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
+if ($id) $object->getCanvas($id);
+$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
@@ -949,5 +947,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/13 00:48:00 $ - $Revision: 1.225 $');
+llxFooter('$Date: 2011/08/22 22:04:26 $ - $Revision: 1.226 $');
?>
diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php
index 0de5644be77..d607e835a82 100644
--- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.12 2011/07/31 23:50:01 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.13 2011/08/22 22:04:21 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("contracts");
echo '
';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 17c95dffac8..4078ef29546 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -21,33 +21,24 @@
* \file htdocs/core/class/commonobject.class.php
* \ingroup core
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
- * \version $Id: commonobject.class.php,v 1.158 2011/08/20 15:30:38 eldy Exp $
+ * \version $Id: commonobject.class.php,v 1.159 2011/08/22 22:04:22 eldy Exp $
*/
/**
* \class CommonObject
- * \brief Class of all other business classes (invoices, contracts, proposals, orders, ...)
+ * \brief Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
*/
-class CommonObject
+abstract class CommonObject
{
var $db;
- var $linkedObjectBlock;
- var $objectid;
+ var $canvas; // Contains canvas name if it is
- // Instantiate hook classe of thirdparty module
- var $hooks=array();
- /**
- * Constructeur de la classe
- * @param DB Handler acces base de donnees
- */
- function CommonObject($DB)
- {
- $this->db = $DB;
- }
+ // No constructor as it is an abstract class
+
/**
* \brief Check if ref is used.
@@ -1408,31 +1399,39 @@ class CommonObject
}
/**
- * Load type of canvas of an object
+ * Load type of canvas of an object if it exists
+ *
* @param id Record id
* @param ref Record ref
+ * @return int <0 if KO, 0 if nothing done, >0 if OK
*/
function getCanvas($id=0,$ref='')
{
global $conf;
+ if (empty($id) && empty($ref)) return 0;
+ if (! empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default.
+
+ // Clean parameters
$ref = trim($ref);
$sql = "SELECT rowid, canvas";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE entity = ".$conf->entity;
- if (!empty($id)) $sql.= " AND rowid = ".$id;
+ if (!empty($id)) $sql.= " AND rowid = ".$id;
if (!empty($ref)) $sql.= " AND ref = '".$ref."'";
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
-
- $this->id = $obj->rowid;
- $this->canvas = $obj->canvas;
-
- return 1;
+ if ($obj)
+ {
+ $this->id = $obj->rowid;
+ $this->canvas = $obj->canvas;
+ return 1;
+ }
+ else return 0;
}
else
{
@@ -1594,14 +1593,15 @@ class CommonObject
}
// To work with non standard path
- if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; }
- if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; }
- if ($objecttype == 'shipping') { $tplpath = 'expedition'; }
- if ($objecttype == 'delivery') { $tplpath = 'livraison'; }
+ if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; }
+ if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; }
+ if ($objecttype == 'shipping') { $tplpath = 'expedition'; }
+ if ($objecttype == 'delivery') { $tplpath = 'livraison'; }
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; }
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; }
- $this->linkedObjectBlock = $objects;
+ global $linkedObjectBlock;
+ $linkedObjectBlock = $objects;
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php');
}
diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
index 71c2a006abb..1285ea01f30 100755
--- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.2 2011/07/31 23:50:56 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.3 2011/08/22 22:04:26 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("interventions");
echo '
';
diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
index 15e1bd935fd..d5f12faac94 100755
--- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.4 2011/07/31 23:57:01 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.5 2011/08/22 22:04:23 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("orders");
echo '
';
diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
index 7be74b211e0..46a6ccfb0d4 100755
--- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * $Id: linkedobjectblock.tpl.php,v 1.4 2011/07/31 23:57:02 eldy Exp $
+ * $Id: linkedobjectblock.tpl.php,v 1.5 2011/08/22 22:04:26 eldy Exp $
*/
?>
@@ -23,7 +23,7 @@
linkedObjectBlock;
+$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("bills");
echo '
';
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index dc7216dce93..f3928365a76 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -28,7 +28,7 @@
* \file htdocs/lib/functions.lib.php
* \brief A set of functions for Dolibarr
* This file contains all frequently used functions.
- * \version $Id: functions.lib.php,v 1.563 2011/08/21 10:01:37 hregis Exp $
+ * \version $Id: functions.lib.php,v 1.564 2011/08/22 22:04:21 eldy Exp $
*/
// For compatibility during upgrade
@@ -2012,13 +2012,14 @@ function info_admin($text,$infoonimgalt=0)
/**
- * Check permissions of a user to show a page and an object. Check read permission
- * If $_REQUEST['action'] defined, we also check write and delete permission.
+ * Check permissions of a user to show a page and an object. Check read permission.
+ * If GETPOST('action') defined, we also check write and delete permission.
+ *
* @param user User to check
* @param features Features to check (in most cases, it's module name)
* @param objectid Object ID if we want to check permission on a particular record (optionnal)
* @param dbtablename Table name where object is stored. Not used if objectid is null (optionnal)
- * @param feature2 Feature to check (second level of permission)
+ * @param feature2 Feature to check, second level of permission (optionnal)
* @param dbt_keyfield Field name for socid foreign key if not fk_soc. (optionnal)
* @param dbt_select Field name for select if not rowid. (optionnal)
* @return int Always 1, die process if not allowed
@@ -2093,7 +2094,7 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
// Check write permission from module
$createok=1;
- if ( GETPOST("action") && GETPOST("action") == 'create')
+ if (GETPOST("action") && GETPOST("action") == 'create')
{
foreach ($features as $feature)
{
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 2ced1ae4e3b..4b3bd88bc8a 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -25,17 +25,18 @@
* \file htdocs/product/fiche.php
* \ingroup product
* \brief Page to show product
- * \version $Id: fiche.php,v 1.377 2011/08/13 13:03:03 eldy Exp $
+ * \version $Id: fiche.php,v 1.378 2011/08/22 22:04:25 eldy Exp $
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
-if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
-if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
+if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$langs->load("products");
@@ -43,25 +44,34 @@ $langs->load("other");
if ($conf->stock->enabled) $langs->load("stocks");
if ($conf->facture->enabled) $langs->load("bills");
+$mesg = ''; $error=0; $errors=array();
+
$id=GETPOST('id');
$ref=GETPOST('ref');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
+$socid=GETPOST("socid");
+if ($user->societe_id) $socid=$user->societe_id;
+
+$object = new Product($db);
+$extrafields = new ExtraFields($db);
+
+// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
+if ($id) $object->getCanvas($id);
+$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
+if (! empty($canvas))
+{
+ require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
+ $objcanvas = new Canvas($db,$action);
+ $objcanvas->getCanvas('product','card',$canvas);
+}
// Security check
if (isset($id) || isset($ref)) $value = isset($id)?$id:(isset($ref)?$ref:'');
$type = isset($ref)?'ref':'rowid';
-$socid=$user->societe_id?$user->societe_id:0;
$result=restrictedArea($user,'produit|service',$value,'product','','',$type);
-// For canvas usage
-if (empty($_GET["canvas"]))
-{
- $_GET["canvas"] = 'default@product';
- if ($_GET["type"] == 1) $_GET["canvas"] = 'service@product';
-}
-$mesg = '';
/*
@@ -71,7 +81,7 @@ $mesg = '';
if ($action == 'setproductaccountancycodebuy')
{
$product = new Product($db);
- $result=$product->fetch($_POST['id']);
+ $result=$product->fetch($id);
$product->accountancy_code_buy=$_POST["productaccountancycodebuy"];
$result=$product->update($product->id,$user,1,0,1);
if ($result < 0)
@@ -1643,6 +1653,6 @@ if ($product->id && $action == '' && $product->status)
$db->close();
-llxFooter('$Date: 2011/08/13 13:03:03 $ - $Revision: 1.377 $');
+llxFooter('$Date: 2011/08/22 22:04:25 $ - $Revision: 1.378 $');
?>
diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php
index bb542b052d6..9b0b1870cdf 100644
--- a/htdocs/product/liste.php
+++ b/htdocs/product/liste.php
@@ -21,7 +21,7 @@
* \file htdocs/product/liste.php
* \ingroup produit
* \brief Page to list products and services
- * \version $Id: liste.php,v 1.156 2011/08/21 10:12:18 eldy Exp $
+ * \version $Id: liste.php,v 1.157 2011/08/22 22:04:24 eldy Exp $
*/
require("../main.inc.php");
@@ -61,8 +61,8 @@ $action = GETPOST('action');
// Security check
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
-//if (!empty($id)) $object->getCanvas($id);
-$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
+//if ($id) $object->getCanvas($id);
+$canvas = GETPOST("canvas");
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
@@ -483,5 +483,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/21 10:12:18 $ - $Revision: 1.156 $');
+llxFooter('$Date: 2011/08/22 22:04:24 $ - $Revision: 1.157 $');
?>
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index f74fbc9fe56..af540246329 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -25,7 +25,7 @@
* \file htdocs/societe/soc.php
* \ingroup societe
* \brief Third party card page
- * \version $Id: soc.php,v 1.138 2011/08/18 22:25:46 eldy Exp $
+ * \version $Id: soc.php,v 1.139 2011/08/22 22:04:28 eldy Exp $
*/
require("../main.inc.php");
@@ -46,21 +46,19 @@ $langs->load("banks");
$langs->load("users");
if ($conf->notification->enabled) $langs->load("mails");
-$error=0; $errors=array();
+$mesg=''; $error=0; $errors=array();
$action = GETPOST('action');
$confirm = GETPOST('confirm');
+$socid = GETPOST("socid");
+if ($user->societe_id) $socid=$user->societe_id;
$object = new Societe($db);
$extrafields = new ExtraFields($db);
-// Security check
-$socid = GETPOST("socid");
-if ($user->societe_id) $socid=$user->societe_id;
-
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
-if (!empty($socid)) $object->getCanvas($socid);
-$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
+if ($socid) $object->getCanvas($socid);
+$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
@@ -1975,5 +1973,5 @@ else
$db->close();
-llxFooter('$Date: 2011/08/18 22:25:46 $ - $Revision: 1.138 $');
+llxFooter('$Date: 2011/08/22 22:04:28 $ - $Revision: 1.139 $');
?>
\ No newline at end of file