mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-16 06:21:28 +01:00
Qual: Clean and uniformize code.
Remove properties, that are not related to business, from parent business class commonobject.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
echo '<br />';
|
||||
print_titre($langs->trans('RelatedCommercialProposals'));
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("orders");
|
||||
echo '<br />';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("bills");
|
||||
echo '<br />';
|
||||
|
||||
@@ -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 $');
|
||||
?>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("contracts");
|
||||
echo '<br />';
|
||||
|
||||
@@ -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,14 +1399,20 @@ 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";
|
||||
@@ -1428,12 +1425,14 @@ class CommonObject
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ($obj)
|
||||
{
|
||||
$this->id = $obj->rowid;
|
||||
$this->canvas = $obj->canvas;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
@@ -1601,7 +1600,8 @@ class CommonObject
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("interventions");
|
||||
echo '<br />';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("orders");
|
||||
echo '<br>';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* $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 @@
|
||||
<?php
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
|
||||
$langs->load("bills");
|
||||
echo '<br>';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,13 +25,14 @@
|
||||
* \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");
|
||||
@@ -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 $');
|
||||
|
||||
?>
|
||||
|
||||
@@ -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 $');
|
||||
?>
|
||||
|
||||
@@ -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 $');
|
||||
?>
|
||||
Reference in New Issue
Block a user