From ce29331c05b959ede8810e6abcdf5bc10a2627ae Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 18 Jan 2018 12:34:22 +0100 Subject: [PATCH] NEW Filter export model by user --- htdocs/admin/export.php | 103 +++++++++++++++++++++ htdocs/core/class/html.formother.class.php | 4 +- htdocs/core/modules/modExport.class.php | 2 +- htdocs/exports/class/export.class.php | 2 + htdocs/exports/export.php | 4 +- htdocs/langs/fr_FR/exports.lang | 4 + 6 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 htdocs/admin/export.php diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php new file mode 100644 index 00000000000..58e8a1f6621 --- /dev/null +++ b/htdocs/admin/export.php @@ -0,0 +1,103 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2015 Philippe Grand + * + * 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 . + */ + +/** + * \file htdocs/admin/expedition.php + * \ingroup expedition + * \brief Page d'administration/configuration du module Expedition + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + + +$langs->load("admin"); +$langs->load("exports"); + +$langs->load('other'); + +if (! $user->admin) + accessforbidden(); + +$action=GETPOST('action','alpha'); +$value=GETPOST('value','alpha'); + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + +/* + * View + */ + +$page_name = "ExportSetup"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = '' + . $langs->trans("BackToModuleList") . ''; +print_fiche_titre($langs->trans($page_name), $linkback); + +// Configuration header + +dol_fiche_head( + $head, + 'settings', + $langs->trans("ExportsArea"), + 0, + "clialphadiab@clialphadiab" +); + +// Setup page goes here +$form=new Form($db); +$var=false; +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; + + +// Example with a yes / no select +$var=!$var; +print ''; +print ''; +print ''; +print ''; + + +print '
'.$langs->trans("ExportModel").' 
'.$langs->trans("set_EXPORTS_SHARE_MODELS").' '; +print '
'; +print ''; +print ''; +echo ajax_constantonoff('EXPORTS_SHARE_MODELS'); +print '
'; +print '
'; + +llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 492565cebc7..af9bd644caf 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -61,13 +61,15 @@ class FormOther * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Affiche valeur vide dans liste + * @param int $fk_user Utilisateur créant le modèle * @return void */ - function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0) + function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0, $fk_user=null) { $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; $sql.= " WHERE type = '".$type."'"; + if(!empty($fk_user))$sql.=" AND fk_user=".$fk_user; $sql.= " ORDER BY rowid"; $result = $this->db->query($sql); if ($result) diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index 70efc2c165f..4f754711ea1 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -58,7 +58,7 @@ class modExport extends DolibarrModules $this->dirs = array("/export/temp"); // Config pages - $this->config_page_url = array(); + $this->config_page_url = array("export.php"); // Dependencies $this->depends = array(); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index b1b9b42adc5..8a662c83dcf 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -697,11 +697,13 @@ class Export $sql.= 'label,'; $sql.= 'type,'; $sql.= 'field,'; + $sql.= 'fk_user,'; $sql.= 'filter'; $sql.= ') VALUES ('; $sql.= "'".$this->db->escape($this->model_name)."',"; $sql.= "'".$this->db->escape($this->datatoexport)."',"; $sql.= "'".$this->db->escape($this->hexa)."',"; + $sql.= "'".$user->id."',"; $sql.= "'".$this->db->escape($this->hexafiltervalue)."'"; $sql.= ")"; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index a21dcdce7a6..92a63afcd0e 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -551,7 +551,8 @@ if ($step == 2 && $datatoexport) print ''; print '
'; print $langs->trans("SelectExportFields").' '; - $htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1); + if(empty($conf->global->EXPORTS_SHARE_MODELS))$htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1,$user->id); + else $htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1); print ' '; print ''; print '
'; @@ -1082,6 +1083,7 @@ if ($step == 4 && $datatoexport) $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; $sql.= " WHERE type = '".$datatoexport."'"; + if(empty($conf->global->EXPORTS_SHARE_MODELS))$sql.=" AND fk_user=".$user->id; $sql.= " ORDER BY rowid"; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 6cd067822a2..48df77c7641 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -131,3 +131,7 @@ KeysToUseForUpdates=Clé à utiliser pour mettre à jour les données NbInsert=Nombre de lignes insérées: %s NbUpdate=Nombre de lignes mises à jour: %s MultipleRecordFoundWithTheseFilters=Plusieurs enregistrements ont été trouvés avec ces filtres: %s +## setup page +ExportSetup=Configuration du module Export +ExportModel = Modèle d'export +set_EXPORTS_SHARE_MODELS = Partager tous les profils d'export \ No newline at end of file