2015-01-26 17:21:35 +01:00
< ? php
/* Copyright ( C ) 2003 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-03-09 21:20:56 +01:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-01-26 17:21:35 +01:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2012 Juanjo Menent < jmenent @ 2 byte . es >
*
* 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 3 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 , see < http :// www . gnu . org / licenses />.
*/
/**
2015-03-17 11:23:45 +01:00
* \defgroup askpricesupplier Module askpricesupplier
2015-03-09 21:20:56 +01:00
* \brief Module to request supplier price proposals
2015-02-04 15:39:57 +01:00
* \file htdocs / core / modules / modAskPriceSupplier . class . php
* \ingroup askpricesupplier
2015-03-09 21:20:56 +01:00
* \brief File to describe and activate module AskPriceSupplier
2015-01-26 17:21:35 +01:00
*/
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
/**
2015-02-06 09:50:27 +01:00
* Classe de description et activation du module AskPriceSupllier
2015-01-26 17:21:35 +01:00
*/
class modAskPriceSupplier extends DolibarrModules
{
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
function __construct ( $db )
{
global $conf ;
$this -> db = $db ;
2015-03-04 17:54:43 +01:00
$this -> numero = 1120 ;
2015-01-26 17:21:35 +01:00
2015-01-29 10:44:23 +01:00
$this -> family = " products " ;
2015-01-26 17:21:35 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
$this -> description = " askpricesupplierDESC " ;
2015-03-04 17:54:43 +01:00
$this -> version = 'experimental' ;
2015-01-26 17:21:35 +01:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
$this -> special = 0 ;
$this -> picto = 'askpricesupplier' ;
$this -> dirs = array ();
// Dependancies
2015-03-04 17:54:43 +01:00
$this -> depends = array ( 'modFournisseur' );
2015-01-26 17:21:35 +01:00
$this -> requiredby = array ();
$this -> config_page_url = array ( " askpricesupplier.php " );
$this -> langfiles = array ( " askpricesupplier " );
// Constants
$this -> const = array ();
$r = 0 ;
2015-01-27 16:53:27 +01:00
$this -> const [ $r ][ 0 ] = " ASKPRICESUPPLIER_ADDON_PDF " ;
2015-01-26 17:21:35 +01:00
$this -> const [ $r ][ 1 ] = " chaine " ;
2015-01-28 17:27:26 +01:00
$this -> const [ $r ][ 2 ] = " aurore " ;
2015-03-04 17:54:43 +01:00
$this -> const [ $r ][ 3 ] = 'Name of submodule to generate PDF for supplier quotation request' ;
2015-01-27 16:53:27 +01:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " ASKPRICESUPPLIER_ADDON " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
2015-01-28 14:48:59 +01:00
$this -> const [ $r ][ 2 ] = " mod_askpricesupplier_marbre " ;
2015-03-04 17:54:43 +01:00
$this -> const [ $r ][ 3 ] = 'Name of submodule to number supplier quotation request' ;
2015-01-27 16:53:27 +01:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " DOL_DATA_ROOT/doctemplates/askpricesupplier " ;
$this -> const [ $r ][ 3 ] = " " ;
2015-01-26 17:21:35 +01:00
$this -> const [ $r ][ 4 ] = 0 ;
// Boxes
$this -> boxes = array ();
// Permissions
$this -> rights = array ();
$this -> rights_class = 'askpricesupplier' ;
$r = 0 ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 1 ] = 'Read supplier proposals' ; // libelle de la permission
2015-01-26 17:21:35 +01:00
$this -> rights [ $r ][ 3 ] = 1 ; // La permission est-elle une permission par defaut
2015-01-27 16:53:27 +01:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 1 ] = 'Create/modify supplier proposals' ; // libelle de la permission
2015-01-26 17:21:35 +01:00
$this -> rights [ $r ][ 3 ] = 1 ; // La permission est-elle une permission par defaut
2015-01-27 16:53:27 +01:00
$this -> rights [ $r ][ 4 ] = 'creer' ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 1 ] = 'Validate supplier proposals' ; // libelle de la permission
2015-01-26 17:21:35 +01:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2015-01-27 16:53:27 +01:00
$this -> rights [ $r ][ 4 ] = '' ;
2015-01-26 17:21:35 +01:00
$this -> rights [ $r ][ 5 ] = 'validate' ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Envoyer les demandes fournisseurs' ; // libelle de la permission
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2015-01-27 16:53:27 +01:00
$this -> rights [ $r ][ 4 ] = '' ;
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 5 ] = 'send_advance' ;
2015-01-26 17:21:35 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 1 ] = 'Delete supplier proposals' ; // libelle de la permission
2015-01-26 17:21:35 +01:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2015-01-27 16:53:27 +01:00
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
2015-03-04 17:54:43 +01:00
2015-01-29 10:44:23 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = $this -> numero + $r ; // id de la permission
2015-03-04 17:54:43 +01:00
$this -> rights [ $r ][ 1 ] = 'Close supplier price requests' ; // libelle de la permission
2015-01-29 10:44:23 +01:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
$this -> rights [ $r ][ 4 ] = 'cloturer' ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
// Main menu entries
$this -> menu = array (); // List of menus to add
$r = 0 ;
$this -> menu [ $r ] = array (
'fk_menu' => 'fk_mainmenu=commercial' , // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type' => 'left' , // This is a Left menu entry
'titre' => 'askpricesupplierMENU_LEFT_TITLE' ,
'leftmenu' => 'askpricesuppliersubmenu' ,
2015-01-27 16:53:27 +01:00
'url' => '/comm/askpricesupplier/index.php' ,
2015-01-26 17:21:35 +01:00
'langs' => 'askpricesupplier' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'enabled' => '$conf->askpricesupplier->enabled' , // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
2015-01-27 16:53:27 +01:00
'perms' => '$user->rights->askpricesupplier->lire' , // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
2015-01-26 17:21:35 +01:00
'user' => 2 // 0=Menu for internal users, 1=external users, 2=both
2015-03-04 17:54:43 +01:00
);
2015-01-26 17:21:35 +01:00
$r ++ ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
$this -> menu [ $r ] = array (
'fk_menu' => 'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu' ,
'type' => 'left' ,
'titre' => 'askpricesupplierMENU_LEFT_TITLE_NEW' ,
2015-03-04 17:54:43 +01:00
'url' => '/comm/askpricesupplier/card.php?action=create' ,
2015-01-26 17:21:35 +01:00
'langs' => 'askpricesupplier' ,
'enabled' => '$conf->askpricesupplier->enabled' ,
2015-01-27 16:53:27 +01:00
'perms' => '$user->rights->askpricesupplier->creer' ,
2015-01-26 17:21:35 +01:00
'user' => 2
);
$r ++ ;
2015-03-04 17:54:43 +01:00
2015-01-26 17:21:35 +01:00
$this -> menu [ $r ] = array (
'fk_menu' => 'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu' ,
'type' => 'left' ,
'titre' => 'askpricesupplierMENU_LEFT_TITLE_LIST' ,
2015-01-27 16:53:27 +01:00
'url' => '/comm/askpricesupplier/list.php' ,
2015-01-26 17:21:35 +01:00
'langs' => 'askpricesupplier' ,
'enabled' => '$conf->askpricesupplier->enabled' ,
2015-01-27 16:53:27 +01:00
'perms' => '$user->rights->askpricesupplier->lire' ,
2015-01-26 17:21:35 +01:00
'user' => 2
);
2015-03-04 17:54:43 +01:00
$r ++ ;
2015-01-26 17:21:35 +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
*/
function init ( $options = '' )
{
2015-01-28 15:37:52 +01:00
global $conf , $langs ;
// Remove permissions and default values
$this -> remove ( $options );
//ODT template
$src = DOL_DOCUMENT_ROOT . '/install/doctemplates/askpricesupplier/template_askpricesupplier.odt' ;
$dirodt = DOL_DATA_ROOT . '/doctemplates/askpricesupplier' ;
$dest = $dirodt . '/template_askpricesupplier.odt' ;
if ( file_exists ( $src ) && ! file_exists ( $dest ))
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
dol_mkdir ( $dirodt );
$result = dol_copy ( $src , $dest , 0 , 0 );
if ( $result < 0 )
{
$langs -> load ( " errors " );
$this -> error = $langs -> trans ( 'ErrorFailToCopyFile' , $src , $dest );
return 0 ;
}
}
$sql = array (
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> const [ 0 ][ 2 ] . " ' AND entity = " . $conf -> entity ,
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> const [ 0 ][ 2 ] . " ','askpricesupplier', " . $conf -> entity . " ) " ,
);
2015-01-26 17:21:35 +01:00
return $this -> _init ( $sql , $options );
}
/**
* 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 = '' )
{
$sql = array ();
return $this -> _remove ( $sql , $options );
}
2015-02-04 15:39:57 +01:00
}