2005-10-13 23:39:38 +02:00
< ? php
2011-12-28 09:26:36 +01:00
/* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2009-04-27 22:37:50 +02:00
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
2007-01-05 16:34:43 +01:00
* Copyright ( C ) 2006 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2009-04-27 22:37:50 +02:00
* Copyright ( C ) 2007 Auguria SARL < info @ auguria . org >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-03-29 10:54:48 +02:00
* Copyright ( C ) 2011 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
2016-08-05 00:42:40 +02:00
* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
2015-02-26 14:15:33 +01:00
* Copyright ( C ) 2012 Cedric Salvador < csalvador @ gpcsolutions . fr >
2016-08-05 00:42:40 +02:00
* Copyright ( C ) 2016 Charlie Benke < charlie @ patas - monkey . com >
2016-08-01 10:20:10 +02:00
* Copyright ( C ) 2016 Ferran Marcet < fmarcet @ 2 byte . es >
2015-02-26 14:15:33 +01:00
*
2005-10-13 23:39:38 +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
2005-10-13 23:39:38 +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:19:04 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-10-13 23:39:38 +02:00
*/
/**
2012-04-16 12:01:32 +02:00
* \file htdocs / product / admin / product . php
2010-03-01 10:20:41 +01:00
* \ingroup produit
2012-04-16 12:01:32 +02:00
* \brief Setup page of product module
2008-08-28 02:31:27 +02:00
*/
2005-10-13 23:39:38 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
2017-04-12 19:30:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
2005-10-13 23:39:38 +02:00
2018-05-26 17:57:30 +02:00
// Load translation files required by the page
2017-12-22 10:56:52 +01:00
$langs -> loadLangs ( array ( " admin " , " products " ));
2005-10-13 23:39:38 +02:00
2008-10-24 23:36:12 +02:00
// Security check
2012-08-19 03:37:37 +02:00
if ( ! $user -> admin || ( empty ( $conf -> product -> enabled ) && empty ( $conf -> service -> enabled )))
2012-08-03 11:56:42 +02:00
accessforbidden ();
2005-10-13 23:39:38 +02:00
2012-03-29 10:54:48 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$value = GETPOST ( 'value' , 'alpha' );
2016-02-04 16:17:45 +01:00
$label = GETPOST ( 'label' , 'alpha' );
2017-08-23 10:07:00 +02:00
$scandir = GETPOST ( 'scan_dir' , 'alpha' );
2017-03-14 09:25:29 +01:00
$type = 'product' ;
2005-10-13 23:39:38 +02:00
2014-02-23 16:16:47 +01:00
// Pricing Rules
$select_pricing_rules = array (
2015-07-20 13:03:12 +02:00
'PRODUCT_PRICE_UNIQ' => $langs -> trans ( 'PriceCatalogue' ), // Unique price
'PRODUIT_MULTIPRICES' => $langs -> trans ( 'MultiPricesAbility' ), // Several prices according to a customer level
'PRODUIT_CUSTOMER_PRICES' => $langs -> trans ( 'PriceByCustomer' ), // Different price for each customer
2014-02-23 16:16:47 +01:00
);
2017-12-22 10:56:52 +01:00
$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY' ;
2018-01-14 15:58:04 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 1 || ! empty ( $conf -> global -> $keyforparam )) $select_pricing_rules [ 'PRODUIT_CUSTOMER_PRICES_BY_QTY' ] = $langs -> trans ( 'PriceByQuantity' ) . ' (' . $langs -> trans ( " VersionExperimental " ) . ')' ; // TODO If this is enabled, price must be hidden when price by qty is enabled, also price for quantity must be used when adding product into order/propal/invoice
2018-01-10 13:20:43 +01:00
$keyforparam = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES' ;
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 || ! empty ( $conf -> global -> $keyforparam )) $select_pricing_rules [ 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES' ] = $langs -> trans ( 'MultiPricesAbility' ) . '+' . $langs -> trans ( 'PriceByQuantity' ) . ' (' . $langs -> trans ( " VersionExperimental " ) . ')' ;
2014-02-23 16:16:47 +01:00
2015-04-02 19:41:19 +02:00
// Clean param
2016-03-02 11:38:40 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ) && empty ( $conf -> global -> PRODUIT_MULTIPRICES_LIMIT )) {
dolibarr_set_const ( $db , 'PRODUIT_MULTIPRICES_LIMIT' , 5 , 'chaine' , 0 , '' , $conf -> entity );
}
2015-04-02 19:41:19 +02:00
2017-04-12 19:30:01 +02:00
$error = 0 ;
2015-04-02 19:41:19 +02:00
2011-10-03 22:48:10 +02:00
/*
* Actions
*/
2015-07-20 13:03:12 +02:00
2017-06-01 12:11:45 +02:00
$nomessageinsetmoduleoptions = 1 ;
include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php' ;
2012-08-09 01:41:55 +02:00
if ( $action == 'setcodeproduct' )
{
if ( dolibarr_set_const ( $db , " PRODUCT_CODEPRODUCT_ADDON " , $value , 'chaine' , 0 , '' , $conf -> entity ) > 0 )
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ]);
2012-08-09 01:41:55 +02:00
exit ;
}
else
{
dol_print_error ( $db );
}
}
2016-08-01 10:20:10 +02:00
if ( $action == 'other' && GETPOST ( 'value_PRODUIT_LIMIT_SIZE' ) >= 0 )
2005-10-13 23:39:38 +02:00
{
2015-07-20 13:03:12 +02:00
$res = dolibarr_set_const ( $db , " PRODUIT_LIMIT_SIZE " , GETPOST ( 'value_PRODUIT_LIMIT_SIZE' ), 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
if ( ! $res > 0 ) $error ++ ;
2005-10-13 23:39:38 +02:00
}
2015-07-20 13:03:12 +02:00
if ( $action == 'other' && GETPOST ( 'value_PRODUIT_MULTIPRICES_LIMIT' ) > 0 )
2006-02-03 17:42:39 +01:00
{
2015-07-20 13:03:12 +02:00
$res = dolibarr_set_const ( $db , " PRODUIT_MULTIPRICES_LIMIT " , GETPOST ( 'value_PRODUIT_MULTIPRICES_LIMIT' ), 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
if ( ! $res > 0 ) $error ++ ;
2006-02-03 17:42:39 +01:00
}
2015-07-20 13:03:12 +02:00
if ( $action == 'other' )
2006-02-03 17:42:39 +01:00
{
2014-02-23 16:16:47 +01:00
$princingrules = GETPOST ( 'princingrule' , 'alpha' );
2014-05-01 11:54:48 +02:00
foreach ( $select_pricing_rules as $rule => $label ) // Loop on each possible mode
{
if ( $rule == $princingrules ) // We are on selected rule, we enable it
{
if ( $princingrules == 'PRODUCT_PRICE_UNIQ' ) // For this case, we disable entries manually
{
$res = dolibarr_set_const ( $db , 'PRODUIT_MULTIPRICES' , 0 , 'chaine' , 0 , '' , $conf -> entity );
$res = dolibarr_set_const ( $db , 'PRODUIT_CUSTOMER_PRICES_BY_QTY' , 0 , 'chaine' , 0 , '' , $conf -> entity );
$res = dolibarr_set_const ( $db , 'PRODUIT_CUSTOMER_PRICES' , 0 , 'chaine' , 0 , '' , $conf -> entity );
dolibarr_set_const ( $db , 'PRODUCT_PRICE_UNIQ' , 1 , 'chaine' , 0 , '' , $conf -> entity );
}
else
{
2014-02-23 16:16:47 +01:00
$multirule = explode ( '&' , $princingrules );
2014-10-04 17:20:17 +02:00
foreach ( $multirule as $rulesselected )
2014-05-01 11:54:48 +02:00
{
$res = dolibarr_set_const ( $db , $rulesselected , 1 , 'chaine' , 0 , '' , $conf -> entity );
2014-02-23 16:16:47 +01:00
}
}
2014-05-01 11:54:48 +02:00
}
else // We clear this mode
{
2014-02-23 16:16:47 +01:00
if ( strpos ( $rule , '&' ) === false ) {
2014-05-01 11:54:48 +02:00
$res = dolibarr_set_const ( $db , $rule , 0 , 'chaine' , 0 , '' , $conf -> entity );
2014-02-23 16:16:47 +01:00
}
}
2014-10-04 17:20:17 +02:00
}
2017-04-12 19:30:01 +02:00
2018-02-27 13:26:57 +01:00
$value = GETPOST ( 'PRODUIT_SOUSPRODUITS' , 'alpha' );
2015-07-20 13:03:12 +02:00
$res = dolibarr_set_const ( $db , " PRODUIT_SOUSPRODUITS " , $value , 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'activate_viewProdDescInForm' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUIT_DESC_IN_FORM " , $value , 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'activate_viewProdTextsInThirdpartyLanguage' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE " , $value , 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'activate_mergePropalProductCard' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUIT_PDF_MERGE_PROPAL " , $value , 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'activate_usesearchtoselectproduct' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUIT_USE_SEARCH_TO_SELECT " , $value , 'chaine' , 0 , '' , $conf -> entity );
2018-08-06 16:26:25 +02:00
$value = GETPOST ( 'activate_useProdFournDesc' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUIT_FOURN_TEXTS " , $value , 'chaine' , 0 , '' , $conf -> entity );
2018-08-06 17:21:20 +02:00
if ( $value ) {
$sql_test = " SELECT count(desc_fourn) as cpt FROM " . MAIN_DB_PREFIX . " product_fournisseur_price WHERE 1 " ;
$resql = $db -> query ( $sql_test );
if ( ! $resql && $db -> lasterrno == 'DB_ERROR_NOSUCHFIELD' ) // if the field does not exist, we create it
{
$sql_new = " ALTER TABLE " . MAIN_DB_PREFIX . " product_fournisseur_price ADD COLUMN desc_fourn text " ;
$resql_new = $db -> query ( $sql_new );
}
}
2006-12-01 16:37:26 +01:00
}
2016-02-04 16:17:45 +01:00
if ( $action == 'specimen' ) // For products
{
$modele = GETPOST ( 'module' , 'alpha' );
2017-04-12 19:30:01 +02:00
$product = new Product ( $db );
$product -> initAsSpecimen ();
2016-02-04 16:17:45 +01:00
// Search template files
$file = '' ; $classname = '' ; $filefound = 0 ;
$dirmodels = array_merge ( array ( '/' ),( array ) $conf -> modules_parts [ 'models' ]);
foreach ( $dirmodels as $reldir )
{
$file = dol_buildpath ( $reldir . " core/modules/product/doc/pdf_ " . $modele . " .modules.php " , 0 );
if ( file_exists ( $file ))
{
$filefound = 1 ;
$classname = " pdf_ " . $modele ;
break ;
}
}
if ( $filefound )
{
require_once $file ;
$module = new $classname ( $db );
2017-04-12 19:30:01 +02:00
if ( $module -> write_file ( $product , $langs , '' ) > 0 )
2016-02-04 16:17:45 +01:00
{
2017-04-12 19:30:01 +02:00
header ( " Location: " . DOL_URL_ROOT . " /document.php?modulepart=product&file=SPECIMEN.pdf " );
2016-02-04 16:17:45 +01:00
return ;
}
else
{
2018-07-25 15:36:50 +02:00
setEventMessages ( $obj -> error , $obj -> errors , 'errors' );
2016-02-04 16:17:45 +01:00
dol_syslog ( $obj -> error , LOG_ERR );
}
}
else
{
2018-07-25 15:36:50 +02:00
setEventMessages ( $langs -> trans ( " ErrorModuleNotFound " ), null , 'errors' );
2016-02-04 16:17:45 +01:00
dol_syslog ( $langs -> trans ( " ErrorModuleNotFound " ), LOG_ERR );
}
}
// Activate a model
if ( $action == 'set' )
{
$ret = addDocumentModel ( $value , $type , $label , $scandir );
}
if ( $action == 'del' )
{
$ret = delDocumentModel ( $value , $type );
if ( $ret > 0 )
{
if ( $conf -> global -> PRODUCT_ADDON_PDF == " $value " ) dolibarr_del_const ( $db , 'PRODUCT_ADDON_PDF' , $conf -> entity );
}
}
// Set default model
if ( $action == 'setdoc' )
{
if ( dolibarr_set_const ( $db , " PRODUCT_ADDON_PDF " , $value , 'chaine' , 0 , '' , $conf -> entity ))
{
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf -> global -> PRODUCT_ADDON_PDF = $value ;
}
// On active le modele
$ret = delDocumentModel ( $value , $type );
if ( $ret > 0 )
{
$ret = addDocumentModel ( $value , $type , $label , $scandir );
}
}
2015-07-20 13:03:12 +02:00
if ( $action == 'set' )
2006-12-01 16:37:26 +01:00
{
2012-03-29 10:54:48 +02:00
$const = " PRODUCT_SPECIAL_ " . strtoupper ( GETPOST ( 'spe' , 'alpha' ));
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'value' );
2012-03-29 10:54:48 +02:00
if ( GETPOST ( 'value' , 'alpha' )) $res = dolibarr_set_const ( $db , $const , $value , 'chaine' , 0 , '' , $conf -> entity );
2011-09-02 15:47:10 +02:00
else $res = dolibarr_del_const ( $db , $const , $conf -> entity );
2017-04-12 19:30:01 +02:00
if ( ! $res > 0 ) $error ++ ;
2006-06-08 11:46:25 +02:00
}
2011-09-02 15:47:10 +02:00
2015-07-20 13:03:12 +02:00
if ( $action == 'other' )
2015-02-26 14:15:33 +01:00
{
2015-07-20 13:03:12 +02:00
$value = GETPOST ( 'activate_units' , 'alpha' );
$res = dolibarr_set_const ( $db , " PRODUCT_USE_UNITS " , $value , 'chaine' , 0 , '' , $conf -> entity );
2017-04-12 19:30:01 +02:00
if ( ! $res > 0 ) $error ++ ;
2015-02-26 14:15:33 +01:00
}
2015-07-20 13:03:12 +02:00
if ( $action )
2011-09-02 15:47:10 +02:00
{
2017-04-12 19:30:01 +02:00
if ( ! $error )
2011-09-02 15:47:10 +02:00
{
2015-12-12 10:59:02 +01:00
setEventMessages ( $langs -> trans ( " SetupSaved " ), null , 'mesgs' );
2011-09-02 15:47:10 +02:00
}
else
{
2017-06-01 12:11:45 +02:00
setEventMessages ( $langs -> trans ( " SetupNotError " ), null , 'errors' );
2011-09-02 15:47:10 +02:00
}
}
2005-10-13 23:39:38 +02:00
/*
2011-03-05 14:56:09 +01:00
* View
2005-10-13 23:39:38 +02:00
*/
2008-01-03 20:02:40 +01:00
$formbarcode = new FormBarCode ( $db );
2011-12-28 09:26:36 +01:00
$title = $langs -> trans ( 'ProductServiceSetup' );
$tab = $langs -> trans ( " ProductsAndServices " );
if ( empty ( $conf -> produit -> enabled ))
{
$title = $langs -> trans ( 'ServiceSetup' );
$tab = $langs -> trans ( 'Services' );
}
else if ( empty ( $conf -> service -> enabled ))
{
$title = $langs -> trans ( 'ProductSetup' );
$tab = $langs -> trans ( 'Products' );
}
llxHeader ( '' , $title );
2005-10-13 23:39:38 +02:00
2018-02-26 09:20:05 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToModuleList " ) . '</a>' ;
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $title , $linkback , 'title_setup' );
2005-10-13 23:39:38 +02:00
2012-05-22 18:35:14 +02:00
$head = product_admin_prepare_head ();
2017-04-12 19:30:01 +02:00
dol_fiche_head ( $head , 'general' , $tab , - 1 , 'product' );
2011-03-05 14:56:09 +01:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2012-08-09 01:41:55 +02:00
2017-04-12 19:30:01 +02:00
// Module to manage product / services code
2012-08-09 01:41:55 +02:00
$dirproduct = array ( '/core/modules/product/' );
2017-03-14 09:25:29 +01:00
$dirmodels = array_merge ( array ( '/' ),( array ) $conf -> modules_parts [ 'models' ]);
2012-08-09 01:41:55 +02:00
2016-02-08 15:49:38 +01:00
print load_fiche_titre ( $langs -> trans ( " ProductCodeChecker " ), '' , '' );
2012-08-09 01:41:55 +02:00
print '<table class="noborder" width="100%">' . " \n " ;
print '<tr class="liste_titre">' . " \n " ;
print ' <td>' . $langs -> trans ( " Name " ) . '</td>' ;
print ' <td>' . $langs -> trans ( " Description " ) . '</td>' ;
print ' <td>' . $langs -> trans ( " Example " ) . '</td>' ;
print ' <td align="center" width="80">' . $langs -> trans ( " Status " ) . '</td>' ;
2013-05-07 22:04:08 +02:00
print ' <td align="center" width="60">' . $langs -> trans ( " ShortInfo " ) . '</td>' ;
2012-08-09 01:41:55 +02:00
print " </tr> \n " ;
$var = true ;
foreach ( $dirproduct as $dirroot )
{
$dir = dol_buildpath ( $dirroot , 0 );
$handle = @ opendir ( $dir );
if ( is_resource ( $handle ))
{
// Loop on each module find in opened directory
while (( $file = readdir ( $handle )) !== false )
{
if ( substr ( $file , 0 , 16 ) == 'mod_codeproduct_' && substr ( $file , - 3 ) == 'php' )
{
$file = substr ( $file , 0 , dol_strlen ( $file ) - 4 );
try {
2012-08-23 02:04:35 +02:00
dol_include_once ( $dirroot . $file . '.php' );
2012-08-09 01:41:55 +02:00
}
catch ( Exception $e )
{
dol_syslog ( $e -> getMessage (), LOG_ERR );
}
$modCodeProduct = new $file ;
// Show modules according to features level
if ( $modCodeProduct -> version == 'development' && $conf -> global -> MAIN_FEATURES_LEVEL < 2 ) continue ;
if ( $modCodeProduct -> version == 'experimental' && $conf -> global -> MAIN_FEATURES_LEVEL < 1 ) continue ;
$var = ! $var ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven">' . " \n " ;
2014-10-04 17:20:17 +02:00
print '<td width="140">' . $modCodeProduct -> name . '</td>' . " \n " ;
2012-08-09 01:41:55 +02:00
print '<td>' . $modCodeProduct -> info ( $langs ) . '</td>' . " \n " ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' . $modCodeProduct -> getExample ( $langs ) . '</td>' . " \n " ;
2012-08-09 01:41:55 +02:00
2012-08-15 09:06:36 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_CODEPRODUCT_ADDON ) && $conf -> global -> PRODUCT_CODEPRODUCT_ADDON == $file )
2012-08-09 01:41:55 +02:00
{
print '<td align="center">' . " \n " ;
print img_picto ( $langs -> trans ( " Activated " ), 'switch_on' );
print " </td> \n " ;
}
else
{
2012-08-09 01:51:45 +02:00
$disabled = false ;
2012-08-09 01:41:55 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ( is_object ( $mc ) && ! empty ( $mc -> sharings [ 'referent' ]) && $mc -> sharings [ 'referent' ] == $conf -> entity ) ? false : true );
print '<td align="center">' ;
2012-08-09 01:51:45 +02:00
if ( ! $disabled ) print '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=setcodeproduct&value=' . $file . '">' ;
2012-08-09 01:41:55 +02:00
print img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' );
if ( ! $disabled ) print '</a>' ;
print '</td>' ;
}
print '<td align="center">' ;
$s = $modCodeProduct -> getToolTip ( $langs , null , - 1 );
2016-03-25 15:24:57 +01:00
print $form -> textwithpicto ( '' , $s , 1 );
2012-08-09 01:41:55 +02:00
print '</td>' ;
print '</tr>' ;
}
}
closedir ( $handle );
}
}
print '</table>' ;
2017-04-12 19:30:01 +02:00
// Module to build doc
2016-02-04 16:17:45 +01:00
$def = array ();
$sql = " SELECT nom " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " document_model " ;
2017-03-14 09:25:29 +01:00
$sql .= " WHERE type = ' " . $type . " ' " ;
2016-02-04 16:17:45 +01:00
$sql .= " AND entity = " . $conf -> entity ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$i = 0 ;
$num_rows = $db -> num_rows ( $resql );
2017-03-14 09:25:29 +01:00
while ( $i < $num_rows )
2016-02-04 16:17:45 +01:00
{
2017-03-14 09:25:29 +01:00
$array = $db -> fetch_array ( $resql );
array_push ( $def , $array [ 0 ]);
$i ++ ;
2016-02-04 16:17:45 +01:00
}
}
else
{
2017-03-14 09:25:29 +01:00
dol_print_error ( $db );
2016-02-04 16:17:45 +01:00
}
2017-03-14 09:25:29 +01:00
2017-04-12 19:30:01 +02:00
print '<br>' ;
print load_fiche_titre ( $langs -> trans ( " ProductDocumentTemplates " ), '' , '' );
2017-03-14 09:25:29 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Name " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td align="center" width="60">' . $langs -> trans ( " Status " ) . " </td> \n " ;
print '<td align="center" width="60">' . $langs -> trans ( " Default " ) . " </td> \n " ;
print '<td align="center" width="80">' . $langs -> trans ( " ShortInfo " ) . '</td>' ;
print '<td align="center" width="80">' . $langs -> trans ( " Preview " ) . '</td>' ;
print " </tr> \n " ;
clearstatcache ();
foreach ( $dirmodels as $reldir )
{
foreach ( array ( '' , '/doc' ) as $valdir )
{
$dir = dol_buildpath ( $reldir . " core/modules/product " . $valdir );
if ( is_dir ( $dir ))
{
$handle = opendir ( $dir );
if ( is_resource ( $handle ))
{
while (( $file = readdir ( $handle )) !== false )
{
$filelist [] = $file ;
}
closedir ( $handle );
arsort ( $filelist );
foreach ( $filelist as $file )
{
if ( preg_match ( '/\.modules\.php$/i' , $file ) && preg_match ( '/^(pdf_|doc_)/' , $file ))
{
if ( file_exists ( $dir . '/' . $file ))
{
$name = substr ( $file , 4 , dol_strlen ( $file ) - 16 );
$classname = substr ( $file , 0 , dol_strlen ( $file ) - 12 );
require_once $dir . '/' . $file ;
$module = new $classname ( $db );
$modulequalified = 1 ;
if ( $module -> version == 'development' && $conf -> global -> MAIN_FEATURES_LEVEL < 2 ) $modulequalified = 0 ;
if ( $module -> version == 'experimental' && $conf -> global -> MAIN_FEATURES_LEVEL < 1 ) $modulequalified = 0 ;
if ( $modulequalified )
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td width="100">' ;
2017-03-14 09:25:29 +01:00
print ( empty ( $module -> name ) ? $name : $module -> name );
print " </td><td> \n " ;
if ( method_exists ( $module , 'info' )) print $module -> info ( $langs );
else print $module -> description ;
print '</td>' ;
// Active
if ( in_array ( $name , $def ))
{
print '<td align="center">' . " \n " ;
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=del&value=' . $name . '">' ;
print img_picto ( $langs -> trans ( " Enabled " ), 'switch_on' );
print '</a>' ;
print '</td>' ;
}
else
{
print '<td align="center">' . " \n " ;
2017-08-23 16:11:51 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=set&value=' . $name . '&scan_dir=' . $module -> scandir . '&label=' . urlencode ( $module -> name ) . '">' . img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' ) . '</a>' ;
2017-03-14 09:25:29 +01:00
print " </td> " ;
}
// Defaut
print '<td align="center">' ;
if ( $conf -> global -> PRODUCT_ADDON_PDF == $name )
{
print img_picto ( $langs -> trans ( " Default " ), 'on' );
}
else
{
2017-08-23 16:11:51 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=setdoc&value=' . $name . '&scan_dir=' . $module -> scandir . '&label=' . urlencode ( $module -> name ) . '" alt="' . $langs -> trans ( " Default " ) . '">' . img_picto ( $langs -> trans ( " Disabled " ), 'off' ) . '</a>' ;
2017-03-14 09:25:29 +01:00
}
print '</td>' ;
// Info
$htmltooltip = '' . $langs -> trans ( " Name " ) . ': ' . $module -> name ;
$htmltooltip .= '<br>' . $langs -> trans ( " Type " ) . ': ' . ( $module -> type ? $module -> type : $langs -> trans ( " Unknown " ));
if ( $module -> type == 'pdf' )
{
$htmltooltip .= '<br>' . $langs -> trans ( " Width " ) . '/' . $langs -> trans ( " Height " ) . ': ' . $module -> page_largeur . '/' . $module -> page_hauteur ;
}
$htmltooltip .= '<br><br><u>' . $langs -> trans ( " FeaturesSupported " ) . ':</u>' ;
$htmltooltip .= '<br>' . $langs -> trans ( " Logo " ) . ': ' . yn ( $module -> option_logo , 1 , 1 );
$htmltooltip .= '<br>' . $langs -> trans ( " MultiLanguage " ) . ': ' . yn ( $module -> option_multilang , 1 , 1 );
print '<td align="center">' ;
print $form -> textwithpicto ( '' , $htmltooltip , 1 , 0 );
print '</td>' ;
// Preview
print '<td align="center">' ;
if ( $module -> type == 'pdf' )
{
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=specimen&module=' . $name . '">' . img_object ( $langs -> trans ( " Preview " ), 'contract' ) . '</a>' ;
}
else
{
print img_object ( $langs -> trans ( " PreviewNotAvailable " ), 'generic' );
}
print '</td>' ;
print " </tr> \n " ;
}
}
}
}
}
}
}
}
print '</table>' ;
print " <br> " ;
2017-06-01 12:11:45 +02:00
2012-08-09 01:41:55 +02:00
/*
* Other conf
*/
print " <br> " ;
2016-02-08 15:49:38 +01:00
print load_fiche_titre ( $langs -> trans ( " ProductOtherConf " ), '' , '' );
2012-08-09 01:41:55 +02:00
2015-07-20 13:03:12 +02:00
print '<form method="POST" action="' . $_SERVER [ 'PHP_SELF' ] . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="other">' ;
2006-07-25 11:42:59 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2011-12-28 09:26:36 +01:00
print '<td>' . $langs -> trans ( " Parameters " ) . '</td>' . " \n " ;
print '<td align="right" width="60">' . $langs -> trans ( " Value " ) . '</td>' . " \n " ;
print '<td width="80"> </td></tr>' . " \n " ;
2006-07-25 11:42:59 +02:00
2015-07-20 13:03:12 +02:00
2005-10-13 23:39:38 +02:00
/*
2015-07-20 13:03:12 +02:00
* Other parameters
2005-10-13 23:39:38 +02:00
*/
2015-07-20 13:03:12 +02:00
$rowspan = 4 ;
2018-05-23 17:05:08 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ) || ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES )) $rowspan ++ ;
2015-07-20 13:03:12 +02:00
if ( empty ( $conf -> global -> PRODUIT_USE_SEARCH_TO_SELECT )) $rowspan ++ ;
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) $rowspan ++ ;
2018-08-06 16:26:25 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled )) $rowspan ++ ;
2014-02-23 16:16:47 +01:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2014-02-23 16:16:47 +01:00
print '<td>' . $langs -> trans ( " PricingRule " ) . '</td>' ;
2006-07-25 11:42:59 +02:00
print '<td width="60" align="right">' ;
2014-02-23 16:16:47 +01:00
$current_rule = 'PRODUCT_PRICE_UNIQ' ;
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) $current_rule = 'PRODUIT_MULTIPRICES' ;
if ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES_BY_QTY )) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY' ;
if ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES )) $current_rule = 'PRODUIT_CUSTOMER_PRICES' ;
2018-05-23 17:05:08 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES )) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES' ;
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " princingrule " , $select_pricing_rules , $current_rule );
2016-07-26 16:40:37 +02:00
if ( empty ( $conf -> multicompany -> enabled ))
{
print $langs -> trans ( " SamePriceAlsoForSharedCompanies " );
}
2015-10-06 16:12:09 +02:00
print '</td><td align="right" rowspan="' . $rowspan . '" class="nohover">' ;
2006-07-25 11:42:59 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '">' ;
2011-12-28 09:26:36 +01:00
print '</td>' ;
2006-02-03 17:42:39 +01:00
print '</tr>' ;
2006-02-03 19:21:55 +01:00
2006-02-03 17:42:39 +01:00
// multiprix nombre de prix a proposer
2018-05-23 17:05:08 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ) || ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES ))
2006-02-03 17:42:39 +01:00
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2008-08-28 02:31:27 +02:00
print '<td>' . $langs -> trans ( " MultiPricesNumPrices " ) . '</td>' ;
2015-07-20 13:03:12 +02:00
print '<td align="right"><input size="3" type="text" class="flat" name="value_PRODUIT_MULTIPRICES_LIMIT" value="' . $conf -> global -> PRODUIT_MULTIPRICES_LIMIT . '"></td>' ;
2008-08-28 02:31:27 +02:00
print '</tr>' ;
2006-02-03 17:42:39 +01:00
}
2006-03-22 10:03:55 +01:00
2006-02-20 11:58:10 +01:00
// sousproduits activation/desactivation
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2007-10-07 16:45:42 +02:00
print '<td>' . $langs -> trans ( " AssociatedProductsAbility " ) . '</td>' ;
2006-07-25 11:42:59 +02:00
print '<td width="60" align="right">' ;
2018-02-27 13:26:57 +01:00
print $form -> selectyesno ( " PRODUIT_SOUSPRODUITS " , $conf -> global -> PRODUIT_SOUSPRODUITS , 1 );
2011-12-28 09:26:36 +01:00
print '</td>' ;
2006-02-20 11:58:10 +01:00
print '</tr>' ;
2006-02-03 17:42:39 +01:00
2015-07-20 13:03:12 +02:00
// Utilisation formulaire Ajax sur choix produit
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2016-03-25 15:24:57 +01:00
print '<td>' . $form -> textwithpicto ( $langs -> trans ( " UseSearchToSelectProduct " ), $langs -> trans ( 'UseSearchToSelectProductTooltip' ), 1 ) . '</td>' ;
2012-08-15 09:06:36 +02:00
if ( empty ( $conf -> use_javascript_ajax ))
2006-10-22 15:30:13 +02:00
{
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" align="right" colspan="2">' ;
2008-08-28 02:31:27 +02:00
print $langs -> trans ( " NotAvailableWhenAjaxDisabled " );
2011-12-28 09:26:36 +01:00
print '</td>' ;
2006-10-22 15:30:13 +02:00
}
else
{
2008-08-28 02:31:27 +02:00
print '<td width="60" align="right">' ;
2015-07-20 13:03:12 +02:00
$arrval = array (
'0' => $langs -> trans ( " No " ),
'1' => $langs -> trans ( " Yes " ) . ' (' . $langs -> trans ( " NumberOfKeyToSearch " , 1 ) . ')' ,
'2' => $langs -> trans ( " Yes " ) . ' (' . $langs -> trans ( " NumberOfKeyToSearch " , 2 ) . ')' ,
'3' => $langs -> trans ( " Yes " ) . ' (' . $langs -> trans ( " NumberOfKeyToSearch " , 3 ) . ')' ,
2011-10-03 22:48:10 +02:00
);
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( " activate_usesearchtoselectproduct " , $arrval , $conf -> global -> PRODUIT_USE_SEARCH_TO_SELECT );
2011-12-28 09:26:36 +01:00
print '</td>' ;
2006-10-22 15:30:13 +02:00
}
2006-07-25 11:42:59 +02:00
print '</tr>' ;
2008-12-02 13:56:29 +01:00
if ( empty ( $conf -> global -> PRODUIT_USE_SEARCH_TO_SELECT ))
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2008-12-02 13:56:29 +01:00
print '<td>' . $langs -> trans ( " NumberOfProductShowInSelect " ) . '</td>' ;
2015-07-20 13:03:12 +02:00
print '<td align="right"><input size="3" type="text" class="flat" name="value_PRODUIT_LIMIT_SIZE" value="' . $conf -> global -> PRODUIT_LIMIT_SIZE . '"></td>' ;
2008-12-02 13:56:29 +01:00
print '</tr>' ;
}
2007-07-26 18:32:30 +02:00
// Visualiser description produit dans les formulaires activation/desactivation
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2007-10-07 16:45:42 +02:00
print '<td>' . $langs -> trans ( " ViewProductDescInFormAbility " ) . '</td>' ;
2007-07-26 18:32:30 +02:00
print '<td width="60" align="right">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( " activate_viewProdDescInForm " , $conf -> global -> PRODUIT_DESC_IN_FORM , 1 );
2011-12-28 09:26:36 +01:00
print '</td>' ;
2007-07-26 18:32:30 +02:00
print '</tr>' ;
2015-04-18 18:44:05 +02:00
// Activate propal merge produt card
2015-07-20 13:03:12 +02:00
/* Kept as hidden feature only . PRODUIT_PDF_MERGE_PROPAL can be added manually . Still did not understand how this feature works .
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-04-18 18:44:05 +02:00
print '<td>' . $langs -> trans ( " MergePropalProductCard " ) . '</td>' ;
print '<td width="60" align="right">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( " activate_mergePropalProductCard " , $conf -> global -> PRODUIT_PDF_MERGE_PROPAL , 1 );
2015-04-18 18:44:05 +02:00
print '</td>' ;
print '</tr>' ;
2015-07-20 13:03:12 +02:00
*/
2015-04-18 18:44:05 +02:00
2015-02-26 14:15:33 +01:00
// Use units
2015-07-20 13:03:12 +02:00
/* Kept as hidden feature only . PRODUCT_USE_UNITS is hidden for the moment . Because it seems to be a duplicated feature with already existing field to store unit of product
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-02-26 14:15:33 +01:00
print '<td>' . $langs -> trans ( " UseUnits " ) . '</td>' ;
print '<td width="60" align="right">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( " activate_units " , $conf -> global -> PRODUCT_USE_UNITS , 1 );
2015-02-26 14:15:33 +01:00
print '</td>' ;
print '</tr>' ;
2015-07-20 13:03:12 +02:00
*/
2015-02-26 14:15:33 +01:00
2012-01-13 17:46:15 +01:00
// View product description in thirdparty language
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2012-01-13 17:46:15 +01:00
print '<td>' . $langs -> trans ( " ViewProductDescInThirdpartyLanguageAbility " ) . '</td>' ;
print '<td width="60" align="right">' ;
2016-03-25 15:53:44 +01:00
print $form -> selectyesno ( " activate_viewProdTextsInThirdpartyLanguage " , ( ! empty ( $conf -> global -> PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE ) ? $conf -> global -> PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE : 0 ), 1 );
2012-01-13 17:46:15 +01:00
print '</td>' ;
print '</tr>' ;
}
2012-01-13 16:53:28 +01:00
2018-08-06 16:26:25 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ))
{
print '<tr class="oddeven">' ;
print '<td>' . $langs -> trans ( " UseProductFournDesc " ) . '</td>' ;
print '<td width="60" align="right">' ;
print $form -> selectyesno ( " activate_useProdFournDesc " , ( ! empty ( $conf -> global -> PRODUIT_FOURN_TEXTS ) ? $conf -> global -> PRODUIT_FOURN_TEXTS : 0 ), 1 );
print '</td>' ;
print '</tr>' ;
}
2012-01-13 16:53:28 +01:00
2012-08-15 09:06:36 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_CANVAS_ABILITY ))
2007-10-07 16:45:42 +02:00
{
2010-03-22 12:49:10 +01:00
// Add canvas feature
$dir = DOL_DOCUMENT_ROOT . " /product/canvas/ " ;
2010-04-30 20:39:21 +02:00
2007-10-07 16:45:42 +02:00
print '<tr class="liste_titre">' ;
2010-03-22 12:49:10 +01:00
print '<td>' . $langs -> trans ( " ProductSpecial " ) . '</td>' . " \n " ;
print '<td align="right" width="60">' . $langs -> trans ( " Value " ) . '</td>' . " \n " ;
print '<td width="80"> </td></tr>' . " \n " ;
2010-04-30 20:39:21 +02:00
2010-03-22 12:49:10 +01:00
if ( is_dir ( $dir ))
2007-01-05 16:34:43 +01:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
2010-04-30 20:39:21 +02:00
2009-08-02 18:47:06 +02:00
$handle = opendir ( $dir );
2010-12-15 19:15:08 +01:00
if ( is_resource ( $handle ))
{
while (( $file = readdir ( $handle )) !== false )
{
if ( file_exists ( $dir . $file . '/product.' . $file . '.class.php' ))
{
$classfile = $dir . $file . '/product.' . $file . '.class.php' ;
$classname = 'Product' . ucfirst ( $file );
2012-08-22 23:11:24 +02:00
require_once $classfile ;
2010-12-15 19:15:08 +01:00
$object = new $classname ();
$module = $object -> module ;
if ( $conf -> $module -> enabled )
{
2018-07-18 16:13:13 +02:00
print '<tr class="oddeven"><td>' ;
2010-12-15 19:15:08 +01:00
print $object -> description ;
print '</td><td align="right">' ;
$const = " PRODUCT_SPECIAL_ " . strtoupper ( $file );
if ( $conf -> global -> $const )
{
2011-08-17 17:56:22 +02:00
print img_picto ( $langs -> trans ( " Active " ), 'tick' );
2010-12-15 19:15:08 +01:00
print '</td><td align="right">' ;
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=set&spe=' . $file . '&value=0">' . $langs -> trans ( " Disable " ) . '</a>' ;
}
else
{
print ' </td><td align="right">' ;
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=set&spe=' . $file . '&value=1">' . $langs -> trans ( " Activate " ) . '</a>' ;
}
print '</td></tr>' ;
}
}
}
closedir ( $handle );
}
2009-08-02 18:47:06 +02:00
}
else
{
2015-11-05 11:11:51 +01:00
setEventMessages ( $dir . ' ' . $langs -> trans ( " IsNotADir " ), null , 'errors' );
2006-12-01 16:37:26 +01:00
}
}
2006-07-25 11:42:59 +02:00
2015-07-20 13:03:12 +02:00
print '</table>' ;
print '</form>' ;
2018-08-14 09:55:58 +02:00
// End of page
2012-01-13 17:46:15 +01:00
llxFooter ();
2005-10-13 23:39:38 +02:00
$db -> close ();