2005-04-13 11:51:00 +02:00
< ? php
2006-02-21 00:43:46 +01:00
/* Copyright ( C ) 2005 Matthieu Valleton < mv @ seeschloss . org >
2010-03-13 00:40:39 +01:00
* Copyright ( C ) 2005 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-04-13 11:51:00 +02:00
*
* 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 2 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
2011-08-01 01:24:38 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-04-13 11:51:00 +02:00
*/
2005-07-10 21:54:48 +02:00
/**
2009-11-06 15:57:16 +01:00
* \defgroup category Module categories
2010-03-13 00:40:39 +01:00
* \brief Module to manage categories
2011-08-31 12:27:17 +02:00
* \file htdocs / includes / modules / modCategorie . class . php
* \ingroup category
* \brief Fichier de description et activation du module Categorie
2009-11-06 15:57:16 +01:00
*/
2007-10-10 01:15:25 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /includes/modules/DolibarrModules.class.php " );
2005-04-13 11:51:00 +02:00
2006-07-23 03:38:43 +02:00
2006-01-22 19:31:56 +01:00
/**
2009-11-06 15:57:16 +01:00
* \class modCategorie
* \brief Classe de description et activation du module Categorie
*/
2005-04-13 11:51:00 +02:00
class modCategorie extends DolibarrModules
{
2006-07-23 03:38:43 +02:00
/**
2011-06-17 08:49:03 +02:00
* \brief Constructor
* \param DB Database handler
2006-07-23 03:38:43 +02:00
*/
function modCategorie ( $DB )
{
$this -> db = $DB ;
$this -> numero = 1780 ;
2009-02-11 16:09:59 +01:00
2007-12-03 03:18:10 +01:00
$this -> family = " technic " ;
2008-10-01 21:10:17 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2009-10-21 15:09:42 +02:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
$this -> description = " Gestion des categories (produits, clients, fournisseurs...) " ;
2009-02-11 16:09:59 +01:00
2008-12-15 23:25:59 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2009-02-11 16:09:59 +01:00
2008-10-06 09:39:52 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2009-02-11 16:09:59 +01:00
$this -> special = 2 ;
2009-11-06 15:57:16 +01:00
$this -> picto = 'category' ;
2009-02-11 16:09:59 +01:00
2009-05-04 13:40:00 +02:00
// Data directories to create when module is enabled
2006-07-23 03:38:43 +02:00
$this -> dirs = array ();
2009-02-11 16:09:59 +01:00
2008-12-05 00:06:45 +01:00
// Dependencies
2009-04-17 17:21:10 +02:00
$this -> depends = array ();
2009-02-11 16:09:59 +01:00
2008-12-05 00:06:45 +01:00
// Config pages
$this -> config_page_url = array ();
$this -> langfiles = array ( " products " , " companies " , " categories " );
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
// Constantes
$this -> const = array ();
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
// Boxes
$this -> boxes = array ();
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'categorie' ;
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
$r = 0 ;
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 0 ] = 241 ; // id de la permission
2008-10-28 21:37:30 +01:00
$this -> rights [ $r ][ 1 ] = 'Lire les categories' ; // libelle de la permission
2010-03-13 00:40:39 +01:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 1 ; // La permission est-elle une permission par defaut
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
$r ++ ;
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 0 ] = 242 ; // id de la permission
2008-10-28 21:37:30 +01:00
$this -> rights [ $r ][ 1 ] = 'Creer/modifier les categories' ; // libelle de la permission
2010-03-13 00:40:39 +01:00
$this -> rights [ $r ][ 2 ] = 'w' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 4 ] = 'creer' ;
$r ++ ;
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 0 ] = 243 ; // id de la permission
2008-10-28 21:37:30 +01:00
$this -> rights [ $r ][ 1 ] = 'Supprimer les categories' ; // libelle de la permission
2010-03-13 00:40:39 +01:00
$this -> rights [ $r ][ 2 ] = 'd' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2006-07-23 03:38:43 +02:00
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
$r ++ ;
2009-02-11 16:09:59 +01:00
2008-12-05 00:06:45 +01:00
// Exports
//--------
$r = 0 ;
$r ++ ;
2008-12-06 01:02:54 +01:00
$this -> export_code [ $r ] = 'category_' . $r ;
2009-03-05 12:11:32 +01:00
$this -> export_label [ $r ] = 'CatSupList' ;
2009-11-08 20:28:44 +01:00
$this -> export_icon [ $r ] = 'category' ;
2011-02-05 19:13:10 +01:00
$this -> export_enabled [ $r ] = '$conf->fournisseur->enabled' ;
2011-02-05 18:54:34 +01:00
$this -> export_permission [ $r ] = array ( array ( " categorie " , " lire " ), array ( " fournisseur " , " lire " ));
2009-04-10 02:29:23 +02:00
$this -> export_fields_array [ $r ] = array ( 'u.rowid' => " CategId " , 'u.label' => " Label " , 'u.description' => " Description " , 's.rowid' => 'IdThirdParty' , 's.nom' => 'Name' , 's.prefix_comm' => " Prefix " , 's.client' => " Customer " , 's.datec' => " DateCreation " , 's.tms' => " DateLastModification " , 's.code_client' => " CustomerCode " , 's.address' => " Address " , 's.cp' => " Zip " , 's.ville' => " Town " , 'p.libelle' => " Country " , 'p.code' => " CountryCode " , 's.tel' => " Phone " , 's.fax' => " Fax " , 's.url' => " Url " , 's.email' => " Email " , 's.siret' => " IdProf1 " , 's.siren' => " IdProf2 " , 's.ape' => " IdProf3 " , 's.idprof4' => " IdProf4 " , 's.tva_intra' => " VATIntraShort " , 's.capital' => " Capital " , 's.note' => " Note " );
2009-11-08 20:28:44 +01:00
$this -> export_entities_array [ $r ] = array ( 's.rowid' => 'company' , 's.nom' => 'company' , 's.prefix_comm' => " company " , 's.client' => " company " , 's.datec' => " company " , 's.tms' => " company " , 's.code_client' => " company " , 's.address' => " company " , 's.cp' => " company " , 's.ville' => " company " , 'p.libelle' => " company " , 'p.code' => " company " , 's.tel' => " company " , 's.fax' => " company " , 's.url' => " company " , 's.email' => " company " , 's.siret' => " company " , 's.siren' => " company " , 's.ape' => " company " , 's.idprof4' => " company " , 's.tva_intra' => " company " , 's.capital' => " company " , 's.note' => " company " ); // We define here only fields that use another picto
2008-12-05 00:06:45 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
2008-12-06 01:02:54 +01:00
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, ' . MAIN_DB_PREFIX . 'categorie_fournisseur as cf, ' . MAIN_DB_PREFIX . 'societe as s LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN ' . MAIN_DB_PREFIX . 'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code' ;
2008-12-05 00:06:45 +01:00
$this -> export_sql_end [ $r ] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND u.type = 1' ; // Supplier categories
$r ++ ;
2008-12-06 01:02:54 +01:00
$this -> export_code [ $r ] = 'category_' . $r ;
2009-03-05 12:11:32 +01:00
$this -> export_label [ $r ] = 'CatCusList' ;
2009-11-08 20:28:44 +01:00
$this -> export_icon [ $r ] = 'category' ;
2011-02-05 19:13:10 +01:00
$this -> export_enabled [ $r ] = '$conf->societe->enabled' ;
2011-02-05 18:54:34 +01:00
$this -> export_permission [ $r ] = array ( array ( " categorie " , " lire " ), array ( " societe " , " lire " ));
2009-11-08 20:28:44 +01:00
$this -> export_fields_array [ $r ] = array ( 'u.rowid' => " CategId " , 'u.label' => " Label " , 'u.description' => " Description " , 's.rowid' => 'IdThirdParty' , 's.nom' => 'Name' , 's.prefix_comm' => " Prefix " , 's.client' => " Customer " , 's.datec' => " DateCreation " , 's.tms' => " DateLastModification " , 's.code_client' => " CustomerCode " , 's.address' => " Address " , 's.cp' => " Zip " , 's.ville' => " Town " , 'p.libelle' => " Country " , 'p.code' => " CountryCode " , 's.tel' => " Phone " , 's.fax' => " Fax " , 's.url' => " Url " , 's.email' => " Email " , 's.siret' => " IdProf1 " , 's.siren' => " IdProf2 " , 's.ape' => " IdProf3 " , 's.idprof4' => " IdProf4 " , 's.tva_intra' => " VATIntraShort " , 's.capital' => " Capital " , 's.note' => " Note " , 's.fk_prospectlevel' => 'ProspectLevel' , 's.fk_stcomm' => 'ProspectStatus' );
$this -> export_entities_array [ $r ] = array ( 's.rowid' => 'company' , 's.nom' => 'company' , 's.prefix_comm' => " company " , 's.client' => " company " , 's.datec' => " company " , 's.tms' => " company " , 's.code_client' => " company " , 's.address' => " company " , 's.cp' => " company " , 's.ville' => " company " , 'p.libelle' => " company " , 'p.code' => " company " , 's.tel' => " company " , 's.fax' => " company " , 's.url' => " company " , 's.email' => " company " , 's.siret' => " company " , 's.siren' => " company " , 's.ape' => " company " , 's.idprof4' => " company " , 's.tva_intra' => " company " , 's.capital' => " company " , 's.note' => " company " , 's.fk_prospectlevel' => 'company' , 's.fk_stcomm' => 'company' ); // We define here only fields that use another picto
2008-12-05 00:06:45 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
2008-12-06 01:02:54 +01:00
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, ' . MAIN_DB_PREFIX . 'categorie_societe as cf, ' . MAIN_DB_PREFIX . 'societe as s LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN ' . MAIN_DB_PREFIX . 'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN ' . MAIN_DB_PREFIX . 'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code' ;
2008-12-05 00:06:45 +01:00
$this -> export_sql_end [ $r ] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND u.type = 2' ; // Customer/Prospect categories
2009-02-11 16:09:59 +01:00
2008-12-05 00:06:45 +01:00
$r ++ ;
2008-12-06 01:02:54 +01:00
$this -> export_code [ $r ] = 'category_' . $r ;
2009-03-05 12:11:32 +01:00
$this -> export_label [ $r ] = 'CatProdList' ;
2009-11-08 20:28:44 +01:00
$this -> export_icon [ $r ] = 'category' ;
2011-02-05 19:13:10 +01:00
$this -> export_enabled [ $r ] = '$conf->produit->enabled' ;
2011-02-05 18:54:34 +01:00
$this -> export_permission [ $r ] = array ( array ( " categorie " , " lire " ), array ( " produit " , " lire " ));
2008-12-05 00:06:45 +01:00
$this -> export_fields_array [ $r ] = array ( 'u.rowid' => " CategId " , 'u.label' => " Label " , 'u.description' => " Description " , 'p.rowid' => 'ProductId' , 'p.ref' => 'Ref' );
2009-11-08 20:28:44 +01:00
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => 'product' , 'p.ref' => 'product' ); // We define here only fields that use another picto
2008-12-05 00:06:45 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, ' . MAIN_DB_PREFIX . 'categorie_product as cp, ' . MAIN_DB_PREFIX . 'product as p' ;
$this -> export_sql_end [ $r ] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND u.type = 0' ; // Supplier categories
2010-03-20 21:24:32 +01:00
$r ++ ;
$this -> export_code [ $r ] = 'category_' . $r ;
$this -> export_label [ $r ] = 'CatMemberList' ;
$this -> export_icon [ $r ] = 'category' ;
2011-02-05 19:13:10 +01:00
$this -> export_enabled [ $r ] = '$conf->adherent->enabled' ;
2011-02-05 18:54:34 +01:00
$this -> export_permission [ $r ] = array ( array ( " categorie " , " lire " ), array ( " adherent " , " lire " ));
2010-03-20 21:24:32 +01:00
$this -> export_fields_array [ $r ] = array ( 'u.rowid' => " CategId " , 'u.label' => " Label " , 'u.description' => " Description " , 'p.rowid' => 'MemberId' , 'p.nom' => 'Name' , 'p.prenom' => 'Firstname' );
$this -> export_entities_array [ $r ] = array ( 'p.rowid' => 'member' , 'p.nom' => 'member' , 'p.prenom' => 'member' ); // We define here only fields that use another picto
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, ' . MAIN_DB_PREFIX . 'categorie_member as cp, ' . MAIN_DB_PREFIX . 'adherent as p' ;
$this -> export_sql_end [ $r ] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND u.type = 3' ; // Supplier categories
2006-07-23 03:38:43 +02:00
}
2011-02-05 18:57:31 +01:00
/**
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories .
* @ return int 1 if OK , 0 if KO
*/
2006-07-23 03:38:43 +02:00
function init ()
{
// Permissions
$this -> remove ();
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
$sql = array ();
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
return $this -> _init ( $sql );
}
2011-02-05 18:57:31 +01:00
/**
* Function called when module is disabled .
* Remove from database constants , boxes and permissions from Dolibarr database .
* Data directories are not deleted .
* @ return int 1 if OK , 0 if KO
*/
2006-07-23 03:38:43 +02:00
function remove ()
{
$sql = array ();
2009-02-11 16:09:59 +01:00
2006-07-23 03:38:43 +02:00
return $this -> _remove ( $sql );
}
2005-04-13 11:51:00 +02:00
}
?>