2004-10-20 00:24:10 +02:00
< ? php
2004-12-06 11:16:56 +01:00
/* Copyright ( C ) 2003 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2006-01-22 18:43:27 +01:00
* Copyright ( C ) 2004 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-05-14 16:22:08 +02:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2003-04-12 17:56:59 +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
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
2004-08-14 14:21:24 +02:00
2005-01-14 19:46:23 +01:00
/** \defgroup facture Module facture
2004-08-14 14:21:24 +02:00
\brief Module pour g<EFBFBD> rer les factures clients et / ou fournisseurs
*/
2004-08-15 14:40:18 +02:00
2006-01-22 18:43:27 +01:00
/**
\file htdocs / includes / modules / modFacture . class . php
2004-10-20 00:24:10 +02:00
\ingroup facture
\brief Fichier de la classe de description et activation du module Facture
2004-08-14 14:21:24 +02:00
*/
2003-11-13 16:09:12 +01:00
include_once " DolibarrModules.class.php " ;
2003-04-12 17:56:59 +02:00
2004-08-15 14:40:18 +02:00
2006-01-22 18:43:27 +01:00
/**
\class modFacture
2004-08-15 14:40:18 +02:00
\brief Classe de description et activation du module Facture
*/
2003-11-13 16:09:12 +01:00
class modFacture extends DolibarrModules
2003-05-16 14:48:12 +02:00
{
2003-04-12 17:56:59 +02:00
2004-11-23 21:04:19 +01:00
/**
* \brief Constructeur . Definit les noms , constantes et boites
2004-08-15 14:40:18 +02:00
* \param DB handler d ' acc<EFBFBD> s base
*/
2006-01-22 18:43:27 +01:00
function modFacture ( $DB )
{
$this -> db = $DB ;
2006-01-22 19:31:56 +01:00
$this -> id = 'invoice' ; // Same value xxx than in file modXxx.class.php file
2006-01-22 18:43:27 +01:00
$this -> numero = 30 ;
$this -> family = " financial " ;
$this -> name = " Factures " ;
$this -> description = " Gestion des factures " ;
$this -> revision = explode ( ' ' , '$Revision$' );
$this -> version = $this -> revision [ 1 ];
$this -> const_name = 'MAIN_MODULE_FACTURE' ;
$this -> special = 0 ;
$this -> picto = 'bill' ;
// Dir
$this -> dirs = array ();
// D<> pendances
2006-05-20 12:10:41 +02:00
$this -> depends = array ( " modSociete " );
$this -> requiredby = array ( " modComptabilite " , " modComptabiliteExpert " );
$this -> conflictwith = array ();
$this -> langfiles = array ( " bills " , " companies " );
2006-01-22 18:43:27 +01:00
// Config pages
$this -> config_page_url = " facture.php " ;
// Constantes
$this -> const = array ();
2006-06-10 23:31:10 +02:00
$r = 0 ;
$this -> const [ $r ][ 0 ] = " FACTURE_ADDON_PDF " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " bulot " ;
$r ++ ;
2006-01-22 18:43:27 +01:00
2006-06-10 23:31:10 +02:00
$this -> const [ $r ][ 0 ] = " FACTURE_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " pluton " ;
$r ++ ;
2006-01-22 18:43:27 +01:00
2006-06-10 23:31:10 +02:00
$this -> const [ $r ][ 0 ] = " FAC_FORCE_DATE_VALIDATION " ;
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
$r ++ ;
2006-02-11 17:24:55 +01:00
2006-06-10 23:31:10 +02:00
$this -> const [ $r ][ 0 ] = " FAC_ADD_PROD_DESC " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
$this -> const [ $r ][ 3 ] = " Mettre <20> 1 pour voir la description d'un produit dans une facture " ;
$this -> const [ $r ][ 4 ] = 1 ;
$r ++ ;
2006-01-22 18:43:27 +01:00
// Boites
$this -> boxes = array ();
2006-05-20 14:16:18 +02:00
$r = 0 ;
$this -> boxes [ $r ][ 0 ] = " Factures clients r<> centes impay<61> es " ;
$this -> boxes [ $r ][ 1 ] = " box_factures_imp.php " ;
$r ++ ;
$this -> boxes [ $r ][ 0 ] = " Derni<EFBFBD> res factures clients saisies " ;
$this -> boxes [ $r ][ 1 ] = " box_factures.php " ;
$r ++ ;
2006-01-22 18:43:27 +01:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'facture' ;
2006-02-09 22:44:25 +01:00
$r = 0 ;
2006-01-22 18:43:27 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 11 ;
$this -> rights [ $r ][ 1 ] = 'Lire les factures' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 1 ;
$this -> rights [ $r ][ 4 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 12 ;
2006-07-11 08:42:44 +02:00
$this -> rights [ $r ][ 1 ] = 'Cr<43> er les factures' ;
2006-01-22 18:43:27 +01:00
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'creer' ;
2006-07-11 08:42:44 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 13 ;
$this -> rights [ $r ][ 1 ] = 'Modifier les factures' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'modifier' ;
2006-01-22 18:43:27 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 14 ;
$this -> rights [ $r ][ 1 ] = 'Valider les factures' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'valider' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 15 ;
$this -> rights [ $r ][ 1 ] = 'Envoyer les factures par mail' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'envoyer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 16 ;
$this -> rights [ $r ][ 1 ] = 'Emettre des paiements sur les factures' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'paiement' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 19 ;
$this -> rights [ $r ][ 1 ] = 'Supprimer les factures' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1320 ;
2006-02-09 22:44:25 +01:00
$this -> rights [ $r ][ 1 ] = 'Exporter les factures clients et attributs' ;
2006-01-22 18:43:27 +01:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
/*
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1325 ;
$this -> rights [ $r ][ 1 ] = 'Exporter les paiements' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'paiement' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
*/
// Exports
//--------
$r = 0 ;
$r ++ ;
2006-01-22 19:31:56 +01:00
$this -> export_code [ $r ] = $this -> id . '_' . $r ;
2006-02-09 22:44:25 +01:00
$this -> export_label [ $r ] = 'Factures clients et lignes de facture' ;
2006-02-25 15:47:47 +01:00
$this -> export_fields_array [ $r ] = array ( 's.idp' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.cp' => 'Zip' , 's.ville' => 'Town' , 's.fk_pays' => 'Country' , 's.tel' => 'Phone' , 's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 'f.rowid' => " Id " , 'f.facnumber' => " Ref " , 'f.fk_soc' => " IdCompany " , 'f.datec' => " DateCreation " , 'f.datef' => " DateInvoice " , 'f.amount' => " Amount " , 'f.remise_percent' => " GlobalDiscount " , 'f.total' => " TotalHT " , 'f.total_ttc' => " TotalTTC " , 'f.paye' => " BillShortStatusPayed " , 'f.fk_statut' => 'Status' , 'f.note' => " Note " , 'fd.rowid' => 'LineId' , 'fd.description' => " LineDescription " , 'fd.tva_taux' => " LineVATRate " , 'fd.qty' => " LineQty " , 'fd.date_start' => " DateStart " , 'fd.date_end' => " DateEnd " );
$this -> export_entities_array [ $r ] = array ( 's.idp' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.cp' => 'company' , 's.ville' => 'company' , 's.fk_pays' => 'company' , 's.tel' => 'company' , 's.siren' => 'company' , 's.siret' => 'company' , 'f.rowid' => " invoice " , 'f.facnumber' => " invoice " , 'f.fk_soc' => " invoice " , 'f.datec' => " invoice " , 'f.datef' => " invoice " , 'f.amount' => " invoice " , 'f.remise_percent' => " invoice " , 'f.total' => " invoice " , 'f.total_ttc' => " invoice " , 'f.paye' => " invoice " , 'f.fk_statut' => 'invoice' , 'f.note' => " invoice " , 'fd.rowid' => 'invoice_line' , 'fd.description' => " invoice_line " , 'fd.tva_taux' => " invoice_line " , 'fd.qty' => " invoice_line " , 'fd.date_start' => " invoice_line " , 'fd.date_end' => " invoice_line " );
2006-06-19 22:35:22 +02:00
$this -> export_alias_array [ $r ] = array ( 's.idp' => " socidp " , 's.nom' => 'soc_name' , 's.address' => 'soc_adres' , 's.cp' => 'soc_zip' , 's.ville' => 'soc_ville' , 's.fk_pays' => 'soc_pays' , 's.tel' => 'soc_tel' , 's.siren' => 'soc_siren' , 's.siret' => 'soc_siret' , 'f.rowid' => " invoiceid " , 'f.facnumber' => " ref " , 'f.fk_soc' => " fk_soc " , 'f.datec' => " datecreation " , 'f.datef' => " dateinvoice " , 'f.amount' => " amount " , 'f.remise_percent' => " globaldiscount " , 'f.total' => " totalht " , 'f.total_ttc' => " totalttc " , 'f.paye' => " paid " , 'f.fk_statut' => 'status' , 'f.note' => " note " , 'fd.rowid' => 'lineid' , 'fd.description' => " linedescription " , 'fd.tva_taux' => " linevatrate " , 'fd.qty' => " lineqty " , 'fd.date_start' => " linedatestart " , 'fd.date_end' => " linedateend " );
2006-01-22 18:43:27 +01:00
$this -> export_sql [ $r ] = " select distinct " ;
$i = 0 ;
foreach ( $this -> export_alias_array [ $r ] as $key => $value )
{
if ( $i > 0 ) $this -> export_sql [ $r ] .= ', ' ;
else $i ++ ;
$this -> export_sql [ $r ] .= $key . ' as ' . $value ;
}
2006-02-25 15:47:47 +01:00
$this -> export_sql [ $r ] .= ' from ' . MAIN_DB_PREFIX . 'facture as f, ' . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s WHERE f.fk_soc = s.idp AND f.rowid = fd.fk_facture' ;
2006-01-22 18:43:27 +01:00
$this -> export_permission [ $r ] = array ( array ( " facture " , " facture " , " export " ));
}
2005-05-14 16:22:08 +02:00
/**
* \brief Fonction appel<EFBFBD> e lors de l ' activation du module . Ins<EFBFBD> re en base les constantes , boites , permissions du module .
* D<EFBFBD> finit <EFBFBD> galement les r<EFBFBD> pertoires de donn<EFBFBD> es <EFBFBD> cr<EFBFBD> er pour ce module .
*/
2006-01-22 18:43:27 +01:00
function init ()
{
global $conf ;
2005-05-14 16:22:08 +02:00
2006-01-22 18:43:27 +01:00
// Permissions
$this -> remove ();
2005-01-12 21:42:01 +01:00
2006-01-22 18:43:27 +01:00
// Dir
$this -> dirs [ 0 ] = $conf -> facture -> dir_output ;
$sql = array ();
return $this -> _init ( $sql );
}
/**
* \brief Fonction appel<EFBFBD> e lors de la d<EFBFBD> sactivation d ' un module .
* Supprime de la base les constantes , boites et permissions du module .
*/
function remove ()
{
$sql = array ();
return $this -> _remove ( $sql );
}
2003-04-12 17:56:59 +02:00
}
?>