2011-09-21 18:40:52 +02:00
< ? php
2011-09-21 15:05:32 +02:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2009 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2011-09-21 15:05:32 +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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2011-09-21 15:05:32 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
* or see https :// www . gnu . org /
2011-09-21 15:05:32 +02:00
*/
/**
2015-03-17 11:23:45 +01:00
* \defgroup ficheinter Module Interventions
2011-09-21 15:05:32 +02:00
* \brief Module to manage intervention cards
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modFicheinter . class . php
2011-09-21 15:05:32 +02:00
* \ingroup ficheinter
* \brief Fichier de description et activation du module Ficheinter
*/
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2011-09-21 15:05:32 +02:00
/**
2015-09-07 15:55:26 +02:00
* Class to describe and enable module Ficheinter
2011-09-21 15:05:32 +02:00
*/
2012-01-04 21:23:50 +01:00
class modFicheinter extends DolibarrModules
2011-09-21 15:05:32 +02:00
{
/**
2011-09-26 16:22:35 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 21:23:50 +01:00
* @ param DoliDB $db Database handler
2011-09-21 15:05:32 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2011-09-21 15:05:32 +02:00
{
global $conf ;
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 70 ;
2011-09-21 15:05:32 +02:00
$this -> family = " crm " ;
2019-06-21 13:25:40 +02:00
$this -> module_position = '41' ;
2011-09-21 15:05:32 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2011-09-21 15:05:32 +02:00
$this -> description = " Gestion des fiches d'intervention " ;
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
$this -> picto = " intervention " ;
// Data directories to create when module is enabled
$this -> dirs = array ( " /ficheinter/temp " );
// Dependencies
$this -> depends = array ( " modSociete " );
$this -> requiredby = array ();
$this -> conflictwith = array ();
2020-04-10 10:59:32 +02:00
$this -> langfiles = array ( " bills " , " companies " , " interventions " );
2011-09-21 15:05:32 +02:00
// Config pages
$this -> config_page_url = array ( " fichinter.php " );
2015-09-07 15:40:55 +02:00
// Constants
2011-09-21 15:05:32 +02:00
$this -> const = array ();
2020-04-10 10:59:32 +02:00
$r = 0 ;
2011-09-21 15:05:32 +02:00
$this -> const [ $r ][ 0 ] = " FICHEINTER_ADDON_PDF " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " soleil " ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " FICHEINTER_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " pacific " ;
$r ++ ;
2014-05-01 19:17:45 +02:00
// Boxes
2020-04-10 10:59:32 +02:00
$this -> boxes = array ( 0 => array ( 'file' => 'box_ficheinter.php' , 'enabledbydefaulton' => 'Home' ));
2011-09-21 15:05:32 +02:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'ficheinter' ;
2020-04-10 10:59:32 +02:00
$r = 0 ;
2011-09-21 15:05:32 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 61 ;
$this -> rights [ $r ][ 1 ] = 'Lire les fiches d\'intervention' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2011-09-21 15:05:32 +02:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 62 ;
$this -> rights [ $r ][ 1 ] = 'Creer/modifier les fiches d\'intervention' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'creer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 64 ;
$this -> rights [ $r ][ 1 ] = 'Supprimer les fiches d\'intervention' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 67 ;
$this -> rights [ $r ][ 1 ] = 'Exporter les fiches interventions' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 68 ;
$this -> rights [ $r ][ 1 ] = 'Envoyer les fiches d\'intervention par courriel' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
2020-04-10 10:59:32 +02:00
$this -> rights [ $r ][ 4 ] = 'ficheinter_advance' ; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2011-09-21 15:05:32 +02:00
$this -> rights [ $r ][ 5 ] = 'send' ;
2016-02-29 19:05:42 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 69 ;
$this -> rights [ $r ][ 1 ] = 'Valider les fiches d\'intervention ' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
2020-04-10 10:59:32 +02:00
$this -> rights [ $r ][ 4 ] = 'ficheinter_advance' ; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2016-02-29 19:05:42 +01:00
$this -> rights [ $r ][ 5 ] = 'validate' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 70 ;
$this -> rights [ $r ][ 1 ] = 'Dévalider les fiches d\'intervention' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
2020-04-10 10:59:32 +02:00
$this -> rights [ $r ][ 4 ] = 'ficheinter_advance' ; // Visible if option MAIN_USE_ADVANCED_PERMS is on
2016-02-29 19:05:42 +01:00
$this -> rights [ $r ][ 5 ] = 'unvalidate' ;
2018-02-25 10:55:02 +01:00
2016-09-30 13:02:13 +02:00
// Menus
//-------
2020-04-10 10:59:32 +02:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2018-02-25 10:55:02 +01:00
2011-09-21 15:05:32 +02:00
//Exports
//--------
2020-04-10 10:59:32 +02:00
$r = 1 ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'InterventionCardsAndInterventionLines' ; // Translation key (used only if key ExportDataset_xxx_z not found)
$this -> export_permission [ $r ] = array ( array ( " ficheinter " , " export " ));
$this -> export_fields_array [ $r ] = array (
's.rowid' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.zip' => 'Zip' , 's.town' => 'Town' , 's.fk_pays' => 'Country' , 's.phone' => 'Phone' ,
's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 's.ape' => 'ProfId3' , 's.idprof4' => 'ProfId4' , 's.code_compta' => 'CustomerAccountancyCode' ,
's.code_compta_fournisseur' => 'SupplierAccountancyCode' , 'f.rowid' => " InterId " , 'f.ref' => " InterRef " , 'f.datec' => " InterDateCreation " ,
'f.duree' => " InterDuration " , 'f.fk_statut' => 'InterStatus' , 'f.description' => " InterNote " );
$keyforselect = 'fichinter' ; $keyforelement = 'intervention' ; $keyforaliasextra = 'extra' ;
2019-10-24 15:57:34 +02:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2020-04-10 10:59:32 +02:00
$this -> export_fields_array [ $r ] += array (
'pj.ref' => 'ProjectRef' , 'pj.title' => 'ProjectLabel' ,
2019-10-24 15:57:34 +02:00
'fd.rowid' => 'InterLineId' ,
2020-04-10 10:59:32 +02:00
'fd.date' => " InterLineDate " , 'fd.duree' => " InterLineDuration " , 'fd.description' => " InterLineDesc "
2018-05-27 15:04:12 +02:00
);
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
// 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
// 's.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",
// 'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",
// 'fd.total_ht'=>"Numeric"
//);
2020-04-10 10:59:32 +02:00
$this -> export_TypeFields_array [ $r ] = array (
's.rowid' => " Numeric " , 's.nom' => 'Text' , 's.address' => 'Text' , 's.zip' => 'Text' , 's.town' => 'Text' , 's.fk_pays' => 'List:c_country:label' , 's.phone' => 'Text' , 's.siren' => 'Text' ,
's.siret' => 'Text' , 's.ape' => 'Text' , 's.idprof4' => 'Text' , 's.code_compta' => 'Text' , 's.code_compta_fournisseur' => 'Text' ,
'f.rowid' => 'Numeric' , 'f.ref' => " Text " , 'f.datec' => " Date " ,
'f.duree' => " Duree " , 'f.fk_statut' => 'Numeric' , 'f.description' => " Text " , 'f.datee' => " Date " , 'f.dateo' => " Date " , 'f.fulldayevent' => " Boolean " ,
'pj.ref' => 'Text' , 'pj.title' => 'Text' ,
'fd.rowid' => " Numeric " , 'fd.date' => " Date " , 'fd.duree' => " Duree " , 'fd.description' => " Text " , 'fd.total_ht' => " Numeric "
2018-05-27 15:04:12 +02:00
);
2020-04-10 10:59:32 +02:00
$this -> export_entities_array [ $r ] = array (
's.rowid' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.zip' => 'company' , 's.town' => 'company' , 's.fk_pays' => 'company' , 's.phone' => 'company' ,
's.siren' => 'company' , 's.siret' => 'company' , 's.ape' => 'company' , 's.idprof4' => 'company' , 's.code_compta' => 'company' ,
's.code_compta_fournisseur' => 'company' , 'f.rowid' => " intervention " , 'f.ref' => " intervention " , 'f.datec' => " intervention " , 'f.duree' => " intervention " ,
'f.fk_statut' => " intervention " , 'f.description' => " intervention " , 'pj.ref' => 'project' , 'pj.title' => 'project' , 'fd.rowid' => " inter_line " , 'fd.date' => " inter_line " ,
'fd.duree' => 'inter_line' , 'fd.description' => 'inter_line'
2018-05-27 15:04:12 +02:00
);
2020-04-10 10:59:32 +02:00
$this -> export_dependencies_array [ $r ] = array ( 'inter_line' => 'fd.rowid' ); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$keyforselect = 'fichinterdet' ; $keyforelement = 'inter_line' ; $keyforaliasextra = 'extradet' ;
2019-10-24 15:57:34 +02:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2011-09-21 15:05:32 +02:00
2020-04-10 10:59:32 +02:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'fichinter as f' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'fichinter_extrafields as extra ON f.rowid = extra.fk_object' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet as pj ON f.fk_projet = pj.rowid' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'fichinterdet as fd ON f.rowid = fd.fk_fichinter' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'fichinterdet_extrafields as extradet ON fd.rowid = extradet.fk_object,' ;
$this -> export_sql_end [ $r ] .= ' ' . MAIN_DB_PREFIX . 'societe as s' ;
$this -> export_sql_end [ $r ] .= ' WHERE f.fk_soc = s.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND f.entity IN (' . getEntity ( 'intervention' ) . ')' ;
2011-09-21 15:05:32 +02:00
$r ++ ;
}
/**
2019-02-26 21:13:07 +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
2012-01-04 21:23:50 +01:00
*
2019-02-26 21:13:07 +01:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
2011-09-21 15:05:32 +02:00
*/
2019-02-26 21:13:07 +01:00
public function init ( $options = '' )
2011-09-21 15:05:32 +02:00
{
global $conf ;
// Permissions
2012-03-03 17:37:45 +01:00
$this -> remove ( $options );
2011-09-21 15:05:32 +02:00
$sql = array (
2017-05-12 16:55:11 +02:00
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ' AND type = 'ficheinter' AND entity = " . $conf -> entity ,
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ','ficheinter', " . $conf -> entity . " ) " ,
2011-09-21 15:05:32 +02:00
);
2019-01-27 11:55:16 +01:00
return $this -> _init ( $sql , $options );
2011-09-21 15:05:32 +02:00
}
}