2010-05-07 21:08:27 +02:00
< ? php
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2013-08-01 15:26:01 +02:00
* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2012-10-17 11:43:26 +02:00
* Copyright ( C ) 2012 Juanjo Menent < jmenent @ 2 byte . es >
2013-03-17 10:21:44 +01:00
* Copyright ( C ) 2013 Philippe Grand < philippe . grand @ atoo - net . com >
2010-05-07 21:08:27 +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
2010-05-07 21:08:27 +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
2011-08-01 01:24:38 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2010-05-07 21:08:27 +02:00
*/
2011-02-02 21:41:54 +01:00
/**
2011-01-30 11:00:10 +01:00
* \defgroup fournisseur Module suppliers
2010-05-07 21:08:27 +02:00
* \brief Module pour gerer des societes et contacts de type fournisseurs
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modFournisseur . class . php
2010-05-07 21:08:27 +02:00
* \ingroup fournisseur
* \brief Fichier de description et activation du module Fournisseur
*/
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2010-05-07 21:08:27 +02:00
2011-02-02 21:41:54 +01:00
/**
2012-04-11 15:27:03 +02:00
* Classe de description et activation du module Fournisseur
2010-05-07 21:08:27 +02:00
*/
class modFournisseur extends DolibarrModules
{
/**
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
2010-05-07 21:08:27 +02:00
*/
2012-07-30 17:17:33 +02:00
function __construct ( $db )
2010-05-07 21:08:27 +02:00
{
global $conf ;
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 40 ;
2010-05-07 21:08:27 +02:00
$this -> family = " products " ;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
$this -> description = " Gestion des fournisseurs " ;
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
$this -> special = 0 ;
$this -> picto = 'company' ;
// Data directories to create when module is enabled
$this -> dirs = array ( " /fournisseur/temp " ,
" /fournisseur/commande " ,
" /fournisseur/commande/temp " ,
" /fournisseur/facture " ,
" /fournisseur/facture/temp "
);
2012-01-04 21:23:50 +01:00
// Dependances
$this -> depends = array ( " modSociete " );
$this -> requiredby = array ();
2012-09-12 19:11:03 +02:00
$this -> langfiles = array ( 'bills' , 'companies' , 'suppliers' , 'orders' );
2012-01-04 21:23:50 +01:00
// Config pages
2013-03-16 15:24:14 +01:00
$this -> config_page_url = array ( " supplier_order.php " );
2012-01-04 21:23:50 +01:00
// Constantes
$this -> const = array ();
$r = 0 ;
$this -> const [ $r ][ 0 ] = " COMMANDE_SUPPLIER_ADDON_PDF " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " muscadet " ;
2013-03-17 10:21:44 +01:00
$this -> const [ $r ][ 3 ] = 'Nom du gestionnaire de generation des bons de commande en PDF' ;
$this -> const [ $r ][ 4 ] = 0 ;
2012-01-04 21:23:50 +01:00
$r ++ ;
2013-03-17 10:21:44 +01:00
$this -> const [ $r ][ 0 ] = " COMMANDE_SUPPLIER_ADDON_NUMBER " ;
2012-01-04 21:23:50 +01:00
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " mod_commande_fournisseur_muguet " ;
2013-03-17 10:21:44 +01:00
$this -> const [ $r ][ 3 ] = 'Nom du gestionnaire de numerotation des commandes fournisseur' ;
$this -> const [ $r ][ 4 ] = 0 ;
2012-01-04 21:23:50 +01:00
$r ++ ;
$this -> const [ $r ][ 0 ] = " INVOICE_SUPPLIER_ADDON_PDF " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " canelle " ;
2013-03-17 10:21:44 +01:00
$this -> const [ $r ][ 3 ] = 'Nom du gestionnaire de generation des factures fournisseur en PDF' ;
$this -> const [ $r ][ 4 ] = 0 ;
2012-01-04 21:23:50 +01:00
$r ++ ;
2013-08-06 13:22:00 +02:00
2013-03-16 15:24:14 +01:00
$this -> const [ $r ][ 0 ] = " INVOICE_SUPPLIER_ADDON_NUMBER " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
2013-03-17 15:27:52 +01:00
$this -> const [ $r ][ 2 ] = " mod_facture_fournisseur_cactus " ;
2013-03-17 10:21:44 +01:00
$this -> const [ $r ][ 3 ] = 'Nom du gestionnaire de numerotation des factures fournisseur' ;
$this -> const [ $r ][ 4 ] = 0 ;
2013-03-16 15:24:14 +01:00
$r ++ ;
2012-01-04 21:23:50 +01:00
// Boxes
2013-07-16 18:42:43 +02:00
$this -> boxes = array (
0 => array ( 'file' => 'box_graph_invoices_supplier_permonth.php' , 'enabledbydefaulton' => 'Home' ),
2013-07-18 16:53:31 +02:00
1 => array ( 'file' => 'box_graph_orders_supplier_permonth.php' , 'enabledbydefaulton' => 'Home' ),
2 => array ( 'file' => 'box_fournisseurs.php' , 'enabledbydefaulton' => 'Home' ),
3 => array ( 'file' => 'box_factures_fourn_imp.php' , 'enabledbydefaulton' => 'Home' ),
4 => array ( 'file' => 'box_factures_fourn.php' , 'enabledbydefaulton' => 'Home' ),
5 => array ( 'file' => 'box_supplier_orders.php' , 'enabledbydefaulton' => 'Home' ),
2013-07-16 18:42:43 +02:00
);
2012-06-04 16:54:20 +02:00
2012-01-04 21:23:50 +01:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'fournisseur' ;
$r = 0 ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1181 ;
$this -> rights [ $r ][ 1 ] = 'Consulter les fournisseurs' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 1 ;
$this -> rights [ $r ][ 4 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1182 ;
$this -> rights [ $r ][ 1 ] = 'Consulter 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 ] = 1183 ;
$this -> rights [ $r ][ 1 ] = 'Creer 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 ] = 1184 ;
$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 ] = 1185 ;
$this -> rights [ $r ][ 1 ] = 'Approuver une commande 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 ] = 1186 ;
$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 ] = 1187 ;
$this -> rights [ $r ][ 1 ] = 'Receptionner une commande 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 ] = 1188 ;
$this -> rights [ $r ][ 1 ] = 'Supprimer une commande fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'supprimer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1231 ;
$this -> rights [ $r ][ 1 ] = 'Consulter 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 ] = 1232 ;
$this -> rights [ $r ][ 1 ] = 'Creer 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 ] = 1233 ;
$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' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1234 ;
$this -> rights [ $r ][ 1 ] = 'Supprimer une facture fournisseur' ;
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'supprimer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1235 ;
$this -> rights [ $r ][ 1 ] = 'Envoyer les factures par mail' ;
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'supplier_invoice_advance' ;
$this -> rights [ $r ][ 5 ] = 'send' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1236 ;
$this -> rights [ $r ][ 1 ] = 'Exporter les factures fournisseurs, attributs et reglements' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'facture' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
2012-04-11 15:27:03 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 1237 ;
$this -> rights [ $r ][ 1 ] = 'Exporter les commande fournisseurs, attributs' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'commande' ;
$this -> rights [ $r ][ 5 ] = 'export' ;
2012-01-04 21:23:50 +01:00
// Exports
//--------
$r = 0 ;
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'Factures fournisseurs et lignes de facture' ;
$this -> export_icon [ $r ] = 'bill' ;
$this -> export_permission [ $r ] = array ( array ( " fournisseur " , " facture " , " export " ));
2014-04-18 11:21:15 +02:00
$this -> export_fields_array [ $r ] = array ( 's.rowid' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.zip' => 'Zip' , 's.town' => 'Town' , 'c.code' => 'CountryCode' , 's.phone' => 'Phone' , 's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 's.ape' => 'ProfId3' , 's.idprof4' => 'ProfId4' , 's.idprof5' => 'ProfId5' , 's.idprof6' => 'ProfId6' , 's.tva_intra' => 'VATIntra' , 'f.rowid' => " InvoiceId " , 'f.ref' => " InvoiceRef " , 'f.ref_supplier' => " RefSupplier " , 'f.datec' => " InvoiceDateCreation " , 'f.datef' => " DateInvoice " , 'f.total_ht' => " TotalHT " , 'f.total_ttc' => " TotalTTC " , 'f.total_tva' => " TotalVAT " , 'f.paye' => " InvoicePaid " , 'f.fk_statut' => 'InvoiceStatus' , 'f.note_public' => " InvoiceNote " , 'fd.rowid' => 'LineId' , 'fd.description' => " LineDescription " , 'fd.tva_tx' => " LineVATRate " , 'fd.qty' => " LineQty " , 'fd.remise_percent' => " Discount " , 'fd.total_ht' => " LineTotalHT " , 'fd.total_ttc' => " LineTotalTTC " , 'fd.tva' => " LineTotalVAT " , 'fd.product_type' => 'TypeOfLineServiceOrProduct' , 'fd.fk_product' => 'ProductId' , 'p.ref' => 'ProductRef' , 'p.label' => 'ProductLabel' , 'p.accountancy_code_buy' => 'ProductAccountancyBuyCode' );
2013-08-01 15:26:01 +02:00
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
2013-12-17 09:11:36 +01:00
$this -> export_TypeFields_array [ $r ] = array ( 's.nom' => 'Text' , 's.address' => 'Text' , 's.zip' => 'Text' , 's.town' => 'Text' , 'c.code' => 'Text' , 's.phone' => 'Text' , 's.siren' => 'Text' , 's.siret' => 'Text' , 's.ape' => 'Text' , 's.idprof4' => 'Text' , 's.tva_intra' => 'Text' , 'f.ref' => " Text " , 'f.ref_supplier' => " Text " , 'f.datec' => " Date " , 'f.datef' => " Date " , 'f.total_ht' => " Number " , 'f.total_ttc' => " Number " , 'f.total_tva' => " Number " , 'f.paye' => " Boolean " , 'f.fk_statut' => 'Status' , 'f.note_public' => " Text " , 'fd.description' => " Text " , 'fd.tva_tx' => " Text " , 'fd.qty' => " Number " , 'fd.total_ht' => " Number " , 'fd.total_ttc' => " Number " , 'fd.tva' => " Number " , 'fd.product_type' => 'Boolean' , 'fd.fk_product' => 'List:Product:label' , 'p.ref' => 'Text' , 'p.label' => 'Text' );
2014-04-18 11:21:15 +02:00
$this -> export_entities_array [ $r ] = array ( 's.rowid' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.zip' => 'company' , 's.town' => 'company' , 'c.code' => 'company' , 's.phone' => 'company' , 's.siren' => 'company' , 's.siret' => 'company' , 's.ape' => 'company' , 's.idprof4' => 'company' , 's.idprof5' => 'company' , 's.idprof6' => 'company' , 's.tva_intra' => 'company' , 'f.rowid' => " invoice " , 'f.ref' => " invoice " , 'f.ref_supplier' => " invoice " , 'f.datec' => " invoice " , 'f.datef' => " invoice " , 'f.total_ht' => " invoice " , 'f.total_ttc' => " invoice " , 'f.total_tva' => " invoice " , 'f.paye' => " invoice " , 'f.fk_statut' => 'invoice' , 'f.note_public' => " invoice " , 'fd.rowid' => 'invoice_line' , 'fd.description' => " invoice_line " , 'fd.tva_tx' => " invoice_line " , 'fd.qty' => " invoice_line " , 'fd.remise_percent' => " invoice_line " , 'fd.total_ht' => " invoice_line " , 'fd.total_ttc' => " invoice_line " , 'fd.tva' => " invoice_line " , 'fd.product_type' => 'invoice_line' , 'fd.fk_product' => 'product' , 'p.ref' => 'product' , 'p.label' => 'product' , 'p.accountancy_code_buy' => 'product' );
2012-07-28 11:28:37 +02:00
$this -> export_dependencies_array [ $r ] = array ( 'invoice_line' => 'fd.rowid' , 'product' => 'fd.rowid' ); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
2012-01-04 21:23:50 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
2012-04-08 00:05:52 +02:00
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as c ON s.fk_pays = c.rowid,' ;
$this -> export_sql_end [ $r ] .= ' ' . MAIN_DB_PREFIX . 'facture_fourn as f, ' . MAIN_DB_PREFIX . 'facture_fourn_det as fd' ;
2012-01-04 21:23:50 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p on (fd.fk_product = p.rowid)' ;
$this -> export_sql_end [ $r ] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn' ;
$this -> export_sql_end [ $r ] .= ' AND f.entity = ' . $conf -> entity ;
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'Factures fournisseurs et reglements' ;
$this -> export_icon [ $r ] = 'bill' ;
$this -> export_permission [ $r ] = array ( array ( " fournisseur " , " facture " , " export " ));
2013-12-17 09:11:36 +01:00
$this -> export_fields_array [ $r ] = array ( 's.rowid' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.zip' => 'Zip' , 's.town' => 'Town' , 'c.code' => 'CountryCode' , 's.phone' => 'Phone' , 's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 's.ape' => 'ProfId3' , 's.idprof4' => 'ProfId4' , 's.idprof5' => 'ProfId5' , 's.idprof6' => 'ProfId6' , 's.tva_intra' => 'VATIntra' , 'f.rowid' => " InvoiceId " , 'f.ref' => " InvoiceRef " , 'f.ref_supplier' => " RefSupplier " , 'f.datec' => " InvoiceDateCreation " , 'f.datef' => " DateInvoice " , 'f.total_ht' => " TotalHT " , 'f.total_ttc' => " TotalTTC " , 'f.total_tva' => " TotalVAT " , 'f.paye' => " InvoicePaid " , 'f.fk_statut' => 'InvoiceStatus' , 'f.note_public' => " InvoiceNote " , 'p.rowid' => 'PaymentId' , 'pf.amount' => 'AmountPayment' , 'p.datep' => 'DatePayment' , 'p.num_paiement' => 'PaymentNumber' );
2013-08-01 15:26:01 +02:00
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
2013-12-17 09:11:36 +01:00
$this -> export_TypeFields_array [ $r ] = array ( 's.nom' => 'Text' , 's.address' => 'Text' , 's.zip' => 'Text' , 's.town' => 'Text' , 'c.code' => 'Text' , 's.phone' => 'Text' , 's.siren' => 'Text' , 's.siret' => 'Text' , 's.ape' => 'Text' , 's.idprof4' => 'Text' , 's.tva_intra' => 'Text' , 'f.ref' => " Text " , 'f.ref_supplier' => " Text " , 'f.datec' => " Date " , 'f.datef' => " Date " , 'f.total_ht' => " Number " , 'f.total_ttc' => " Number " , 'f.total_tva' => " Number " , 'f.paye' => " Boolean " , 'f.fk_statut' => 'Status' , 'f.note_public' => " Text " , 'pf.amount' => 'Number' , 'p.datep' => 'Date' , 'p.num_paiement' => 'Number' );
$this -> export_entities_array [ $r ] = array ( 's.rowid' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.zip' => 'company' , 's.town' => 'company' , 'c.code' => 'company' , 's.phone' => 'company' , 's.siren' => 'company' , 's.siret' => 'company' , 's.ape' => 'company' , 's.idprof4' => 'company' , 's.idprof5' => 'company' , 's.idprof6' => 'company' , 's.tva_intra' => 'company' , 'f.rowid' => " invoice " , 'f.ref' => " invoice " , 'f.ref_supplier' => " invoice " , 'f.datec' => " invoice " , 'f.datef' => " invoice " , 'f.total_ht' => " invoice " , 'f.total_ttc' => " invoice " , 'f.total_tva' => " invoice " , 'f.paye' => " invoice " , 'f.fk_statut' => 'invoice' , 'f.note_public' => " invoice " , 'p.rowid' => 'payment' , 'pf.amount' => 'payment' , 'p.datep' => 'payment' , 'p.num_paiement' => 'payment' );
2012-07-28 11:28:37 +02:00
$this -> export_dependencies_array [ $r ] = array ( 'payment' => 'p.rowid' ); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
2012-01-04 21:23:50 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
2012-04-08 00:05:52 +02:00
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as c ON s.fk_pays = c.rowid,' ;
$this -> export_sql_end [ $r ] .= ' ' . MAIN_DB_PREFIX . 'facture_fourn as f' ;
2012-01-04 21:23:50 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn as p ON pf.fk_paiementfourn = p.rowid' ;
$this -> export_sql_end [ $r ] .= ' WHERE f.fk_soc = s.rowid' ;
$this -> export_sql_end [ $r ] .= ' AND f.entity = ' . $conf -> entity ;
2012-04-11 15:27:03 +02:00
$r ++ ;
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'Commandes fournisseurs et lignes de commandes' ;
$this -> export_icon [ $r ] = 'order' ;
$this -> export_permission [ $r ] = array ( array ( " fournisseur " , " commande " , " export " ));
2013-08-06 13:22:00 +02:00
$this -> export_fields_array [ $r ] = array ( 's.rowid' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.zip' => 'Zip' , 's.town' => 'Town' , 'c.code' => 'CountryCode' , 's.phone' => 'Phone' , 's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 's.ape' => 'ProfId3' , 's.idprof4' => 'ProfId4' , 's.idprof5' => 'ProfId5' , 's.idprof6' => 'ProfId6' , 's.tva_intra' => 'VATIntra' , 'f.rowid' => " OrderId " , 'f.ref' => " Ref " , 'f.ref_supplier' => " RefSupplier " , 'f.date_creation' => " DateCreation " , 'f.date_commande' => " OrderDate " , 'f.total_ht' => " TotalHT " , 'f.total_ttc' => " TotalTTC " , 'f.tva' => " TotalVAT " , 'f.fk_statut' => 'Status' , 'f.note_private' => " NotePrivate " , 'fd.rowid' => 'LineId' , 'fd.description' => " LineDescription " , 'fd.tva_tx' => " LineVATRate " , 'fd.qty' => " LineQty " , 'fd.remise_percent' => " Discount " , 'fd.total_ht' => " LineTotalHT " , 'fd.total_ttc' => " LineTotalTTC " , 'fd.total_tva' => " LineTotalVAT " , 'fd.product_type' => 'TypeOfLineServiceOrProduct' , 'fd.fk_product' => 'ProductId' , 'p.ref' => 'ProductRef' , 'p.label' => 'ProductLabel' );
$this -> export_TypeFields_array [ $r ] = array ( 's.rowid' => " company " , 's.nom' => 'Text' , 's.address' => 'Text' , 's.cp' => 'Text' , 's.ville' => 'Text' , 'c.code' => 'Text' , 's.tel' => 'Text' , 's.siren' => 'Text' , 's.siret' => 'Text' , 's.ape' => 'Text' , 's.idprof4' => 'Text' , 's.idprof5' => 'Text' , 's.idprof6' => 'Text' , 's.tva_intra' => 'Text' , 'f.ref' => " Text " , 'f.ref_supplier' => " Text " , 'f.date_creation' => " Date " , 'f.date_commande' => " Date " , 'f.total_ht' => " Number " , 'f.total_ttc' => " Number " , 'f.tva' => " Number " , 'f.fk_statut' => 'Status' , 'f.note_private' => " Text " , 'fd.description' => " Text " , 'fd.tva_tx' => " Number " , 'fd.qty' => " Number " , 'fd.remise_percent' => " Number " , 'fd.total_ht' => " Number " , 'fd.total_ttc' => " Number " , 'fd.total_tva' => " Number " , 'fd.product_type' => 'Boolean' , 'fd.fk_product' => 'List:Product:label' , 'p.ref' => 'Text' , 'p.label' => 'Text' );
$this -> export_entities_array [ $r ] = array ( 's.rowid' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.zip' => 'company' , 's.town' => 'company' , 'c.code' => 'company' , 's.phone' => 'company' , 's.siren' => 'company' , 's.siret' => 'company' , 's.ape' => 'company' , 's.idprof4' => 'company' , 's.idprof5' => 'company' , 's.idprof6' => 'company' , 's.tva_intra' => 'company' , 'f.rowid' => " order " , 'f.ref' => " order " , 'f.ref_supplier' => " order " , 'f.date_creation' => " order " , 'f.date_commande' => " order " , 'f.total_ht' => " order " , 'f.total_ttc' => " order " , 'f.tva' => " order " , 'f.fk_statut' => 'order' , 'f.note_private' => " order " , 'fd.rowid' => 'order_line' , 'fd.description' => " order_line " , 'fd.tva_tx' => " order_line " , 'fd.qty' => " order_line " , 'fd.remise_percent' => " order_line " , 'fd.total_ht' => " order_line " , 'fd.total_ttc' => " order_line " , 'fd.total_tva' => " order_line " , 'fd.product_type' => 'order_line' , 'fd.fk_product' => 'product' , 'p.ref' => 'product' , 'p.label' => 'product' );
2012-07-28 11:28:37 +02:00
$this -> export_dependencies_array [ $r ] = array ( 'order_line' => 'fd.rowid' , 'product' => 'fd.rowid' ); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
2012-04-11 15:27:03 +02:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'societe as s' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as c ON s.fk_pays = c.rowid,' ;
$this -> export_sql_end [ $r ] .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseur as f, ' . MAIN_DB_PREFIX . 'commande_fournisseurdet as fd' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p on (fd.fk_product = p.rowid)' ;
$this -> export_sql_end [ $r ] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande' ;
$this -> export_sql_end [ $r ] .= ' AND f.entity = ' . $conf -> entity ;
2010-05-07 21:08:27 +02:00
}
/**
2012-01-04 21:23:50 +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
*
* @ param string $options Options when enabling module ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
2010-05-07 21:08:27 +02:00
*/
2012-01-04 21:23:50 +01:00
function init ( $options = '' )
2010-05-07 21:08:27 +02:00
{
2010-07-10 01:15:06 +02:00
global $conf ;
2012-03-03 17:37:45 +01:00
$this -> remove ( $options );
2010-05-07 21:08:27 +02:00
2010-07-10 01:15:06 +02:00
$sql = array (
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> const [ 0 ][ 2 ] . " ' AND entity = " . $conf -> entity ,
2010-12-30 23:38:09 +01:00
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> const [ 0 ][ 2 ] . " ','order_supplier', " . $conf -> entity . " ) " ,
2010-07-10 01:15:06 +02:00
);
2010-05-07 21:08:27 +02:00
2012-01-04 21:23:50 +01:00
return $this -> _init ( $sql , $options );
2010-05-07 21:08:27 +02:00
}
2012-03-03 17:37:45 +01:00
/**
* Function called when module is disabled .
* Remove from database constants , boxes and permissions from Dolibarr database .
* Data directories are not deleted
*
* @ param string $options Options when enabling module ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
*/
function remove ( $options = '' )
{
2010-05-07 21:08:27 +02:00
$sql = array ();
2012-03-03 17:37:45 +01:00
return $this -> _remove ( $sql , $options );
}
2010-05-07 21:08:27 +02:00
}
?>