mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Add a parent class for dictionary classes
This commit is contained in:
parent
b43ca2a0ad
commit
c055d58028
|
|
@ -22,49 +22,19 @@
|
|||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
//require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage dictionary Countries (used by imports)
|
||||
*/
|
||||
class Ccountry // extends CommonObject
|
||||
class Ccountry extends Commondict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
public $element = 'ccountry'; //!< Id that identify managed objects
|
||||
public $table_element = 'c_country'; //!< Name of table without prefix where object is stored
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
public $code;
|
||||
public $code_iso;
|
||||
|
||||
/**
|
||||
* @var string Countries label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
public $active;
|
||||
|
||||
public $fields = array(
|
||||
'label' => array('type'=>'varchar(250)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>15, 'notnull'=>-1, 'showoncombobox'=>'1')
|
||||
);
|
||||
|
|
@ -90,7 +60,6 @@ class Ccountry // extends CommonObject
|
|||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -213,7 +182,6 @@ class Ccountry // extends CommonObject
|
|||
*/
|
||||
public function update($user = null, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -275,7 +243,6 @@ class Ccountry // extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".$this->db->prefix()."c_country";
|
||||
|
|
|
|||
|
|
@ -23,18 +23,14 @@
|
|||
* \ingroup resource
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
/**
|
||||
* Class CGenericDic
|
||||
*
|
||||
* @see CommonObject
|
||||
*/
|
||||
class CGenericDic
|
||||
class CGenericDic extends Commondict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Id to identify managed objects
|
||||
*/
|
||||
|
|
|
|||
70
htdocs/core/class/commondict.class.php
Normal file
70
htdocs/core/class/commondict.class.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/commondict.class.php
|
||||
* \ingroup core
|
||||
* \brief File of parent class of all other dictionary classes
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Parent class of all other dictionary classes
|
||||
*/
|
||||
abstract class CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDb Database handler (result of a new DoliDB)
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error string
|
||||
* @see $errors
|
||||
*/
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @var string[] Array of error strings
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* @var int The object identifier
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int The environment ID when using a multicompany module
|
||||
*/
|
||||
public $entity;
|
||||
|
||||
/**
|
||||
* @var string The code
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string The label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var int Is the entry active
|
||||
*/
|
||||
public $active;
|
||||
}
|
||||
|
|
@ -22,27 +22,15 @@
|
|||
* \brief This file is CRUD class file (Create/Read/Update/Delete) for c_units dictionary
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class of dictionary of nature of product (used by imports)
|
||||
*/
|
||||
class CProductNature // extends CommonObject
|
||||
class CProductNature extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* @var array record
|
||||
*/
|
||||
|
|
@ -58,26 +46,6 @@ class CProductNature // extends CommonObject
|
|||
*/
|
||||
public $table_element = 'c_product_nature';
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int code
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var int active
|
||||
*/
|
||||
public $active;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
|
|
@ -22,34 +22,18 @@
|
|||
* \brief This file is a CRUD class file (Create/Read/Update/Delete) for c_regions dictionary
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage dictionary Regions
|
||||
*/
|
||||
class Cregion
|
||||
class Cregion extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
//public $element = 'cregion'; //!< Id that identify managed objects
|
||||
//public $table_element = 'c_regions'; //!< Name of table without prefix where object is stored
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
public $code_region;
|
||||
public $fk_pays;
|
||||
|
||||
|
|
@ -63,7 +47,6 @@ class Cregion
|
|||
*/
|
||||
public $cheflieu;
|
||||
|
||||
public $active;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
|
|
@ -21,41 +21,21 @@
|
|||
* \brief This file is a CRUD class file (Create/Read/Update/Delete) for c_departements dictionary
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage dictionary States (used by imports)
|
||||
*/
|
||||
class Cstate // extends CommonObject
|
||||
class Cstate extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
//var $element='cstate'; //!< Id that identify managed objects
|
||||
//var $table_element='cstate'; //!< Name of table without prefix where object is stored
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $rowid;
|
||||
|
||||
public $code_departement;
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string name
|
||||
|
|
@ -69,12 +49,6 @@ class Cstate // extends CommonObject
|
|||
*/
|
||||
public $nom = '';
|
||||
|
||||
public $label;
|
||||
|
||||
public $active;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -206,7 +180,6 @@ class Cstate // extends CommonObject
|
|||
*/
|
||||
public function update($user = null, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -264,7 +237,6 @@ class Cstate // extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".$this->db->prefix()."c_departements";
|
||||
|
|
|
|||
|
|
@ -21,43 +21,21 @@
|
|||
* \brief This file is CRUD class file (Create/Read/Update/Delete) for c_typent dictionary
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class of dictionary type of thirdparty (used by imports)
|
||||
*/
|
||||
class Ctypent // extends CommonObject
|
||||
class Ctypent extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
// public $element = 'ctypent'; //!< Id that identify managed objects
|
||||
// public $table_element = 'ctypent'; //!< Name of table without prefix where object is stored
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int ID of country
|
||||
*/
|
||||
public $country_id;
|
||||
|
||||
public $code;
|
||||
public $libelle;
|
||||
public $active;
|
||||
public $module;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
* \ingroup resource
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class Ctyperesource
|
||||
*
|
||||
* @see CommonObject
|
||||
*/
|
||||
class Ctyperesource
|
||||
class Ctyperesource extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var string Id to identify managed objects
|
||||
|
|
@ -45,15 +47,6 @@ class Ctyperesource
|
|||
*/
|
||||
public $lines = array();
|
||||
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string Type resource label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
public $active;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
|
|
@ -21,45 +21,24 @@
|
|||
* \brief This file is CRUD class file (Create/Read/Update/Delete) for c_units dictionary
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class of dictionary type of thirdparty (used by imports)
|
||||
*/
|
||||
class CUnits // extends CommonObject
|
||||
class CUnits extends CommonDict
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
*/
|
||||
public $error = '';
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
*/
|
||||
public $errors = array();
|
||||
public $records = array();
|
||||
|
||||
//var $element='ctypent'; //!< Id that identify managed objects
|
||||
//var $table_element='ctypent'; //!< Name of table without prefix where object is stored
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
public $code;
|
||||
public $label;
|
||||
public $sortorder;
|
||||
public $short_label;
|
||||
public $unit_type;
|
||||
public $scale;
|
||||
public $active;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +61,6 @@ class CUnits // extends CommonObject
|
|||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -168,8 +146,6 @@ class CUnits // extends CommonObject
|
|||
*/
|
||||
public function fetch($id, $code = '', $short_label = '', $unit_type = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql .= " t.rowid,";
|
||||
$sql .= " t.code,";
|
||||
|
|
@ -234,8 +210,6 @@ class CUnits // extends CommonObject
|
|||
*/
|
||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$sql = "SELECT";
|
||||
|
|
@ -315,7 +289,6 @@ class CUnits // extends CommonObject
|
|||
*/
|
||||
public function update($user = null, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
|
@ -388,7 +361,6 @@ class CUnits // extends CommonObject
|
|||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".$this->db->prefix()."c_units";
|
||||
|
|
|
|||
3
htdocs/custom/.gitignore
vendored
3
htdocs/custom/.gitignore
vendored
|
|
@ -2,6 +2,3 @@
|
|||
!.gitignore
|
||||
!README.md
|
||||
!index.html
|
||||
/advancedhrm
|
||||
/ship2bill
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user