Suite fonction gnrique export
This commit is contained in:
parent
e5b5ca5887
commit
54f160a821
121
htdocs/exports/export.class.php
Normal file
121
htdocs/exports/export.class.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/exports/export.class.php
|
||||
\ingroup core
|
||||
\brief Fichier de la classe des exports
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class Export
|
||||
\brief Classe permettant la gestion des exports
|
||||
*/
|
||||
|
||||
class Export
|
||||
{
|
||||
var $array_export_code=array();
|
||||
var $array_export_module=array();
|
||||
var $array_export_label=array();
|
||||
var $array_export_fields_code=array();
|
||||
var $array_export_fields_label=array();
|
||||
var $array_export_sql=array();
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB Handler accès base de données
|
||||
*/
|
||||
function Export($DB)
|
||||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Charge les lots de données exportables
|
||||
* \param user Objet utilisateur qui exporte
|
||||
* \param filter Code export pour charger un lot de données particulier
|
||||
*/
|
||||
function load_arrays($user,$filter)
|
||||
{
|
||||
dolibarr_syslog("Export::load_arrays user=$user filter=$filter");
|
||||
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
$handle=opendir($dir);
|
||||
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($db);
|
||||
|
||||
if (is_array($module->export_code))
|
||||
{
|
||||
foreach($module->export_code as $r => $value)
|
||||
{
|
||||
if ($filter && $filter != $module->export_code[$r]) next;
|
||||
// Test si permissions ok \todo tester sur toutes permissions
|
||||
$perm=$module->export_permission[$r][0];
|
||||
if (strlen($perms[2]) > 0)
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($bool) // Permissions ok
|
||||
{
|
||||
dolibarr_syslog("Export chargé pour le module ".$modulename." en index ".$i);
|
||||
$this->array_export_module[$i]=$module;
|
||||
$this->array_export_code[$i]=$module->export_code[$r];
|
||||
$this->array_export_label[$i]=$module->export_label[$r];
|
||||
$this->array_export_fields_code[$i]=$module->export_fields_code[$r];
|
||||
$this->array_export_fields_label[$i]=$module->export_fields_label[$r];
|
||||
$this->array_export_sql[$i]=$module->export_sql[$r];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -26,10 +26,10 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/exports/export.class.php");
|
||||
|
||||
$langs->load("commercial");
|
||||
$langs->load("orders");
|
||||
$langs->load("exports");
|
||||
|
||||
$user->getrights();
|
||||
|
||||
@ -38,22 +38,89 @@ if (! $user->societe_id == 0)
|
||||
|
||||
|
||||
|
||||
$export=new Export($db);
|
||||
$export->load_arrays($user,isset($datatoexport)?$datatoexport:'');
|
||||
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("NewExport"));
|
||||
if (! isset($datatoexport))
|
||||
{
|
||||
llxHeader('',$langs->trans("NewExport"));
|
||||
|
||||
print_fiche_titre($langs->trans("NewExport"));
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
print_fiche_titre($langs->trans("NewExport"));
|
||||
print $langs->trans("SelectExportDataSet").'<br>';
|
||||
print '<br>';
|
||||
|
||||
// Affiche les modules d'exports
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="120">'.$langs->trans("Module").'</td>';
|
||||
print '<td>'.$langs->trans("ExportableDatas").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$val=true;
|
||||
if (sizeof($export->array_export_code))
|
||||
{
|
||||
foreach ($export->array_export_code as $key => $value)
|
||||
{
|
||||
$val=!$val;
|
||||
print '<tr '.$bc[$val].'><td>';
|
||||
print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
|
||||
print $export->array_export_module[$key]->getName();
|
||||
print '</td><td>';
|
||||
print $export->array_export_label[$key];
|
||||
print '</td><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/exports/export.php?datatoexport='.$export->array_export_code[$key].'">'.img_picto($langs->trans("NewExport"),'filenew').'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td '.$bc[false].' colspan="2">'.$langs->trans("NoExportableData").'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
if (isset($datatoexport))
|
||||
{
|
||||
llxHeader('',$langs->trans("NewExport"));
|
||||
|
||||
print_fiche_titre($langs->trans("NewExport")." - ".$export->array_export_label[0]);
|
||||
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
|
||||
print $langs->trans("SelectExportFields").'<br>';
|
||||
print '<br>';
|
||||
|
||||
print '<table>';
|
||||
print '<tr><td>'.$langs->trans("ExportableFields").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>'.$langs->trans("ExportedFields").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>';
|
||||
|
||||
// Champs exportables
|
||||
$fieldscode=split(',',$export->array_export_fields_code);
|
||||
$fieldslib=split(',',$export->array_export_fields_lib);
|
||||
foreach($fieldscode as $i=>$code)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
?>
|
||||
|
||||
@ -26,71 +26,20 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/exports/export.class.php");
|
||||
|
||||
$langs->load("commercial");
|
||||
$langs->load("orders");
|
||||
$langs->load("exports");
|
||||
|
||||
$user->getrights();
|
||||
|
||||
if (! $user->societe_id == 0)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
|
||||
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
$handle=opendir($dir);
|
||||
|
||||
// Recherche des exports disponibles
|
||||
$array_export_code=array();
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($db);
|
||||
|
||||
if (is_array($module->export_code))
|
||||
{
|
||||
foreach($module->export_code as $r => $value)
|
||||
{
|
||||
dolibarr_syslog("Exports trouvés pour le module ".$modulename);
|
||||
$perm=$module->export_permission[$r][0];
|
||||
if (strlen($perms[2]) > 0)
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($bool)
|
||||
{
|
||||
$array_export_module[$i]=$module;
|
||||
$array_export_code[$i]=$module->export_code[$r];
|
||||
$array_export_label[$i]=$module->export_label[$r];
|
||||
$array_export_fields_code[$i]=$module->export_fields_code[$r];
|
||||
$array_export_fields_label[$i]=$module->export_fields_label[$r];
|
||||
$array_export_sql[$i]=$module->export_sql[$r];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
|
||||
|
||||
$export=new Export($db);
|
||||
$export->load_arrays($user);
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("ExportsArea"));
|
||||
@ -127,22 +76,24 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||
// Affiche les modules d'exports
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Module").'</td>';
|
||||
print '<td width="120">'.$langs->trans("Module").'</td>';
|
||||
print '<td>'.$langs->trans("ExportableDatas").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$val=true;
|
||||
if (sizeof($array_export_code))
|
||||
if (sizeof($export->array_export_code))
|
||||
{
|
||||
foreach ($array_export_code as $key => $value)
|
||||
foreach ($export->array_export_code as $key => $value)
|
||||
{
|
||||
$val=!$val;
|
||||
print '<tr '.$bc[$val].'><td>';
|
||||
print img_object($array_export_module[$key]->getName(),$array_export_module[$key]->picto).' ';
|
||||
print $array_export_module[$key]->getName();
|
||||
print img_object($export->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
|
||||
print $export->array_export_module[$key]->getName();
|
||||
print '</td><td>';
|
||||
print $array_export_label[$key];
|
||||
print $export->array_export_label[$key];
|
||||
print '</td><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/exports/export.php?datatoexport='.$export->array_export_code[$key].'">'.img_picto($langs->trans("NewExport"),'filenew').'</a>';
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user