mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Work on import module
This commit is contained in:
parent
1af4674b5c
commit
8b12e7c07b
|
|
@ -18,192 +18,199 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/exports/export.class.php
|
||||
\ingroup export
|
||||
\brief Fichier de la classe des exports
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/exports/export.class.php
|
||||
* \ingroup export
|
||||
* \brief Fichier de la classe des exports
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class Export
|
||||
\brief Classe permettant la gestion des exports
|
||||
*/
|
||||
|
||||
* \class Export
|
||||
* \brief Classe permettant la gestion des exports
|
||||
*/
|
||||
class Export
|
||||
{
|
||||
var $db;
|
||||
|
||||
var $array_export_code=array(); // Tableau de "idmodule_numlot"
|
||||
var $array_export_module=array(); // Tableau de "nom de modules"
|
||||
var $array_export_label=array(); // Tableau de "libelle de lots"
|
||||
var $array_export_sql=array(); // Tableau des "requetes sql"
|
||||
var $array_export_fields=array(); // Tableau des listes de champ+libell<6C> <20> exporter
|
||||
var $array_export_alias=array(); // Tableau des listes de champ+alias <20> exporter
|
||||
var $array_export_special=array(); // Tableau des operations speciales sur champ
|
||||
var $array_export_module=array(); // Tableau de "nom de modules"
|
||||
var $array_export_label=array(); // Tableau de "libelle de lots"
|
||||
var $array_export_sql=array(); // Tableau des "requetes sql"
|
||||
var $array_export_fields=array(); // Tableau des listes de champ+libell<6C> <20> exporter
|
||||
var $array_export_alias=array(); // Tableau des listes de champ+alias <20> exporter
|
||||
var $array_export_special=array(); // Tableau des operations speciales sur champ
|
||||
|
||||
// To store export modules
|
||||
var $hexa;
|
||||
var $datatoexport;
|
||||
var $model_name;
|
||||
// To store export modules
|
||||
var $hexa;
|
||||
var $datatoexport;
|
||||
var $model_name;
|
||||
|
||||
var $sqlusedforexport;
|
||||
var $sqlusedforexport;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB Handler acces base de donnees
|
||||
*/
|
||||
function Export($DB)
|
||||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB Handler acces base de donnees
|
||||
*/
|
||||
function Export($DB)
|
||||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load an exportable dataset
|
||||
* \param user Object user making export
|
||||
* \param filter Code export pour charger un lot de donnees particulier
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
/**
|
||||
* \brief Load an exportable dataset
|
||||
* \param user Object user making export
|
||||
* \param filter Code export pour charger un lot de donnees particulier
|
||||
*/
|
||||
function load_arrays($user,$filter='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
dol_syslog("Export::load_arrays user=".$user->id." filter=".$filter);
|
||||
dol_syslog("Export::load_arrays user=".$user->id." filter=".$filter);
|
||||
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
$handle=opendir($dir);
|
||||
//$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
foreach($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot.'/includes/modules';
|
||||
$handle=opendir($dir);
|
||||
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php$",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
// Search available exports
|
||||
$handle=@opendir($dir);
|
||||
if ($handle)
|
||||
{
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php$",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
if (empty($conf->$part->enabled)) $enabled=false;
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
if (empty($conf->$part->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
if ($enabled)
|
||||
{
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
|
||||
if (is_array($module->export_code))
|
||||
{
|
||||
foreach($module->export_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->export_code[$r])) continue;
|
||||
if (is_array($module->export_code))
|
||||
{
|
||||
foreach($module->export_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->export_code[$r])) continue;
|
||||
|
||||
// Test si permissions ok \todo tester sur toutes permissions
|
||||
$perm=$module->export_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
// Test si permissions ok \todo tester sur toutes permissions
|
||||
$perm=$module->export_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Module
|
||||
$this->array_export_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_export_perms[$i]=$bool;
|
||||
// Icon
|
||||
$this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$this->array_export_code[$i]=$module->export_code[$r];
|
||||
// Libelle du dataset export
|
||||
$this->array_export_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
$this->array_export_fields[$i]=$module->export_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_export_entities[$i]=$module->export_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_export_alias[$i]=$module->export_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_export_special[$i]=$module->export_special_array[$r];
|
||||
|
||||
// Requete sql du dataset
|
||||
$this->array_export_sql_start[$i]=$module->export_sql_start[$r];
|
||||
$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
|
||||
//$this->array_export_sql[$i]=$module->export_sql[$r];
|
||||
|
||||
dol_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Lance la generation du fichier
|
||||
* \param user User qui exporte
|
||||
* \param model Modele d'export
|
||||
* \param datatoexport Lot de donnee a exporter
|
||||
* \param array_selected Tableau des champs a exporter
|
||||
* \remarks Les tableaux array_export_xxx sont deja chargees pour le bon datatoexport
|
||||
* aussi le parametre datatoexport est inutilise
|
||||
*/
|
||||
function build_file($user, $model, $datatoexport, $array_selected)
|
||||
{
|
||||
global $conf,$langs;
|
||||
// Module
|
||||
$this->array_export_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_export_perms[$i]=$bool;
|
||||
// Icon
|
||||
$this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$this->array_export_code[$i]=$module->export_code[$r];
|
||||
// Libelle du dataset export
|
||||
$this->array_export_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
$this->array_export_fields[$i]=$module->export_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_export_entities[$i]=$module->export_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_export_alias[$i]=$module->export_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_export_special[$i]=$module->export_special_array[$r];
|
||||
|
||||
$indice=0;
|
||||
asort($array_selected);
|
||||
// Requete sql du dataset
|
||||
$this->array_export_sql_start[$i]=$module->export_sql_start[$r];
|
||||
$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
|
||||
//$this->array_export_sql[$i]=$module->export_sql[$r];
|
||||
|
||||
dol_syslog("Export::build_file $model, $datatoexport, $array_selected");
|
||||
dol_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
// Creation de la classe d'export du model ExportXXX
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/export/";
|
||||
$file = "export_".$model.".modules.php";
|
||||
$classname = "Export".$model;
|
||||
require_once($dir.$file);
|
||||
$objmodel = new $classname($db);
|
||||
|
||||
// Build the sql request
|
||||
$sql=$this->array_export_sql_start[$indice];
|
||||
$i=0;
|
||||
//print_r($array_selected);
|
||||
foreach ($this->array_export_alias[$indice] as $key => $value)
|
||||
{
|
||||
if (! array_key_exists($key, $array_selected)) continue; // Field not selected
|
||||
/**
|
||||
* \brief Lance la generation du fichier
|
||||
* \param user User qui exporte
|
||||
* \param model Modele d'export
|
||||
* \param datatoexport Lot de donnee a exporter
|
||||
* \param array_selected Tableau des champs a exporter
|
||||
* \remarks Les tableaux array_export_xxx sont deja chargees pour le bon datatoexport
|
||||
* aussi le parametre datatoexport est inutilise
|
||||
*/
|
||||
function build_file($user, $model, $datatoexport, $array_selected)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
if ($i > 0) $sql.=', ';
|
||||
else $i++;
|
||||
$newfield=$key.' as '.$value;
|
||||
|
||||
$sql.=$newfield;
|
||||
}
|
||||
$sql.=$this->array_export_sql_end[$indice];
|
||||
$indice=0;
|
||||
asort($array_selected);
|
||||
|
||||
dol_syslog("Export::build_file $model, $datatoexport, $array_selected");
|
||||
|
||||
// Creation de la classe d'export du model ExportXXX
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/export/";
|
||||
$file = "export_".$model.".modules.php";
|
||||
$classname = "Export".$model;
|
||||
require_once($dir.$file);
|
||||
$objmodel = new $classname($db);
|
||||
|
||||
// Build the sql request
|
||||
$sql=$this->array_export_sql_start[$indice];
|
||||
$i=0;
|
||||
//print_r($array_selected);
|
||||
foreach ($this->array_export_alias[$indice] as $key => $value)
|
||||
{
|
||||
if (! array_key_exists($key, $array_selected)) continue; // Field not selected
|
||||
|
||||
if ($i > 0) $sql.=', ';
|
||||
else $i++;
|
||||
$newfield=$key.' as '.$value;
|
||||
|
||||
$sql.=$newfield;
|
||||
}
|
||||
$sql.=$this->array_export_sql_end[$indice];
|
||||
|
||||
// Run the sql
|
||||
$this->sqlusedforexport=$sql;
|
||||
|
|
@ -211,24 +218,24 @@ class Export
|
|||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
//$this->array_export_label[$indice]
|
||||
$filename="export_".$datatoexport;
|
||||
$filename.='.'.$objmodel->getDriverExtension();
|
||||
$dirname=$conf->export->dir_temp.'/'.$user->id;
|
||||
//$this->array_export_label[$indice]
|
||||
$filename="export_".$datatoexport;
|
||||
$filename.='.'.$objmodel->getDriverExtension();
|
||||
$dirname=$conf->export->dir_temp.'/'.$user->id;
|
||||
|
||||
$outputlangs=$langs; // Lang for output
|
||||
|
||||
// Open file
|
||||
create_exdir($dirname);
|
||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
create_exdir($dirname);
|
||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($outputlangs);
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs);
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs);
|
||||
|
||||
while ($objp = $this->db->fetch_object($resql))
|
||||
{
|
||||
|
|
@ -237,8 +244,8 @@ class Export
|
|||
// Process special operations
|
||||
if (! empty($this->array_export_special[$indice]))
|
||||
{
|
||||
foreach ($this->array_export_special[$indice] as $key => $value)
|
||||
{
|
||||
foreach ($this->array_export_special[$indice] as $key => $value)
|
||||
{
|
||||
if (! array_key_exists($key, $array_selected)) continue; // Field not selected
|
||||
// Operation NULLIFNEG
|
||||
if ($this->array_export_special[$indice][$key]=='NULLIFNEG')
|
||||
|
|
@ -257,33 +264,33 @@ class Export
|
|||
// end of special operation processing
|
||||
|
||||
$objmodel->write_record($this->array_export_alias[$indice],$array_selected,$objp,$outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
// Genere en-tete
|
||||
$objmodel->write_footer($outputlangs);
|
||||
// Genere en-tete
|
||||
$objmodel->write_footer($outputlangs);
|
||||
|
||||
// Close file
|
||||
$objmodel->close_file();
|
||||
// Close file
|
||||
$objmodel->close_file();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$objmodel->error;
|
||||
dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
$this->error=$objmodel->error;
|
||||
dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=".$sql;
|
||||
dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=".$sql;
|
||||
dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Create an export model in database
|
||||
* \param user Objet utilisateur qui cree
|
||||
*/
|
||||
* \brief Create an export model in database
|
||||
* \param user Objet utilisateur qui cree
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
|
@ -314,9 +321,9 @@ class Export
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Load an export profil from database
|
||||
* \param rowid id of profil to load
|
||||
*/
|
||||
* \brief Load an export profil from database
|
||||
* \param rowid id of profil to load
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = 'SELECT em.rowid, em.field, em.label, em.type';
|
||||
|
|
@ -351,10 +358,10 @@ class Export
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Delete object in database
|
||||
* \param user User that delete
|
||||
* \param notrigger 0=launch triggers after, 1=disable triggers
|
||||
* \param user User that delete
|
||||
* \param notrigger 0=launch triggers after, 1=disable triggers
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
|
|
@ -369,31 +376,31 @@ class Export
|
|||
|
||||
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action call a trigger.
|
||||
// want this action call a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
//// Call triggers
|
||||
//include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/exports/export.php
|
||||
\ingroup export
|
||||
\brief Page d'edition d'un export
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/exports/export.php
|
||||
* \ingroup export
|
||||
* \brief Page d'edition d'un export
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
|
|
@ -699,7 +699,7 @@ if ($step == 4 && $datatoexport)
|
|||
$var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("AvailableFormats").'</td>';
|
||||
print '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
|
||||
print '<td>'.$langs->trans("LibraryUsed").'</td>';
|
||||
print '<td>'.$langs->trans("LibraryVersion").'</td>';
|
||||
print '</tr>';
|
||||
|
|
@ -708,7 +708,9 @@ if ($step == 4 && $datatoexport)
|
|||
foreach($liste as $key)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$objmodelexport->getDriverLabel($key).'</td><td>'.$objmodelexport->getLibLabel($key).'</td><td>'.$objmodelexport->getLibVersion($key).'</td></tr>';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td width="20">'.img_picto_common($key,$objmodelexport->getPicto($key)).'</td>';
|
||||
print '<td>'.$objmodelexport->getDriverLabel($key).'</td><td>'.$objmodelexport->getLibLabel($key).'</td><td>'.$objmodelexport->getLibVersion($key).'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Import
|
|||
{
|
||||
$this->db=$DB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Load an importable dataset
|
||||
|
|
@ -50,101 +50,111 @@ class Import
|
|||
|
||||
dol_syslog("Import::load_arrays user=".$user->id." filter=".$filter);
|
||||
|
||||
$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
$handle=opendir($dir);
|
||||
//$dir=DOL_DOCUMENT_ROOT."/includes/modules";
|
||||
foreach($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot.'/includes/modules';
|
||||
$handle=opendir($dir);
|
||||
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
// Search available exports
|
||||
$handle=@opendir($dir);
|
||||
if ($handle)
|
||||
{
|
||||
// Recherche des exports disponibles
|
||||
$var=True;
|
||||
$i=0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi("^(mod.*)\.class\.php",$file,$reg))
|
||||
{
|
||||
$modulename=$reg[1];
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
if (empty($conf->$part->enabled)) $enabled=false;
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
$part=strtolower(eregi_replace('^mod','',$modulename));
|
||||
if (empty($conf->$part->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
if ($enabled)
|
||||
{
|
||||
// Chargement de la classe
|
||||
$file = $dir."/".$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once($file);
|
||||
$module = new $classname($this->db);
|
||||
|
||||
if (is_array($module->export_code))
|
||||
{
|
||||
foreach($module->export_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->export_code[$r])) continue;
|
||||
if (is_array($module->import_code))
|
||||
{
|
||||
foreach($module->import_code as $r => $value)
|
||||
{
|
||||
if ($filter && ($filter != $module->import_code[$r])) continue;
|
||||
|
||||
// Test si permissions ok \todo tester sur toutes permissions
|
||||
$perm=$module->export_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
// Test if permissions are ok
|
||||
/*$perm=$module->import_permission[$r][0];
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if ($perm[2])
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1]->$perm[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$bool=$user->rights->$perm[0]->$perm[1];
|
||||
}
|
||||
if ($perm[0]=='user' && $user->admin) $bool=true;
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
*/
|
||||
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
// Permissions ok
|
||||
// if ($bool)
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload=$module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach($langtoload as $key)
|
||||
{
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Module
|
||||
$this->array_export_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_export_perms[$i]=$bool;
|
||||
// Icon
|
||||
$this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$this->array_export_code[$i]=$module->export_code[$r];
|
||||
// Libelle du dataset export
|
||||
$this->array_export_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
$this->array_export_fields[$i]=$module->export_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_export_entities[$i]=$module->export_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_export_alias[$i]=$module->export_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_export_special[$i]=$module->export_special_array[$r];
|
||||
// Module
|
||||
$this->array_import_module[$i]=$module;
|
||||
// Permission
|
||||
$this->array_import_perms[$i]=$user->admin;
|
||||
// Icon
|
||||
$this->array_import_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
|
||||
// Code du dataset export
|
||||
$this->array_import_code[$i]=$module->export_code[$r];
|
||||
// Libelle du dataset export
|
||||
$this->array_import_label[$i]=$module->getDatasetLabel($r);
|
||||
// Tableau des champ a exporter (cle=champ, valeur=libelle)
|
||||
$this->array_import_fields[$i]=$module->export_fields_array[$r];
|
||||
// Tableau des entites a exporter (cle=champ, valeur=entite)
|
||||
$this->array_import_entities[$i]=$module->export_entities_array[$r];
|
||||
// Tableau des alias a exporter (cle=champ, valeur=alias)
|
||||
$this->array_import_alias[$i]=$module->export_alias_array[$r];
|
||||
// Tableau des operations speciales sur champ
|
||||
$this->array_import_special[$i]=$module->export_special_array[$r];
|
||||
|
||||
// Requete sql du dataset
|
||||
$this->array_export_sql_start[$i]=$module->export_sql_start[$r];
|
||||
$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
|
||||
//$this->array_export_sql[$i]=$module->export_sql[$r];
|
||||
// Requete sql du dataset
|
||||
$this->array_import_sql_start[$i]=$module->export_sql_start[$r];
|
||||
$this->array_import_sql_end[$i]=$module->export_sql_end[$r];
|
||||
//$this->array_import_sql[$i]=$module->export_sql[$r];
|
||||
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".sizeof($module->export_fields_code[$r]));
|
||||
$i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* \brief Importe un fichier clients
|
||||
*/
|
||||
|
|
@ -227,13 +237,13 @@ class Import
|
|||
while (!feof($hf) )
|
||||
{
|
||||
$cont = fgets($hf, 1024);
|
||||
|
||||
|
||||
if (strlen(trim($cont)) > 0)
|
||||
{
|
||||
$this->lines[$i] = explode(";", $cont);
|
||||
}
|
||||
$i++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -243,49 +253,6 @@ class Import
|
|||
|
||||
return $errno;
|
||||
}
|
||||
|
||||
/*
|
||||
\brief Cree le repertoire de backup
|
||||
*/
|
||||
function CreateBackupDir()
|
||||
{
|
||||
$time = time();
|
||||
|
||||
$upload_dir = DOL_DATA_ROOT."/import/";
|
||||
|
||||
if (! is_dir($upload_dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! mkdir($upload_dir, 0755))
|
||||
{
|
||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
$upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time);
|
||||
|
||||
if (! is_dir($upload_dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! mkdir($upload_dir, 0755))
|
||||
{
|
||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
$upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time)."/".strftime("%d-%m-%Y",$time);
|
||||
|
||||
if (! is_dir($upload_dir))
|
||||
{
|
||||
umask(0);
|
||||
if (! mkdir($upload_dir, 0755))
|
||||
{
|
||||
dol_syslog("Import::ReadFile Impossible de creer $upload_dir",LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
$this->upload_dir = DOL_DATA_ROOT."/import/".strftime("%Y",$time)."/".strftime("%d-%m-%Y",$time);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -43,10 +43,10 @@ class ExportCsv extends ModeleExports
|
|||
var $version_lib;
|
||||
|
||||
var $separator;
|
||||
|
||||
|
||||
var $handle; // Handle fichier
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur
|
||||
* \param db Handler acces base de donnee
|
||||
|
|
@ -59,13 +59,14 @@ class ExportCsv extends ModeleExports
|
|||
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
||||
$this->extension='csv'; // Extension for generated file by this driver
|
||||
$this->picto='mime/other'; // Picto
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->version_lib=DOL_VERSION;
|
||||
|
||||
|
||||
$this->separator=',';
|
||||
if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
|
||||
}
|
||||
|
|
@ -109,11 +110,11 @@ class ExportCsv extends ModeleExports
|
|||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
dol_syslog("ExportCsv::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
|
||||
$outputlangs->load("exports");
|
||||
$this->handle = fopen($file, "wt");
|
||||
if (! $this->handle)
|
||||
|
|
@ -122,7 +123,7 @@ class ExportCsv extends ModeleExports
|
|||
$this->error=$langs->trans("ErrorFailToCreateFile",$file);
|
||||
$ret=-1;
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ class ExportCsv extends ModeleExports
|
|||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
|
||||
{
|
||||
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
|
||||
|
|
@ -152,12 +153,12 @@ class ExportCsv extends ModeleExports
|
|||
{
|
||||
$outputlangs->charset_output = 'ISO-8859-1';
|
||||
}
|
||||
|
||||
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$this->csv_clean($newvalue);
|
||||
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
}
|
||||
fwrite($this->handle,"\n");
|
||||
|
|
@ -171,7 +172,7 @@ class ExportCsv extends ModeleExports
|
|||
function write_record($array_alias,$array_selected_sorted,$objp,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
|
||||
{
|
||||
$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
|
||||
|
|
@ -187,19 +188,19 @@ class ExportCsv extends ModeleExports
|
|||
$alias=$array_alias[$code];
|
||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||
|
||||
|
||||
// Translation newvalue
|
||||
if (eregi('^\((.*)\)$',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
|
||||
$newvalue=$this->csv_clean($newvalue);
|
||||
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
$this->col++;
|
||||
}
|
||||
|
||||
|
||||
fwrite($this->handle,"\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -212,7 +213,7 @@ class ExportCsv extends ModeleExports
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Close file handle
|
||||
*/
|
||||
|
|
@ -230,14 +231,14 @@ class ExportCsv extends ModeleExports
|
|||
function csv_clean($newvalue)
|
||||
{
|
||||
$addquote=0;
|
||||
|
||||
|
||||
// Rule Dolibarr: No HTML
|
||||
$newvalue=dol_string_nohtmltag($newvalue);
|
||||
|
||||
// Rule 1 CSV: No CR, LF in cells
|
||||
$newvalue=ereg_replace("\r",'',$newvalue);
|
||||
$newvalue=ereg_replace("\n",'\n',$newvalue);
|
||||
|
||||
|
||||
// Rule 2 CSV: If value contains ", we must duplicate ", and add "
|
||||
if (ereg('"',$newvalue))
|
||||
{
|
||||
|
|
@ -250,10 +251,10 @@ class ExportCsv extends ModeleExports
|
|||
{
|
||||
$addquote=1;
|
||||
}
|
||||
|
||||
|
||||
return ($addquote?'"':'').$newvalue.($addquote?'"':'');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class ExportExcel extends ModeleExports
|
|||
$this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Excel'; // Label of driver
|
||||
$this->extension='xls'; // Extension for generated file by this driver
|
||||
$this->picto='mime/xls'; // Picto
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ class ExportTsv extends ModeleExports
|
|||
var $version_lib;
|
||||
|
||||
var $separator="\t";
|
||||
|
||||
|
||||
var $handle; // Handle fichier
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Constructeur
|
||||
\param db Handler acc<EFBFBD>s base de donn<EFBFBD>e
|
||||
|
|
@ -59,11 +59,12 @@ class ExportTsv extends ModeleExports
|
|||
$this->id='tsv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Tsv (Tab Separated Value)'; // Label of driver
|
||||
$this->extension='tsv'; // Extension for generated file by this driver
|
||||
$this->picto='mime/other'; // Picto
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->version_lib=DOL_VERSION;
|
||||
}
|
||||
|
||||
|
|
@ -106,11 +107,11 @@ class ExportTsv extends ModeleExports
|
|||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
dol_syslog("ExportTsv::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
|
||||
$outputlangs->load("exports");
|
||||
$this->handle = fopen($file, "wt");
|
||||
if (! $this->handle)
|
||||
|
|
@ -119,7 +120,7 @@ class ExportTsv extends ModeleExports
|
|||
$this->error=$langs->trans("ErrorFailToCreateFile",$file);
|
||||
$ret=-1;
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ class ExportTsv extends ModeleExports
|
|||
{
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$this->tsv_clean($newvalue);
|
||||
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
}
|
||||
fwrite($this->handle,"\n");
|
||||
|
|
@ -168,9 +169,9 @@ class ExportTsv extends ModeleExports
|
|||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
|
||||
$newvalue=$this->tsv_clean($newvalue);
|
||||
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
$this->col++;
|
||||
}
|
||||
|
|
@ -186,7 +187,7 @@ class ExportTsv extends ModeleExports
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Close file handle
|
||||
*/
|
||||
|
|
@ -209,16 +210,16 @@ class ExportTsv extends ModeleExports
|
|||
// Rule 1 TSV: No CR, LF in cells
|
||||
$newvalue=ereg_replace("\r",'',$newvalue);
|
||||
$newvalue=ereg_replace("\n",'\n',$newvalue);
|
||||
|
||||
|
||||
// Rule 2 TSV: If value contains tab, we must replace by space
|
||||
if (ereg($this->separator,$newvalue))
|
||||
{
|
||||
$newvalue=ereg_replace("\t"," ",$newvalue);
|
||||
}
|
||||
|
||||
|
||||
return $newvalue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ class ModeleExports
|
|||
require_once($file);
|
||||
$module = new $classname($db);
|
||||
|
||||
// Picto
|
||||
$this->picto[$module->id]=$module->picto;
|
||||
// Driver properties
|
||||
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
||||
$this->driverversion[$module->id]=$module->getDriverVersion();
|
||||
|
|
@ -92,6 +94,14 @@ class ModeleExports
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return picto of export driver
|
||||
*/
|
||||
function getPicto($key)
|
||||
{
|
||||
return $this->picto[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi libelle d'un driver export
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ class ImportCsv extends ModeleImports
|
|||
var $version_lib;
|
||||
|
||||
var $separator;
|
||||
|
||||
|
||||
var $handle; // Handle fichier
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur
|
||||
* \param db Handler acces base de donnee
|
||||
|
|
@ -59,13 +59,14 @@ class ImportCsv extends ModeleImports
|
|||
$this->id='csv'; // Same value then xxx in file name export_xxx.modules.php
|
||||
$this->label='Csv (Comma Separated Value)'; // Label of driver
|
||||
$this->extension='csv'; // Extension for generated file by this driver
|
||||
$this->picto='mime/other'; // Picto
|
||||
$ver=split(' ','$Revision$');
|
||||
$this->version=$ver[2]; // Driver version
|
||||
|
||||
// If driver use an external library, put its name here
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->label_lib='Dolibarr';
|
||||
$this->version_lib=DOL_VERSION;
|
||||
|
||||
|
||||
$this->separator=',';
|
||||
if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
|
||||
}
|
||||
|
|
@ -109,11 +110,11 @@ class ImportCsv extends ModeleImports
|
|||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
dol_syslog("ImportCsv::open_file file=".$file);
|
||||
|
||||
$ret=1;
|
||||
|
||||
|
||||
$outputlangs->load("exports");
|
||||
$this->handle = fread($file, "wt");
|
||||
if (! $this->handle)
|
||||
|
|
@ -122,7 +123,7 @@ class ImportCsv extends ModeleImports
|
|||
$this->error=$langs->trans("ErrorFailToOpenFile",$file);
|
||||
$ret=-1;
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -156,9 +157,9 @@ class ImportCsv extends ModeleImports
|
|||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
|
||||
|
||||
$newvalue=$this->csv_clean($newvalue);
|
||||
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
$this->col++;
|
||||
}
|
||||
|
|
@ -183,14 +184,14 @@ class ImportCsv extends ModeleImports
|
|||
function csv_clean($newvalue)
|
||||
{
|
||||
$addquote=0;
|
||||
|
||||
|
||||
// Rule Dolibarr: No HTML
|
||||
$newvalue=dol_string_nohtmltag($newvalue);
|
||||
|
||||
// Rule 1 CSV: No CR, LF in cells
|
||||
$newvalue=ereg_replace("\r",'',$newvalue);
|
||||
$newvalue=ereg_replace("\n",'\n',$newvalue);
|
||||
|
||||
|
||||
// Rule 2 CSV: If value contains ", we must duplicate ", and add "
|
||||
if (ereg('"',$newvalue))
|
||||
{
|
||||
|
|
@ -203,10 +204,10 @@ class ImportCsv extends ModeleImports
|
|||
{
|
||||
$addquote=1;
|
||||
}
|
||||
|
||||
|
||||
return ($addquote?'"':'').$newvalue.($addquote?'"':'');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ class ModeleImports
|
|||
require_once($file);
|
||||
$module = new $classname($db);
|
||||
|
||||
// Picto
|
||||
$this->picto[$module->id]=$module->picto;
|
||||
// Driver properties
|
||||
$this->driverlabel[$module->id]=$module->getDriverLabel();
|
||||
$this->driverversion[$module->id]=$module->getDriverVersion();
|
||||
|
|
@ -92,6 +94,14 @@ class ModeleImports
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return picto of import driver
|
||||
*/
|
||||
function getPicto($key)
|
||||
{
|
||||
return $this->picto[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi libelle d'un driver export
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,18 +78,13 @@ class modImport extends DolibarrModules
|
|||
$this->rights = array();
|
||||
$this->rights_class = 'import';
|
||||
|
||||
/*
|
||||
$this->rights[1][0] = 1401;
|
||||
$this->rights[1][1] = 'Lire les imports';
|
||||
$this->rights[1][1] = 'Réaliser un import';
|
||||
$this->rights[1][2] = 'r';
|
||||
$this->rights[1][3] = 1;
|
||||
$this->rights[1][4] = 'lire';
|
||||
|
||||
$this->rights[2][0] = 1402;
|
||||
$this->rights[2][1] = 'Creer/modifier un import';
|
||||
$this->rights[2][2] = 'w';
|
||||
$this->rights[2][3] = 0;
|
||||
$this->rights[2][4] = 'creer';
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -159,21 +159,12 @@ class modProduit extends DolibarrModules
|
|||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]="ProductsOrServices"; // Translation key
|
||||
//$this->import_permission[$r]=array(array("societe","import"));
|
||||
$this->import_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell",'p.duration'=>"Duration");
|
||||
$this->import_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>'product','p.envente'=>"product",'p.duration'=>"product");
|
||||
//$this->import_alias_array[$r]=array('p.rowid'=>"id",'p.ref'=>"ref",'p.fk_product_type'=>"type",'p.label'=>"label",'p.description'=>"description",'p.note'=>"note",'p.price'=>"price",'p.tva_tx'=>'vat','p.envente'=>"onsell",'p.duration'=>"duration");
|
||||
|
||||
if($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
$this->import_multiprices[$r]=array();
|
||||
|
||||
for($i=1;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
|
||||
{
|
||||
$this->import_multiprices[$r][$i]["price_ht"] = "SellingPriceHT ".$i;
|
||||
$this->import_multiprices[$r][$i]["price_ttc"] = "SellingPriceTTC ".$i;
|
||||
}
|
||||
}
|
||||
|
||||
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'produit as s';
|
||||
$this->import_sql_end[$r] .='';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\defgroup societe Module societe
|
||||
\brief Module pour gerer les societes et contacts clients
|
||||
\version $Id$
|
||||
* \defgroup societe Module societe
|
||||
* \brief Module to manage third parties (customers, prospects)
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ class modSociete extends DolibarrModules
|
|||
|
||||
// Data directories to create when module is enabled
|
||||
$this->dirs = array("/societe/temp","/societe/logos");
|
||||
|
||||
|
||||
// Dependances
|
||||
$this->depends = array();
|
||||
$this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande");
|
||||
|
|
@ -187,7 +187,7 @@ class modSociete extends DolibarrModules
|
|||
//--------
|
||||
$r=0;
|
||||
|
||||
// Export liste des societes et attributs
|
||||
// Export list of third parties and attributes
|
||||
$r++;
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]='ExportDataset_company_1';
|
||||
|
|
@ -204,7 +204,7 @@ class modSociete extends DolibarrModules
|
|||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
|
||||
$this->export_sql_end[$r] .=' WHERE s.entity = '.$conf->entity;
|
||||
|
||||
// Export liste des contacts et attributs
|
||||
// Export list of contacts and attributes
|
||||
$r++;
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]='ExportDataset_company_2';
|
||||
|
|
@ -219,6 +219,23 @@ class modSociete extends DolibarrModules
|
|||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
|
||||
$this->export_sql_end[$r] .=' WHERE c.fk_pays = p.rowid';
|
||||
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity;
|
||||
|
||||
|
||||
// Imports
|
||||
//--------
|
||||
$r=0;
|
||||
|
||||
// Import list of third parties and attributes
|
||||
$r++;
|
||||
$this->import_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->import_label[$r]='ImportDataset_company_1';
|
||||
//$this->import_permission[$r]=array(array("societe","export"));
|
||||
$this->import_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"IdProf1",'s.siren'=>"IdProf2",'s.ape'=>"IdProf3",'s.idprof4'=>"IdProf4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Effectif","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','fk_stcomm'=>'ProspectStatus');
|
||||
$this->import_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>"company",'s.prefix_comm'=>"company",'s.client'=>"company",'s.fournisseur'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'t.libelle'=>"company",'ce.code'=>"company","cfj.libelle"=>"company",'s.fk_prospectlevel'=>'company','fk_stcomm'=>'company');
|
||||
|
||||
$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s';
|
||||
$this->import_sql_end[$r] .='';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,5 +52,5 @@ LineTotalHT=Amount net of tax for line
|
|||
LineTotalTTC=Amount with tax for line
|
||||
LineTotalVAT=Amount of VAT for line
|
||||
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||
|
||||
TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
|
||||
FileWithDataToImport=File with data to import
|
||||
FileMustHaveOneOfFollowingFormat=File to import must have one of following format
|
||||
|
|
|
|||
|
|
@ -52,3 +52,5 @@ LineTotalHT=Montant HT de la ligne
|
|||
LineTotalTTC=Montant TTC de la ligne
|
||||
LineTotalVAT=Montant TVA de la ligne
|
||||
TypeOfLineServiceOrProduct=Type de ligne (0=produit, 1=service)
|
||||
FileWithDataToImport=Fichier contenant les données à importer
|
||||
FileMustHaveOneOfFollowingFormat=Le fichier à importer doit avoir un des formats suivants
|
||||
|
|
@ -904,7 +904,7 @@ function img_object($alt, $object)
|
|||
|
||||
/**
|
||||
* \brief Show picto (generic function)
|
||||
* \param alt Texte sur le alt de l'image
|
||||
* \param alt Text on alt and title of image
|
||||
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
||||
* \param options Attribut supplementaire a la balise img
|
||||
* \param pictoisfullpath If 1, image path is a full path
|
||||
|
|
@ -920,7 +920,7 @@ function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
|
|||
|
||||
/**
|
||||
* \brief Show picto (generic function)
|
||||
* \param alt Texte sur le alt de l'image
|
||||
* \param alt Text on alt and title of image
|
||||
* \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
|
||||
* \param options Attribut supplementaire a la balise img
|
||||
* \param pictoisfullpath If 1, image path is a full path
|
||||
|
|
@ -1305,16 +1305,21 @@ function img_allow($allow)
|
|||
function img_mime($file,$alt='')
|
||||
{
|
||||
$mime='other';
|
||||
|
||||
if (eregi('\.xls',$file) || eregi('\.xlsx',$file)) { $mime='xls'; }
|
||||
if (eregi('\.ppt',$file) || eregi('\.pptx',$file)) { $mime='ppt'; }
|
||||
if (eregi('\.doc',$file) || eregi('\.docx',$file)) { $mime='doc'; }
|
||||
|
||||
if (eregi('\.pdf',$file)) { $mime='pdf'; }
|
||||
if (eregi('\.(html|htm)',$file)) { $mime='html'; }
|
||||
if (eregi('\.txt',$file)) { $mime='other'; }
|
||||
if (eregi('\.php',$file)) { $mime='php'; }
|
||||
if (eregi('\.pl',$file)) { $mime='pl'; }
|
||||
if (eregi('\.js',$file)) { $mime='jscript'; }
|
||||
if (eregi('\.(png|bmp|jpg|jpeg|gif)',$file)) $mime='image';
|
||||
if (eregi('\.(mp3|ogg|au)',$file)) $mime='audio';
|
||||
if (eregi('\.(avi|mvw|divx|xvid)',$file)) $mime='video';
|
||||
if (eregi('\.(zip|rar|gz|tgz|z|cab|bz2)',$file)) $mime='archive';
|
||||
if (eregi('\.(png|bmp|jpg|jpeg|gif)',$file)) $mime='image';
|
||||
if (eregi('\.(mp3|ogg|au)',$file)) $mime='audio';
|
||||
if (eregi('\.(avi|mvw|divx|xvid)',$file)) $mime='video';
|
||||
if (eregi('\.(zip|rar|gz|tgz|z|cab|bz2)',$file)) $mime='archive';
|
||||
if (empty($alt)) $alt='Mime type: '.$mime;
|
||||
|
||||
$mime.='.png';
|
||||
|
|
@ -1357,7 +1362,6 @@ function info_admin($texte,$infoonimgalt=0)
|
|||
* \param feature2 Feature to check (second level of permission)
|
||||
* \param dbt_keyfield Field name for socid foreign key if not fk_soc. (optionnal)
|
||||
* \param dbt_select Field name for select if not rowid. (optionnal)
|
||||
* \param dbt_tablename2 Secondary table name for compare keyfield. (optionnal)
|
||||
*/
|
||||
function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
|
||||
{
|
||||
|
|
@ -1529,7 +1533,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='',
|
|||
}
|
||||
}
|
||||
|
||||
print $sql."<br>";
|
||||
//print $sql."<br>";
|
||||
if ($sql)
|
||||
{
|
||||
$resql=$db->query($sql);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user