2004-10-20 00:24:10 +02:00
< ? php
2005-01-02 16:46:39 +01:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-02-17 18:16:31 +01:00
* Copyright ( C ) 2005 - 2006 Regis Houssin < regis . houssin @ cap - networks . com >
2003-09-14 12:34:31 +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 $
*/
2005-01-02 16:46:39 +01:00
/** \defgroup fournisseur Module fournisseur
2004-08-14 14:21:24 +02:00
\brief Module pour g<EFBFBD> rer des soci<EFBFBD> t<EFBFBD> s et contacts de type fournisseurs
*/
2005-01-02 16:46:39 +01:00
/**
2004-08-14 14:21:24 +02:00
\file htdocs / includes / modules / modFournisseur . class . php
2004-08-15 14:40:18 +02:00
\ingroup fournisseur
2004-08-14 14:21:24 +02:00
\brief Fichier de description et activation du module Fournisseur
*/
2003-11-13 16:09:12 +01:00
include_once " DolibarrModules.class.php " ;
2003-09-14 12:34:31 +02:00
2005-01-02 16:46:39 +01:00
/** \class modFournisseur
2004-10-20 00:24:10 +02:00
\brief Classe de description et activation du module Fournisseur
2004-08-15 14:40:18 +02:00
*/
2003-11-13 16:09:12 +01:00
class modFournisseur extends DolibarrModules
2003-09-14 12:34:31 +02:00
{
2006-02-09 22:44:25 +01:00
/**
* \brief Constructeur . Definit les noms , constantes et boites
* \param DB handler d ' acc<EFBFBD> s base
*/
function modFournisseur ( $DB )
{
$this -> db = $DB ;
$this -> id = 'fournisseur' ; // Same value xxx than in file modXxx.class.php file
$this -> numero = 40 ;
$this -> family = " products " ;
$this -> name = " Fournisseur " ;
$this -> description = " Gestion des fournisseurs " ;
$this -> revision = explode ( ' ' , '$Revision$' );
$this -> version = $this -> revision [ 1 ];
$this -> const_name = 'MAIN_MODULE_FOURNISSEUR' ;
$this -> special = 0 ;
$this -> picto = 'company' ;
// Dir
$this -> dirs = array ();
2006-02-25 15:47:47 +01:00
2006-02-09 22:44:25 +01:00
// D<> pendances
$this -> depends = array ( " modSociete " );
$this -> requiredby = array ();
2006-02-25 15:47:47 +01:00
$this -> langfiles = array ( " bills " , " companies " , " suppliers " );
2006-02-17 18:16:31 +01:00
2006-02-25 15:47:47 +01:00
// Config pages
2006-12-06 00:20:18 +01:00
$this -> config_page_url = array ( " fournisseur.php " );
2006-02-25 15:47:47 +01:00
2006-02-09 22:44:25 +01:00
// Constantes
$this -> const = array ();
2006-02-25 15:47:47 +01:00
$this -> const [ 0 ][ 0 ] = " COMMANDE_SUPPLIER_ADDON_PDF " ;
$this -> const [ 0 ][ 1 ] = " chaine " ;
$this -> const [ 0 ][ 2 ] = " muscadet " ;
$this -> const [ 1 ][ 0 ] = " COMMANDE_SUPPLIER_ADDON " ;
$this -> const [ 1 ][ 1 ] = " chaine " ;
$this -> const [ 1 ][ 2 ] = " emeraude " ;
2006-02-09 22:44:25 +01:00
// Boxes
$this -> boxes = array ();
2006-05-20 14:16:18 +02:00
$r = 0 ;
$this -> boxes [ $r ][ 0 ] = " Derniers founisseurs " ;
$this -> boxes [ $r ][ 1 ] = " box_fournisseurs.php " ;
$r ++ ;
$this -> boxes [ $r ][ 0 ] = " Factures fournisseurs r<> centes impay<61> es " ;
$this -> boxes [ $r ][ 1 ] = " box_factures_fourn_imp.php " ;
$r ++ ;
$this -> boxes [ $r ][ 0 ] = " Derni<EFBFBD> res factures fournisseurs saisies " ;
$this -> boxes [ $r ][ 1 ] = " box_factures_fourn.php " ;
$r ++ ;
2006-02-09 22:44:25 +01:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'fournisseur' ;
$r = 0 ;
2006-05-26 15:31:46 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 180 ;
$this -> rights [ $r ][ 1 ] = 'Consulter les fournisseurs' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 1 ;
$this -> rights [ $r ][ 4 ] = 'lire' ;
2006-02-09 22:44:25 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 181 ;
$this -> rights [ $r ][ 1 ] = 'Lire les commandes fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 1 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 182 ;
$this -> rights [ $r ][ 1 ] = 'Cr<43> er une commande fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'creer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 183 ;
$this -> rights [ $r ][ 1 ] = 'Valider une commande fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'valider' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 184 ;
$this -> rights [ $r ][ 1 ] = 'Approuver les commandes fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'approuver' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 185 ;
$this -> rights [ $r ][ 1 ] = 'Commander une commande fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'commander' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 186 ;
$this -> rights [ $r ][ 1 ] = 'R<> ceptionner les commandes fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'receptionner' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 187 ;
$this -> rights [ $r ][ 1 ] = 'Clot<6F> rer les commandes fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'cloturer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 188 ;
$this -> rights [ $r ][ 1 ] = 'Annuler les commandes fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'annuler' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 231 ;
$this -> rights [ $r ][ 1 ] = 'Lire les factures fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 1 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 232 ;
$this -> rights [ $r ][ 1 ] = 'Cr<43> er une facture fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'creer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 233 ;
$this -> rights [ $r ][ 1 ] = 'Valider une facture fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'valider' ;
2006-05-30 11:15:22 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 234 ;
$this -> rights [ $r ][ 1 ] = 'Supprimer une facture fournisseur' ;
2006-08-26 02:59:45 +02:00
$this -> rights [ $r ][ 2 ] = 'd' ;
2006-05-30 11:15:22 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'supprimer' ;
2006-02-09 22:44:25 +01:00
2006-08-26 02:59:45 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 236 ;
$this -> rights [ $r ][ 1 ] = 'Exporter les factures fournisseurs et attributs' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
2006-02-09 22:44:25 +01:00
// Exports
//--------
$r = 0 ;
2005-05-14 16:22:08 +02:00
2006-02-09 22:44:25 +01:00
$r ++ ;
$this -> export_code [ $r ] = $this -> id . '_' . $r ;
$this -> export_label [ $r ] = 'Factures fournisseurs 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.datec' => " DateCreation " , 'f.datef' => " DateInvoice " , 'f.total_ht' => " 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 " );
$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.datec' => " invoice " , 'f.datef' => " invoice " , 'f.total_ht' => " 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 " );
2006-09-13 20:56:30 +02:00
$this -> export_alias_array [ $r ] = array ( 's.idp' => " socid " , '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.datec' => " datecreation " , 'f.datef' => " dateinvoice " , 'f.total_ht' => " 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 " );
2006-02-09 22:44:25 +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_fourn as f, ' . MAIN_DB_PREFIX . 'facture_fourn_det as fd, ' . MAIN_DB_PREFIX . 'societe as s WHERE f.fk_soc = s.idp AND f.rowid = fd.fk_facture_fourn' ;
2006-02-09 22:44:25 +01:00
$this -> export_permission [ $r ] = array ( array ( " fournisseur " , " 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 .
*/
function init ()
{
$this -> remove ();
2006-02-17 15:34:53 +01:00
// Dir
$this -> dirs [ 0 ] = $conf -> fournisseur -> dir_output ;
2006-02-18 15:11:27 +01:00
//$this->dirs[1] = $conf->fournisseur->commande->dir_output;
//$this->dirs[2] = $conf->fournisseur->facture->dir_output;
2005-04-11 10:02:23 +02:00
2003-09-14 12:34:31 +02:00
$sql = array ();
2004-11-30 16:58:38 +01:00
$this -> load_datas ();
2004-09-06 21:45:23 +02:00
2003-09-14 12:34:31 +02:00
return $this -> _init ( $sql );
}
2004-11-23 21:04:19 +01:00
/**
* \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 .
2003-09-14 12:34:31 +02:00
*/
2004-08-07 19:14:42 +02:00
function remove ()
2003-09-14 12:34:31 +02:00
{
2005-01-14 19:44:58 +01:00
$sql = array ();
2003-09-14 12:34:31 +02:00
return $this -> _remove ( $sql );
}
2005-01-14 19:44:58 +01:00
2004-11-30 16:58:38 +01:00
/**
2005-01-14 19:44:58 +01:00
* \brief Fonction appel<EFBFBD> par l 'init (donc lors de l' activation d ' un module )
2004-11-30 16:58:38 +01:00
*
*/
function load_datas ()
{
$sql = " SELECT count(rowid) FROM " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
if ( $this -> db -> query ( $sql ))
{
$row = $this -> db -> fetch_row ();
if ( $row [ 0 ] == 0 )
{
$this -> db -> free ();
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
2005-01-14 19:44:58 +01:00
$sql .= " (code,libelle) VALUES ('OrderByMail','Courrier') " ;
2004-11-30 16:58:38 +01:00
$this -> db -> query ( $sql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
2005-01-14 19:44:58 +01:00
$sql .= " (code,libelle) VALUES ('OrderByFax','Fax') " ;
2004-11-30 16:58:38 +01:00
$this -> db -> query ( $sql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
2005-01-14 19:44:58 +01:00
$sql .= " (code,libelle) VALUES ('OrderByEMail','EMail') " ;
2004-11-30 16:58:38 +01:00
$this -> db -> query ( $sql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
2005-01-14 19:44:58 +01:00
$sql .= " (code,libelle) VALUES ('OrderByPhone','T<> l<EFBFBD> phone') " ;
2004-11-30 16:58:38 +01:00
$this -> db -> query ( $sql );
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " c_methode_commande_fournisseur " ;
2005-01-14 19:44:58 +01:00
$sql .= " (code,libelle) VALUES ('OrderByWWW','En ligne') " ;
2004-11-30 16:58:38 +01:00
$this -> db -> query ( $sql );
}
}
}
2003-09-14 12:34:31 +02:00
}
?>