code syntax exports externalsite directory
This commit is contained in:
parent
f7c119e48c
commit
d6ffdfe835
@ -96,50 +96,49 @@ class Export
|
||||
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
foreach ($modulesdir as $dir) {
|
||||
// Search available exports
|
||||
$handle = @opendir(dol_osencode($dir));
|
||||
if (is_resource($handle))
|
||||
{
|
||||
if (is_resource($handle)) {
|
||||
// Search module files
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$reg = array();
|
||||
if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg))
|
||||
{
|
||||
if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) {
|
||||
$modulename = $reg[1];
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled = true;
|
||||
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
|
||||
if ($part == 'propale') $part = 'propal';
|
||||
if (empty($conf->$part->enabled)) $enabled = false;
|
||||
if ($part == 'propale') {
|
||||
$part = 'propal';
|
||||
}
|
||||
if (empty($conf->$part->enabled)) {
|
||||
$enabled = false;
|
||||
}
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
if ($enabled) {
|
||||
// Loading Class
|
||||
$file = $dir.$modulename.".class.php";
|
||||
$classname = $modulename;
|
||||
require_once $file;
|
||||
$module = new $classname($this->db);
|
||||
|
||||
if (isset($module->export_code) && is_array($module->export_code))
|
||||
{
|
||||
foreach ($module->export_code as $r => $value)
|
||||
{
|
||||
if (isset($module->export_code) && is_array($module->export_code)) {
|
||||
foreach ($module->export_code as $r => $value) {
|
||||
//print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).'<br>';
|
||||
if ($filter && ($filter != $module->export_code[$r])) continue;
|
||||
if ($filter && ($filter != $module->export_code[$r])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Test if condition to show are ok
|
||||
if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) continue;
|
||||
if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Test if permissions are ok
|
||||
$bool = true;
|
||||
if (isset($module->export_permission))
|
||||
{
|
||||
foreach ($module->export_permission[$r] as $val)
|
||||
{
|
||||
if (isset($module->export_permission)) {
|
||||
foreach ($module->export_permission[$r] as $val) {
|
||||
$perm = $val;
|
||||
//print_r("$perm[0]-$perm[1]-$perm[2]<br>");
|
||||
if (!empty($perm[2])) {
|
||||
@ -147,8 +146,12 @@ class Export
|
||||
} else {
|
||||
$bool = isset($user->rights->{$perm[0]}->{$perm[1]}) ? $user->rights->{$perm[0]}->{$perm[1]} : false;
|
||||
}
|
||||
if ($perm[0] == 'user' && $user->admin) $bool = true;
|
||||
if (!$bool) break;
|
||||
if ($perm[0] == 'user' && $user->admin) {
|
||||
$bool = true;
|
||||
}
|
||||
if (!$bool) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//print $bool." $perm[0]"."<br>";
|
||||
@ -158,10 +161,8 @@ class Export
|
||||
// {
|
||||
// Charge fichier lang en rapport
|
||||
$langtoload = $module->getLangFilesArray();
|
||||
if (is_array($langtoload))
|
||||
{
|
||||
foreach ($langtoload as $key)
|
||||
{
|
||||
if (is_array($langtoload)) {
|
||||
foreach ($langtoload as $key) {
|
||||
$langs->load($key);
|
||||
}
|
||||
}
|
||||
@ -234,12 +235,18 @@ class Export
|
||||
$i = 0;
|
||||
|
||||
//print_r($array_selected);
|
||||
foreach ($this->array_export_fields[$indice] as $key => $value)
|
||||
{
|
||||
if (!array_key_exists($key, $array_selected)) continue; // Field not selected
|
||||
if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL
|
||||
if ($i > 0) $sql .= ', ';
|
||||
else $i++;
|
||||
foreach ($this->array_export_fields[$indice] as $key => $value) {
|
||||
if (!array_key_exists($key, $array_selected)) {
|
||||
continue; // Field not selected
|
||||
}
|
||||
if (preg_match('/^none\./', $key)) {
|
||||
continue; // A field that must not appears into SQL
|
||||
}
|
||||
if ($i > 0) {
|
||||
$sql .= ', ';
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (strpos($key, ' as ') === false) {
|
||||
$newfield = $key.' as '.str_replace(array('.', '-', '(', ')'), '_', $key);
|
||||
@ -252,14 +259,16 @@ class Export
|
||||
$sql .= $this->array_export_sql_end[$indice];
|
||||
|
||||
// Add the WHERE part. Filtering into sql if a filtering array is provided
|
||||
if (is_array($array_filterValue) && !empty($array_filterValue))
|
||||
{
|
||||
if (is_array($array_filterValue) && !empty($array_filterValue)) {
|
||||
$sqlWhere = '';
|
||||
// Loop on each condition to add
|
||||
foreach ($array_filterValue as $key => $value)
|
||||
{
|
||||
if (preg_match('/GROUP_CONCAT/i', $key)) continue;
|
||||
if ($value != '') $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
|
||||
foreach ($array_filterValue as $key => $value) {
|
||||
if (preg_match('/GROUP_CONCAT/i', $key)) {
|
||||
continue;
|
||||
}
|
||||
if ($value != '') {
|
||||
$sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
|
||||
}
|
||||
}
|
||||
$sql .= $sqlWhere;
|
||||
}
|
||||
@ -268,12 +277,12 @@ class Export
|
||||
$sql .= $this->array_export_sql_order[$indice];
|
||||
|
||||
// Add the HAVING part.
|
||||
if (is_array($array_filterValue) && !empty($array_filterValue))
|
||||
{
|
||||
if (is_array($array_filterValue) && !empty($array_filterValue)) {
|
||||
// Loop on each condition to add
|
||||
foreach ($array_filterValue as $key => $value)
|
||||
{
|
||||
if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
|
||||
foreach ($array_filterValue as $key => $value) {
|
||||
if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') {
|
||||
$sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,37 +306,41 @@ class Export
|
||||
// build the input field on depend of the type of file
|
||||
switch ($InfoFieldList[0]) {
|
||||
case 'Text':
|
||||
if (!(strpos($ValueField, '%') === false))
|
||||
if (!(strpos($ValueField, '%') === false)) {
|
||||
$szFilterQuery .= " ".$NameField." LIKE '".$ValueField."'";
|
||||
else $szFilterQuery .= " ".$NameField." = '".$ValueField."'";
|
||||
} else {
|
||||
$szFilterQuery .= " ".$NameField." = '".$ValueField."'";
|
||||
}
|
||||
break;
|
||||
case 'Date':
|
||||
if (strpos($ValueField, "+") > 0)
|
||||
{
|
||||
if (strpos($ValueField, "+") > 0) {
|
||||
// mode plage
|
||||
$ValueArray = explode("+", $ValueField);
|
||||
$szFilterQuery = "(".$this->conditionDate($NameField, trim($ValueArray[0]), ">=");
|
||||
$szFilterQuery .= " AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")";
|
||||
} else {
|
||||
if (is_numeric(substr($ValueField, 0, 1)))
|
||||
if (is_numeric(substr($ValueField, 0, 1))) {
|
||||
$szFilterQuery = $this->conditionDate($NameField, trim($ValueField), "=");
|
||||
else $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
|
||||
} else {
|
||||
$szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Duree':
|
||||
break;
|
||||
case 'Numeric':
|
||||
// si le signe -
|
||||
if (strpos($ValueField, "+") > 0)
|
||||
{
|
||||
if (strpos($ValueField, "+") > 0) {
|
||||
// mode plage
|
||||
$ValueArray = explode("+", $ValueField);
|
||||
$szFilterQuery = "(".$NameField.">=".$ValueArray[0];
|
||||
$szFilterQuery .= " AND ".$NameField."<=".$ValueArray[1].")";
|
||||
} else {
|
||||
if (is_numeric(substr($ValueField, 0, 1)))
|
||||
if (is_numeric(substr($ValueField, 0, 1))) {
|
||||
$szFilterQuery = " ".$NameField."=".$ValueField;
|
||||
else $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
|
||||
} else {
|
||||
$szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Boolean':
|
||||
@ -335,12 +348,14 @@ class Export
|
||||
break;
|
||||
case 'Status':
|
||||
case 'List':
|
||||
if (is_numeric($ValueField))
|
||||
if (is_numeric($ValueField)) {
|
||||
$szFilterQuery = " ".$NameField."=".$ValueField;
|
||||
else {
|
||||
if (!(strpos($ValueField, '%') === false))
|
||||
} else {
|
||||
if (!(strpos($ValueField, '%') === false)) {
|
||||
$szFilterQuery = " ".$NameField." LIKE '".$ValueField."'";
|
||||
else $szFilterQuery = " ".$NameField." = '".$ValueField."'";
|
||||
} else {
|
||||
$szFilterQuery = " ".$NameField." = '".$ValueField."'";
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -361,9 +376,13 @@ class Export
|
||||
public function conditionDate($Field, $Value, $Sens)
|
||||
{
|
||||
// TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN
|
||||
if (strlen($Value) == 4) $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
|
||||
elseif (strlen($Value) == 6) $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
|
||||
else $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
|
||||
if (strlen($Value) == 4) {
|
||||
$Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
|
||||
} elseif (strlen($Value) == 6) {
|
||||
$Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
|
||||
} else {
|
||||
$Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
|
||||
}
|
||||
return $Condition;
|
||||
}
|
||||
|
||||
@ -385,8 +404,7 @@ class Export
|
||||
$InfoFieldList = explode(":", $TypeField);
|
||||
|
||||
// build the input field on depend of the type of file
|
||||
switch ($InfoFieldList[0])
|
||||
{
|
||||
switch ($InfoFieldList[0]) {
|
||||
case 'Text':
|
||||
case 'Date':
|
||||
$szFilterField = '<input type="text" name="'.$NameField.'" value="'.$ValueField.'">';
|
||||
@ -403,15 +421,21 @@ class Export
|
||||
case 'Boolean':
|
||||
$szFilterField = '<select name="'.$NameField.'" class="flat">';
|
||||
$szFilterField .= '<option ';
|
||||
if ($ValueField == '') $szFilterField .= ' selected ';
|
||||
if ($ValueField == '') {
|
||||
$szFilterField .= ' selected ';
|
||||
}
|
||||
$szFilterField .= ' value=""> </option>';
|
||||
|
||||
$szFilterField .= '<option ';
|
||||
if ($ValueField == 'yes' || $ValueField == '1') $szFilterField .= ' selected ';
|
||||
if ($ValueField == 'yes' || $ValueField == '1') {
|
||||
$szFilterField .= ' selected ';
|
||||
}
|
||||
$szFilterField .= ' value="1">'.yn(1).'</option>';
|
||||
|
||||
$szFilterField .= '<option ';
|
||||
if ($ValueField == 'no' || $ValueField == '0') $szFilterField .= ' selected ';
|
||||
if ($ValueField == 'no' || $ValueField == '0') {
|
||||
$szFilterField .= ' selected ';
|
||||
}
|
||||
$szFilterField .= ' value="0">'.yn(0).'</option>';
|
||||
$szFilterField .= "</select>";
|
||||
break;
|
||||
@ -422,51 +446,50 @@ class Export
|
||||
// 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list.
|
||||
// 4 : Name of element for getEntity().
|
||||
|
||||
if (!empty($InfoFieldList[3]))
|
||||
if (!empty($InfoFieldList[3])) {
|
||||
$keyList = $InfoFieldList[3];
|
||||
else $keyList = 'rowid';
|
||||
} else {
|
||||
$keyList = 'rowid';
|
||||
}
|
||||
$sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
|
||||
if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
|
||||
if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
|
||||
if ($InfoFieldList[1] == 'c_stcomm') {
|
||||
$sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
|
||||
}
|
||||
if ($InfoFieldList[1] == 'c_country') {
|
||||
$sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
|
||||
}
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[1];
|
||||
if (!empty($InfoFieldList[4])) {
|
||||
$sql .= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')';
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$szFilterField = '<select class="flat" name="'.$NameField.'">';
|
||||
$szFilterField .= '<option value="0"> </option>';
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($num) {
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj->label == '-')
|
||||
{
|
||||
if ($obj->label == '-') {
|
||||
// Discard entry '-'
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
//var_dump($InfoFieldList[1]);
|
||||
$labeltoshow = dol_trunc($obj->label, 18);
|
||||
if ($InfoFieldList[1] == 'c_stcomm')
|
||||
{
|
||||
if ($InfoFieldList[1] == 'c_stcomm') {
|
||||
$langs->load("companies");
|
||||
$labeltoshow = (($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id) ? $langs->trans("StatusProspect".$obj->id) : $obj->label);
|
||||
}
|
||||
if ($InfoFieldList[1] == 'c_country')
|
||||
{
|
||||
if ($InfoFieldList[1] == 'c_country') {
|
||||
//var_dump($sql);
|
||||
$langs->load("dict");
|
||||
$labeltoshow = (($langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label);
|
||||
}
|
||||
if (!empty($ValueField) && $ValueField == $obj->rowid)
|
||||
{
|
||||
if (!empty($ValueField) && $ValueField == $obj->rowid) {
|
||||
$szFilterField .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
||||
} else {
|
||||
$szFilterField .= '<option value="'.$obj->rowid.'" >'.$labeltoshow.'</option>';
|
||||
@ -477,7 +500,9 @@ class Export
|
||||
$szFilterField .= "</select>";
|
||||
|
||||
$this->db->free($resql);
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -542,8 +567,7 @@ class Export
|
||||
dol_syslog(__METHOD__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected));
|
||||
|
||||
// Check parameters or context properties
|
||||
if (empty($this->array_export_fields) || !is_array($this->array_export_fields))
|
||||
{
|
||||
if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) {
|
||||
$this->error = "ErrorBadParameter";
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
return -1;
|
||||
@ -556,22 +580,20 @@ class Export
|
||||
require_once $dir.$file;
|
||||
$objmodel = new $classname($this->db);
|
||||
|
||||
if (!empty($sqlquery)) $sql = $sqlquery;
|
||||
else {
|
||||
if (!empty($sqlquery)) {
|
||||
$sql = $sqlquery;
|
||||
} else {
|
||||
// Define value for indice from $datatoexport
|
||||
$foundindice = 0;
|
||||
foreach ($this->array_export_code as $key => $dataset)
|
||||
{
|
||||
if ($datatoexport == $dataset)
|
||||
{
|
||||
foreach ($this->array_export_code as $key => $dataset) {
|
||||
if ($datatoexport == $dataset) {
|
||||
$indice = $key;
|
||||
$foundindice++;
|
||||
//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($foundindice))
|
||||
{
|
||||
if (empty($foundindice)) {
|
||||
$this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
|
||||
return -1;
|
||||
}
|
||||
@ -582,13 +604,11 @@ class Export
|
||||
$this->sqlusedforexport = $sql;
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
//$this->array_export_label[$indice]
|
||||
if (!empty($conf->global->EXPORT_PREFIX_SPEC)) {
|
||||
$filename = $conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filename = "export_".$datatoexport;
|
||||
}
|
||||
$filename .= '.'.$objmodel->getDriverExtension();
|
||||
@ -600,55 +620,48 @@ class Export
|
||||
dol_mkdir($dirname);
|
||||
$result = $objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, isset($this->array_export_TypeFields[$indice]) ? $this->array_export_TypeFields[$indice] : null);
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
// Process special operations
|
||||
if (!empty($this->array_export_special[$indice]))
|
||||
{
|
||||
foreach ($this->array_export_special[$indice] as $key => $value)
|
||||
{
|
||||
if (!array_key_exists($key, $array_selected)) continue; // Field not selected
|
||||
if (!empty($this->array_export_special[$indice])) {
|
||||
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')
|
||||
{
|
||||
if ($this->array_export_special[$indice][$key] == 'NULLIFNEG') {
|
||||
//$alias=$this->array_export_alias[$indice][$key];
|
||||
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
|
||||
if ($obj->$alias < 0) $obj->$alias = '';
|
||||
}
|
||||
// Operation ZEROIFNEG
|
||||
elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG')
|
||||
{
|
||||
if ($obj->$alias < 0) {
|
||||
$obj->$alias = '';
|
||||
}
|
||||
} elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG') {
|
||||
// Operation ZEROIFNEG
|
||||
//$alias=$this->array_export_alias[$indice][$key];
|
||||
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
|
||||
if ($obj->$alias < 0) $obj->$alias = '0';
|
||||
}
|
||||
// Operation GETNUMOPENDAYS (for Holiday module)
|
||||
elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays')
|
||||
{
|
||||
if ($obj->$alias < 0) {
|
||||
$obj->$alias = '0';
|
||||
}
|
||||
} elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays') {
|
||||
// Operation GETNUMOPENDAYS (for Holiday module)
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
//$alias=$this->array_export_alias[$indice][$key];
|
||||
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
|
||||
$obj->$alias = num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code);
|
||||
}
|
||||
// Operation INVOICEREMAINTOPAY
|
||||
elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay')
|
||||
{
|
||||
} elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay') {
|
||||
// Operation INVOICEREMAINTOPAY
|
||||
//$alias=$this->array_export_alias[$indice][$key];
|
||||
$alias = str_replace(array('.', '-', '(', ')'), '_', $key);
|
||||
$remaintopay = '';
|
||||
if ($obj->f_rowid > 0)
|
||||
{
|
||||
if ($obj->f_rowid > 0) {
|
||||
global $tmpobjforcomputecall;
|
||||
if (!is_object($tmpobjforcomputecall))
|
||||
{
|
||||
if (!is_object($tmpobjforcomputecall)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$tmpobjforcomputecall = new Facture($this->db);
|
||||
}
|
||||
@ -725,8 +738,7 @@ class Export
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -751,11 +763,9 @@ class Export
|
||||
|
||||
dol_syslog("Export::fetch", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->model_name = $obj->label;
|
||||
$this->datatoexport = $obj->type;
|
||||
@ -794,13 +804,13 @@ class Export
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -829,12 +839,10 @@ class Export
|
||||
$sql .= " ORDER BY rowid";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$keyModel = array_search($obj->type, $this->array_export_code);
|
||||
print "<tr>";
|
||||
|
||||
@ -54,14 +54,14 @@ $entitytoicon = array(
|
||||
'subscription' => 'payment',
|
||||
'payment' => 'payment',
|
||||
'tax' => 'generic',
|
||||
'tax_type' => 'generic',
|
||||
'other' => 'generic',
|
||||
'tax_type' => 'generic',
|
||||
'other' => 'generic',
|
||||
'account' => 'account',
|
||||
'product' => 'product',
|
||||
'virtualproduct'=>'product',
|
||||
'subproduct' => 'product',
|
||||
'product_supplier_ref' => 'product',
|
||||
'stock' => 'stock',
|
||||
'stock' => 'stock',
|
||||
'warehouse' => 'stock',
|
||||
'batch' => 'stock',
|
||||
'stockbatch' => 'stock',
|
||||
@ -159,17 +159,16 @@ $usefilters = 1;
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'selectfield') // Selection of field at step 2
|
||||
{
|
||||
if ($action == 'selectfield') { // Selection of field at step 2
|
||||
$fieldsarray = $objexport->array_export_fields[0];
|
||||
$fieldsentitiesarray = $objexport->array_export_entities[0];
|
||||
$fieldsdependenciesarray = $objexport->array_export_dependencies[0];
|
||||
|
||||
if ($field == 'all')
|
||||
{
|
||||
foreach ($fieldsarray as $key=>$val)
|
||||
{
|
||||
if (!empty($array_selected[$key])) continue; // If already selected, check next
|
||||
if ($field == 'all') {
|
||||
foreach ($fieldsarray as $key => $val) {
|
||||
if (!empty($array_selected[$key])) {
|
||||
continue; // If already selected, check next
|
||||
}
|
||||
$array_selected[$key] = count($array_selected) + 1;
|
||||
//print_r($array_selected);
|
||||
$_SESSION["export_selected_fields"] = $array_selected;
|
||||
@ -180,29 +179,30 @@ if ($action == 'selectfield') // Selection of field at step 2
|
||||
$array_selected[$field] = count($array_selected) + 1; // We tag the key $field as "selected"
|
||||
// We check if there is a dependency to activate
|
||||
/*var_dump($field);
|
||||
var_dump($fieldsentitiesarray[$field]);
|
||||
var_dump($fieldsdependenciesarray);*/
|
||||
var_dump($fieldsentitiesarray[$field]);
|
||||
var_dump($fieldsdependenciesarray);*/
|
||||
$listofdependencies = array();
|
||||
if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]]))
|
||||
{
|
||||
if (!empty($fieldsentitiesarray[$field]) && !empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) {
|
||||
// We found a dependency on the type of field
|
||||
$tmp = $fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid'))
|
||||
if (is_array($tmp)) $listofdependencies = $tmp;
|
||||
else $listofdependencies = array($tmp);
|
||||
} elseif (!empty($field) && !empty($fieldsdependenciesarray[$field]))
|
||||
{
|
||||
if (is_array($tmp)) {
|
||||
$listofdependencies = $tmp;
|
||||
} else {
|
||||
$listofdependencies = array($tmp);
|
||||
}
|
||||
} elseif (!empty($field) && !empty($fieldsdependenciesarray[$field])) {
|
||||
// We found a dependency on a dedicated field
|
||||
$tmp = $fieldsdependenciesarray[$field]; // $fieldsdependenciesarray=array('fd.fieldx'=>'fd.rowid') or array('fd.fieldx'=>array('fd.rowid','ab.rowid'))
|
||||
if (is_array($tmp)) $listofdependencies = $tmp;
|
||||
else $listofdependencies = array($tmp);
|
||||
if (is_array($tmp)) {
|
||||
$listofdependencies = $tmp;
|
||||
} else {
|
||||
$listofdependencies = array($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($listofdependencies))
|
||||
{
|
||||
foreach ($listofdependencies as $fieldid)
|
||||
{
|
||||
if (empty($array_selected[$fieldid]))
|
||||
{
|
||||
if (count($listofdependencies)) {
|
||||
foreach ($listofdependencies as $fieldid) {
|
||||
if (empty($array_selected[$fieldid])) {
|
||||
$array_selected[$fieldid] = count($array_selected) + 1; // We tag the key $fieldid as "selected"
|
||||
$warnings[] = $langs->trans("ExportFieldAutomaticallyAdded", $langs->transnoentitiesnoconv($fieldsarray[$fieldid]));
|
||||
}
|
||||
@ -214,10 +214,8 @@ if ($action == 'selectfield') // Selection of field at step 2
|
||||
setEventMessages($warnings, null, 'warnings');
|
||||
}
|
||||
}
|
||||
if ($action == 'unselectfield')
|
||||
{
|
||||
if ($_GET["field"] == 'all')
|
||||
{
|
||||
if ($action == 'unselectfield') {
|
||||
if ($_GET["field"] == 'all') {
|
||||
$array_selected = array();
|
||||
$_SESSION["export_selected_fields"] = $array_selected;
|
||||
} else {
|
||||
@ -226,8 +224,7 @@ if ($action == 'unselectfield')
|
||||
asort($array_selected);
|
||||
$i = 0;
|
||||
$array_selected_save = $array_selected;
|
||||
foreach ($array_selected as $code=>$value)
|
||||
{
|
||||
foreach ($array_selected as $code => $value) {
|
||||
$i++;
|
||||
$array_selected[$code] = $i;
|
||||
//print "x $code x $i y<br>";
|
||||
@ -236,52 +233,48 @@ if ($action == 'unselectfield')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'downfield' || $action == 'upfield')
|
||||
{
|
||||
if ($action == 'downfield' || $action == 'upfield') {
|
||||
$pos = $array_selected[$_GET["field"]];
|
||||
if ($action == 'downfield') $newpos = $pos + 1;
|
||||
if ($action == 'upfield') $newpos = $pos - 1;
|
||||
if ($action == 'downfield') {
|
||||
$newpos = $pos + 1;
|
||||
}
|
||||
if ($action == 'upfield') {
|
||||
$newpos = $pos - 1;
|
||||
}
|
||||
// Recherche code avec qui switcher
|
||||
$newcode = "";
|
||||
foreach ($array_selected as $code=>$value)
|
||||
{
|
||||
if ($value == $newpos)
|
||||
{
|
||||
foreach ($array_selected as $code => $value) {
|
||||
if ($value == $newpos) {
|
||||
$newcode = $code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//print("Switch pos=$pos (code=".$_GET["field"].") and newpos=$newpos (code=$newcode)");
|
||||
if ($newcode) // Si newcode trouve (protection contre resoumission de page)
|
||||
{
|
||||
if ($newcode) { // Si newcode trouve (protection contre resoumission de page)
|
||||
$array_selected[$_GET["field"]] = $newpos;
|
||||
$array_selected[$newcode] = $pos;
|
||||
$_SESSION["export_selected_fields"] = $array_selected;
|
||||
}
|
||||
}
|
||||
|
||||
if ($step == 1 || $action == 'cleanselect')
|
||||
{
|
||||
if ($step == 1 || $action == 'cleanselect') {
|
||||
$_SESSION["export_selected_fields"] = array();
|
||||
$_SESSION["export_filtered_fields"] = array();
|
||||
$array_selected = array();
|
||||
$array_filtervalue = array();
|
||||
}
|
||||
|
||||
if ($action == 'builddoc')
|
||||
{
|
||||
if ($action == 'builddoc') {
|
||||
$max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined
|
||||
$max_time = @ini_get("max_execution_time");
|
||||
if ($max_time && $max_time < $max_execution_time_for_importexport)
|
||||
{
|
||||
if ($max_time && $max_time < $max_execution_time_for_importexport) {
|
||||
dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
|
||||
@ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
|
||||
}
|
||||
|
||||
// Build export file
|
||||
$result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($objexport->error, $objexport->errors, 'errors');
|
||||
$sqlusedforexport = $objexport->sqlusedforexport;
|
||||
} else {
|
||||
@ -291,47 +284,46 @@ if ($action == 'builddoc')
|
||||
}
|
||||
|
||||
// Delete file
|
||||
if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
{
|
||||
if ($step == 5 && $action == 'confirm_deletefile' && $confirm == 'yes') {
|
||||
$file = $upload_dir."/".GETPOST('file'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
|
||||
$ret = dol_delete_file($file);
|
||||
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
|
||||
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
|
||||
if ($ret) {
|
||||
setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
|
||||
}
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == 'deleteprof')
|
||||
{
|
||||
if (GETPOST("id", 'int'))
|
||||
{
|
||||
if ($action == 'deleteprof') {
|
||||
if (GETPOST("id", 'int')) {
|
||||
$objexport->fetch(GETPOST('id', 'int'));
|
||||
$result = $objexport->delete($user);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO The export for filter is not yet implemented (old code created conflicts with step 2). We must use same way of working and same combo list of predefined export than step 2.
|
||||
if ($action == 'add_export_model')
|
||||
{
|
||||
if ($export_name)
|
||||
{
|
||||
if ($action == 'add_export_model') {
|
||||
if ($export_name) {
|
||||
asort($array_selected);
|
||||
|
||||
// Set save string
|
||||
$hexa = '';
|
||||
foreach ($array_selected as $key=>$val)
|
||||
{
|
||||
if ($hexa) $hexa .= ',';
|
||||
foreach ($array_selected as $key => $val) {
|
||||
if ($hexa) {
|
||||
$hexa .= ',';
|
||||
}
|
||||
$hexa .= $key;
|
||||
}
|
||||
|
||||
$hexafiltervalue = '';
|
||||
if (!empty($array_filtervalue) && is_array($array_filtervalue))
|
||||
{
|
||||
foreach ($array_filtervalue as $key=>$val)
|
||||
{
|
||||
if ($hexafiltervalue) $hexafiltervalue .= ',';
|
||||
if (!empty($array_filtervalue) && is_array($array_filtervalue)) {
|
||||
foreach ($array_filtervalue as $key => $val) {
|
||||
if ($hexafiltervalue) {
|
||||
$hexafiltervalue .= ',';
|
||||
}
|
||||
$hexafiltervalue .= $key.'='.$val;
|
||||
}
|
||||
}
|
||||
@ -342,14 +334,15 @@ if ($action == 'add_export_model')
|
||||
$objexport->hexafiltervalue = $hexafiltervalue;
|
||||
|
||||
$result = $objexport->create($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
setEventMessages($langs->trans("ExportModelSaved", $objexport->model_name), null, 'mesgs');
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
if ($objexport->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
setEventMessages($langs->trans("ErrorExportDuplicateProfil"), null, 'errors');
|
||||
else setEventMessages($objexport->error, $objexport->errors, 'errors');
|
||||
} else {
|
||||
setEventMessages($objexport->error, $objexport->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportModelName")), null, 'errors');
|
||||
@ -357,8 +350,7 @@ if ($action == 'add_export_model')
|
||||
}
|
||||
|
||||
// Reload a predefined export model
|
||||
if ($step == 2 && $action == 'select_model')
|
||||
{
|
||||
if ($step == 2 && $action == 'select_model') {
|
||||
$_SESSION["export_selected_fields"] = array();
|
||||
$_SESSION["export_filtered_fields"] = array();
|
||||
|
||||
@ -366,12 +358,10 @@ if ($step == 2 && $action == 'select_model')
|
||||
$array_filtervalue = array();
|
||||
|
||||
$result = $objexport->fetch($exportmodelid);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa);
|
||||
$i = 1;
|
||||
foreach ($fieldsarray as $val)
|
||||
{
|
||||
foreach ($fieldsarray as $val) {
|
||||
$array_selected[$val] = $i;
|
||||
$i++;
|
||||
}
|
||||
@ -379,8 +369,7 @@ if ($step == 2 && $action == 'select_model')
|
||||
|
||||
$fieldsarrayvalue = explode(',', $objexport->hexafiltervalue);
|
||||
$i = 1;
|
||||
foreach ($fieldsarrayvalue as $val)
|
||||
{
|
||||
foreach ($fieldsarrayvalue as $val) {
|
||||
$tmp = explode('=', $val);
|
||||
$array_filtervalue[$tmp[0]] = $tmp[1];
|
||||
$i++;
|
||||
@ -390,21 +379,20 @@ if ($step == 2 && $action == 'select_model')
|
||||
}
|
||||
|
||||
// Get form with filters
|
||||
if ($step == 4 && $action == 'submitFormField')
|
||||
{
|
||||
if ($step == 4 && $action == 'submitFormField') {
|
||||
// on boucle sur les champs selectionne pour recuperer la valeur
|
||||
if (is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if (is_array($objexport->array_export_TypeFields[0])) {
|
||||
$_SESSION["export_filtered_fields"] = array();
|
||||
foreach ($objexport->array_export_TypeFields[0] as $code => $type) // $code: s.fieldname $value: Text|Boolean|List:ccc
|
||||
{
|
||||
foreach ($objexport->array_export_TypeFields[0] as $code => $type) { // $code: s.fieldname $value: Text|Boolean|List:ccc
|
||||
$newcode = (string) preg_replace('/\./', '_', $code);
|
||||
//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n<br>";
|
||||
$filterqualified = 1;
|
||||
if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0;
|
||||
elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0;
|
||||
if ($filterqualified)
|
||||
{
|
||||
if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') {
|
||||
$filterqualified = 0;
|
||||
} elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) {
|
||||
$filterqualified = 0;
|
||||
}
|
||||
if ($filterqualified) {
|
||||
//print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n";
|
||||
$objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml');
|
||||
}
|
||||
@ -419,8 +407,7 @@ if ($step == 4 && $action == 'submitFormField')
|
||||
* View
|
||||
*/
|
||||
|
||||
if ($step == 1 || !$datatoexport)
|
||||
{
|
||||
if ($step == 1 || !$datatoexport) {
|
||||
llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
|
||||
|
||||
$h = 0;
|
||||
@ -443,13 +430,11 @@ if ($step == 1 || !$datatoexport)
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
if (count($objexport->array_export_module))
|
||||
{
|
||||
if (count($objexport->array_export_module)) {
|
||||
asort($objexport->array_export_code_for_sort);
|
||||
//var_dump($objexport->array_export_code_for_sort);
|
||||
//$sortedarrayofmodules = dol_sort_array($objexport->array_export_module, 'module_position', 'asc', 0, 0, 1);
|
||||
foreach ($objexport->array_export_code_for_sort as $key => $value)
|
||||
{
|
||||
foreach ($objexport->array_export_code_for_sort as $key => $value) {
|
||||
print '<tr class="oddeven"><td nospan="nospan">';
|
||||
//print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
|
||||
print $objexport->array_export_module[$key]->getName();
|
||||
@ -466,7 +451,7 @@ if ($step == 1 || !$datatoexport)
|
||||
} else {
|
||||
print $langs->trans("NotEnoughPermissions");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
} else {
|
||||
print '<tr><td class="oddeven" colspan="3">'.$langs->trans("NoExportableData").'</td></tr>';
|
||||
@ -477,8 +462,7 @@ if ($step == 1 || !$datatoexport)
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($step == 2 && $datatoexport)
|
||||
{
|
||||
if ($step == 2 && $datatoexport) {
|
||||
llxHeader('', $langs->trans("NewExport"), 'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones');
|
||||
|
||||
$h = 0;
|
||||
@ -505,14 +489,14 @@ if ($step == 2 && $datatoexport)
|
||||
print $objexport->array_export_module[0]->getName();
|
||||
print '</td></tr>';
|
||||
|
||||
// Lot de donnees a exporter
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
|
||||
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
// Lot de donnees a exporter
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
|
||||
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
@ -568,8 +552,7 @@ if ($step == 2 && $datatoexport)
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($fieldsarray as $code=>$label)
|
||||
{
|
||||
foreach ($fieldsarray as $code => $label) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$i++;
|
||||
@ -583,8 +566,7 @@ if ($step == 2 && $datatoexport)
|
||||
//print $code.'-'.$label.'-'.$entity;
|
||||
|
||||
$tmparray = explode(':', $entityicon);
|
||||
if (count($tmparray) >= 2)
|
||||
{
|
||||
if (count($tmparray) >= 2) {
|
||||
$entityicon = $tmparray[0];
|
||||
$entitylang = $tmparray[1];
|
||||
}
|
||||
@ -595,27 +577,22 @@ if ($step == 2 && $datatoexport)
|
||||
|
||||
$tablename = getablenamefromfield($code, $sqlmaxforexport);
|
||||
$htmltext = '<b>'.$langs->trans("Name").":</b> ".$text.'<br>';
|
||||
if (!empty($objexport->array_export_special[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_special[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
|
||||
} else {
|
||||
$htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
|
||||
}
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("SourceExample").':</b> '.$objexport->array_export_examplevalues[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Type").':</b> '.$objexport->array_export_TypeFields[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_help[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_help[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Help").':</b> '.$langs->trans($objexport->array_export_help[0][$code]).'<br>';
|
||||
}
|
||||
|
||||
if (isset($array_selected[$code]) && $array_selected[$code])
|
||||
{
|
||||
if (isset($array_selected[$code]) && $array_selected[$code]) {
|
||||
// Selected fields
|
||||
print '<td> </td>';
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?step=2&datatoexport='.$datatoexport.'&action=unselectfield&field='.$code.'">'.img_left('default', 0, 'style="max-width: 20px"').'</a></td>';
|
||||
@ -642,15 +619,13 @@ if ($step == 2 && $datatoexport)
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Barre d'action
|
||||
*/
|
||||
* Barre d'action
|
||||
*/
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
|
||||
if (count($array_selected))
|
||||
{
|
||||
if (count($array_selected)) {
|
||||
// If filters exist
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
|
||||
print '<a class="butAction" href="export.php?step=3&datatoexport='.$datatoexport.'">'.$langs->trans("NextStep").'</a>';
|
||||
} else {
|
||||
print '<a class="butAction" href="export.php?step=4&datatoexport='.$datatoexport.'">'.$langs->trans("NextStep").'</a>';
|
||||
@ -662,10 +637,8 @@ if ($step == 2 && $datatoexport)
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($step == 3 && $datatoexport)
|
||||
{
|
||||
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
|
||||
{
|
||||
if ($step == 3 && $datatoexport) {
|
||||
if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
|
||||
// Switch to step 2
|
||||
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
|
||||
exit;
|
||||
@ -713,8 +686,7 @@ if ($step == 3 && $datatoexport)
|
||||
// Nbre champs exportes
|
||||
print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
|
||||
$list = '';
|
||||
foreach ($array_selected as $code=>$value)
|
||||
{
|
||||
foreach ($array_selected as $code => $value) {
|
||||
$list .= (!empty($list) ? ', ' : '');
|
||||
$list .= (isset($objexport->array_export_fields[0][$code]) ? $langs->trans($objexport->array_export_fields[0][$code]) : '');
|
||||
}
|
||||
@ -755,8 +727,7 @@ if ($step == 3 && $datatoexport)
|
||||
|
||||
$i = 0;
|
||||
// on boucle sur les champs
|
||||
foreach ($fieldsarray as $code => $label)
|
||||
{
|
||||
foreach ($fieldsarray as $code => $label) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$i++;
|
||||
@ -767,8 +738,7 @@ if ($step == 3 && $datatoexport)
|
||||
print '<td class="nowrap">';
|
||||
// If value of entityicon=entitylang='icon:Label'
|
||||
$tmparray = explode(':', $entityicon);
|
||||
if (count($tmparray) >= 2)
|
||||
{
|
||||
if (count($tmparray) >= 2) {
|
||||
$entityicon = $tmparray[0];
|
||||
$entitylang = $tmparray[1];
|
||||
}
|
||||
@ -782,22 +752,18 @@ if ($step == 3 && $datatoexport)
|
||||
|
||||
$tablename = getablenamefromfield($code, $sqlmaxforexport);
|
||||
$htmltext = '<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
|
||||
if (!empty($objexport->array_export_special[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_special[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
|
||||
} else {
|
||||
$htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
|
||||
}
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("SourceExample").':</b> '.$objexport->array_export_examplevalues[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Type").':</b> '.$objexport->array_export_TypeFields[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_help[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_help[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Help").':</b> '.$langs->trans($objexport->array_export_help[0][$code]).'<br>';
|
||||
}
|
||||
|
||||
@ -807,11 +773,9 @@ if ($step == 3 && $datatoexport)
|
||||
|
||||
// Filter value
|
||||
print '<td>';
|
||||
if (!empty($Typefieldsarray[$code])) // Example: Text, List:c_country:label:rowid, Number, Boolean
|
||||
{
|
||||
if (!empty($Typefieldsarray[$code])) { // Example: Text, List:c_country:label:rowid, Number, Boolean
|
||||
$szInfoFiltre = $objexport->genDocFilter($Typefieldsarray[$code]);
|
||||
if ($szInfoFiltre) // Is there an info help for this filter ?
|
||||
{
|
||||
if ($szInfoFiltre) { // Is there an info help for this filter ?
|
||||
$tmp = $objexport->build_filterField($Typefieldsarray[$code], $code, $ValueFilter);
|
||||
print $form->textwithpicto($tmp, $szInfoFiltre);
|
||||
} else {
|
||||
@ -837,10 +801,8 @@ if ($step == 3 && $datatoexport)
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($step == 4 && $datatoexport)
|
||||
{
|
||||
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
|
||||
{
|
||||
if ($step == 4 && $datatoexport) {
|
||||
if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
|
||||
// Switch to step 2
|
||||
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
|
||||
exit;
|
||||
@ -862,8 +824,7 @@ if ($step == 4 && $datatoexport)
|
||||
$h++;
|
||||
|
||||
// If filters exist
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
|
||||
$head[$h][1] = $langs->trans("Step")." 3";
|
||||
$h++;
|
||||
@ -888,20 +849,19 @@ if ($step == 4 && $datatoexport)
|
||||
print $objexport->array_export_module[0]->getName();
|
||||
print '</td></tr>';
|
||||
|
||||
// Lot de donnees a exporter
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
// Lot de donnees a exporter
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
|
||||
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
|
||||
// List of exported fields
|
||||
print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
|
||||
$list = '';
|
||||
foreach ($array_selected as $code=>$value)
|
||||
{
|
||||
foreach ($array_selected as $code => $value) {
|
||||
$list .= (!empty($list) ? ', ' : '');
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code]);
|
||||
}
|
||||
@ -909,19 +869,18 @@ if ($step == 4 && $datatoexport)
|
||||
print '</tr>';
|
||||
|
||||
// List of filtered fiels
|
||||
if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
|
||||
print '<tr><td>'.$langs->trans("FilteredFields").'</td>';
|
||||
$list = '';
|
||||
if (!empty($array_filtervalue))
|
||||
{
|
||||
foreach ($array_filtervalue as $code=>$value)
|
||||
{
|
||||
if (isset($objexport->array_export_fields[0][$code]))
|
||||
{
|
||||
if (!empty($array_filtervalue)) {
|
||||
foreach ($array_filtervalue as $code => $value) {
|
||||
if (isset($objexport->array_export_fields[0][$code])) {
|
||||
$list .= ($list ? ', ' : '');
|
||||
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
|
||||
else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
|
||||
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
|
||||
} else {
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -949,8 +908,7 @@ if ($step == 4 && $datatoexport)
|
||||
//print '<td>'.$langs->trans("FieldsTitle").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($array_selected as $code=>$value)
|
||||
{
|
||||
foreach ($array_selected as $code => $value) {
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$entity = (!empty($objexport->array_export_entities[0][$code]) ? $objexport->array_export_entities[0][$code] : $objexport->array_export_icon[0]);
|
||||
@ -960,8 +918,7 @@ if ($step == 4 && $datatoexport)
|
||||
print '<td class="nowrap">';
|
||||
// If value of entityicon=entitylang='icon:Label'
|
||||
$tmparray = explode(':', $entityicon);
|
||||
if (count($tmparray) >= 2)
|
||||
{
|
||||
if (count($tmparray) >= 2) {
|
||||
$entityicon = $tmparray[0];
|
||||
$entitylang = $tmparray[1];
|
||||
}
|
||||
@ -974,22 +931,18 @@ if ($step == 4 && $datatoexport)
|
||||
|
||||
$tablename = getablenamefromfield($code, $sqlmaxforexport);
|
||||
$htmltext = '<b>'.$langs->trans("Name").':</b> '.$text.'<br>';
|
||||
if (!empty($objexport->array_export_special[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_special[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." :</b> ".$objexport->array_export_special[0][$code]."<br>";
|
||||
} else {
|
||||
$htmltext .= '<b>'.$langs->trans("Table")." -> ".$langs->trans("Field").":</b> ".$tablename." -> ".preg_replace('/^.*\./', '', $code)."<br>";
|
||||
}
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_examplevalues[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("SourceExample").':</b> '.$objexport->array_export_examplevalues[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_TypeFields[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Type").':</b> '.$objexport->array_export_TypeFields[0][$code].'<br>';
|
||||
}
|
||||
if (!empty($objexport->array_export_help[0][$code]))
|
||||
{
|
||||
if (!empty($objexport->array_export_help[0][$code])) {
|
||||
$htmltext .= '<b>'.$langs->trans("Help").':</b> '.$langs->trans($objexport->array_export_help[0][$code]).'<br>';
|
||||
}
|
||||
|
||||
@ -1001,8 +954,12 @@ if ($step == 4 && $datatoexport)
|
||||
print '<td class="right" width="100">';
|
||||
print $value.' ';
|
||||
print '</td><td class="center nowraponall" width="40">';
|
||||
if ($value < count($array_selected)) print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport.'&action=downfield&field='.$code.'">'.img_down().'</a>';
|
||||
if ($value > 1) print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport.'&action=upfield&field='.$code.'">'.img_up().'</a>';
|
||||
if ($value < count($array_selected)) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport.'&action=downfield&field='.$code.'">'.img_down().'</a>';
|
||||
}
|
||||
if ($value > 1) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?step='.$step.'&datatoexport='.$datatoexport.'&action=upfield&field='.$code.'">'.img_up().'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
//print '<td> </td>';
|
||||
@ -1017,13 +974,12 @@ if ($step == 4 && $datatoexport)
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Barre d'action
|
||||
*
|
||||
*/
|
||||
* Barre d'action
|
||||
*
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (count($array_selected))
|
||||
{
|
||||
if (count($array_selected)) {
|
||||
print '<a class="butAction" href="export.php?step='.($step + 1).'&datatoexport='.$datatoexport.'">'.$langs->trans("NextStep").'</a>';
|
||||
}
|
||||
|
||||
@ -1031,8 +987,7 @@ if ($step == 4 && $datatoexport)
|
||||
|
||||
|
||||
// Area for profils export
|
||||
if (count($array_selected))
|
||||
{
|
||||
if (count($array_selected)) {
|
||||
print '<br>';
|
||||
|
||||
print '<div class="marginbottomonly">';
|
||||
@ -1062,15 +1017,15 @@ if ($step == 4 && $datatoexport)
|
||||
$sql = "SELECT rowid, label";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."export_model";
|
||||
$sql .= " WHERE type = '".$db->escape($datatoexport)."'";
|
||||
if (empty($conf->global->EXPORTS_SHARE_MODELS))$sql .= " AND fk_user=".$user->id;
|
||||
if (empty($conf->global->EXPORTS_SHARE_MODELS)) {
|
||||
$sql .= " AND fk_user=".$user->id;
|
||||
}
|
||||
$sql .= " ORDER BY rowid";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $obj->label;
|
||||
@ -1092,10 +1047,8 @@ if ($step == 4 && $datatoexport)
|
||||
}
|
||||
}
|
||||
|
||||
if ($step == 5 && $datatoexport)
|
||||
{
|
||||
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
|
||||
{
|
||||
if ($step == 5 && $datatoexport) {
|
||||
if (count($array_selected) < 1) { // This occurs when going back to page after sessecion expired
|
||||
// Switch to step 2
|
||||
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
|
||||
exit;
|
||||
@ -1117,8 +1070,7 @@ if ($step == 5 && $datatoexport)
|
||||
$h++;
|
||||
|
||||
// si le filtrage est parametre pour l'export ou pas
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if ($usefilters && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport;
|
||||
$head[$h][1] = $langs->trans("Step")." 3";
|
||||
$h++;
|
||||
@ -1137,10 +1089,9 @@ if ($step == 5 && $datatoexport)
|
||||
print dol_get_fiche_head($head, $hselected, '', -2);
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'remove_file')
|
||||
{
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'remove_file') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport.'&file='.urlencode(GETPOST("file")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
||||
}
|
||||
|
||||
@ -1156,39 +1107,37 @@ if ($step == 5 && $datatoexport)
|
||||
print $objexport->array_export_module[0]->getName();
|
||||
print '</td></tr>';
|
||||
|
||||
// Dataset to export
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
|
||||
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
// Dataset to export
|
||||
print '<tr><td>'.$langs->trans("DatasetToExport").'</td>';
|
||||
print '<td>';
|
||||
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
|
||||
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
|
||||
print img_object($objexport->array_export_module[0]->getName(), $entityicon).' ';
|
||||
print $objexport->array_export_label[0];
|
||||
print '</td></tr>';
|
||||
|
||||
// List of exported fields
|
||||
print '<tr><td>'.$langs->trans("ExportedFields").'</td>';
|
||||
$list = '';
|
||||
foreach ($array_selected as $code=>$label)
|
||||
{
|
||||
foreach ($array_selected as $code => $label) {
|
||||
$list .= (!empty($list) ? ', ' : '');
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code]);
|
||||
}
|
||||
print '<td>'.$list.'</td></tr>';
|
||||
|
||||
// List of filtered fields
|
||||
if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
|
||||
{
|
||||
if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) {
|
||||
print '<tr><td>'.$langs->trans("FilteredFields").'</td>';
|
||||
$list = '';
|
||||
if (!empty($array_filtervalue))
|
||||
{
|
||||
foreach ($array_filtervalue as $code=>$value)
|
||||
{
|
||||
if (isset($objexport->array_export_fields[0][$code]))
|
||||
{
|
||||
if (!empty($array_filtervalue)) {
|
||||
foreach ($array_filtervalue as $code => $value) {
|
||||
if (isset($objexport->array_export_fields[0][$code])) {
|
||||
$list .= ($list ? ', ' : '');
|
||||
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) $list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
|
||||
else $list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
|
||||
if (isset($array_filtervalue[$code]) && preg_match('/^\s*[<>]/', $array_filtervalue[$code])) {
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code]).(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '');
|
||||
} else {
|
||||
$list .= $langs->trans($objexport->array_export_fields[0][$code])."='".(isset($array_filtervalue[$code]) ? $array_filtervalue[$code] : '')."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1211,10 +1160,8 @@ if ($step == 5 && $datatoexport)
|
||||
|
||||
$liste = $objmodelexport->liste_modeles($db);
|
||||
$listeall = $liste;
|
||||
foreach ($listeall as $key => $val)
|
||||
{
|
||||
if (preg_match('/__\(Disabled\)__/', $listeall[$key]))
|
||||
{
|
||||
foreach ($listeall as $key => $val) {
|
||||
if (preg_match('/__\(Disabled\)__/', $listeall[$key])) {
|
||||
$listeall[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $listeall[$key]);
|
||||
unset($liste[$key]);
|
||||
}
|
||||
@ -1237,13 +1184,14 @@ if ($step == 5 && $datatoexport)
|
||||
print '</div>';
|
||||
|
||||
|
||||
if ($sqlusedforexport && $user->admin)
|
||||
{
|
||||
if ($sqlusedforexport && $user->admin) {
|
||||
print info_admin($langs->trans("SQLUsedForExport").':<br> '.$sqlusedforexport, 0, 0, 1, '', 'TechnicalInformation');
|
||||
}
|
||||
|
||||
|
||||
if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
|
||||
if (!is_dir($conf->export->dir_temp)) {
|
||||
dol_mkdir($conf->export->dir_temp);
|
||||
}
|
||||
|
||||
// Show existing generated documents
|
||||
// NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
|
||||
@ -1273,8 +1221,9 @@ function getablenamefromfield($code, $sqlmaxforexport)
|
||||
$newsql = preg_replace('/^(.*) FROM /i', '', $newsql); // Remove part before the FROM
|
||||
$newsql = preg_replace('/WHERE (.*)$/i', '', $newsql); // Remove part after the WHERE so we have now only list of table aliases in a string. We must keep the ' ' before WHERE
|
||||
|
||||
if (preg_match($regexstring, $newsql, $reg))
|
||||
{
|
||||
if (preg_match($regexstring, $newsql, $reg)) {
|
||||
return $reg[1]; // The tablename
|
||||
} else return '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +48,7 @@ print '<br>';
|
||||
|
||||
|
||||
print '<div class="center">';
|
||||
if (count($export->array_export_code))
|
||||
{
|
||||
if (count($export->array_export_code)) {
|
||||
print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', $user->rights->export->creer);
|
||||
}
|
||||
print '</div>';
|
||||
@ -71,10 +70,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
|
||||
$model = new ModeleExports($db);
|
||||
$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties
|
||||
|
||||
foreach ($liste as $key => $val)
|
||||
{
|
||||
if (preg_match('/__\(Disabled\)__/', $liste[$key]))
|
||||
{
|
||||
foreach ($liste as $key => $val) {
|
||||
if (preg_match('/__\(Disabled\)__/', $liste[$key])) {
|
||||
$liste[$key] = preg_replace('/__\(Disabled\)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
|
||||
}
|
||||
|
||||
|
||||
@ -26,14 +26,17 @@
|
||||
* \brief Page de configuration du module externalsite
|
||||
*/
|
||||
|
||||
if (!defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
|
||||
if (!defined('NOSCANPOSTFORINJECTION')) {
|
||||
define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
|
||||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
|
||||
if (!$user->admin)
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'other', 'externalsite'));
|
||||
@ -43,8 +46,7 @@ $def = array();
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Sauvegardes parametres
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($action == 'update') {
|
||||
$i = 0;
|
||||
|
||||
$db->begin();
|
||||
@ -55,8 +57,7 @@ if ($action == 'update')
|
||||
$i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
|
||||
$i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if ($i >= 2)
|
||||
{
|
||||
if ($i >= 2) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
|
||||
@ -44,35 +44,29 @@ $keyforcontent = GETPOST('keyforcontent', 'aZ09');
|
||||
* View
|
||||
*/
|
||||
|
||||
if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL))
|
||||
{
|
||||
if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) {
|
||||
llxHeader();
|
||||
print '<div class="error">'.$langs->trans('ExternalSiteModuleNotComplete').'</div>';
|
||||
llxFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($keyforcontent))
|
||||
{
|
||||
if (!empty($keyforcontent)) {
|
||||
llxHeader();
|
||||
|
||||
print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
|
||||
|
||||
if (!preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)
|
||||
&& !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent))
|
||||
{
|
||||
&& !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorBadSyntaxForParamKeyForContent", 'EXTERNAL_SITE_CONTENT_', 'EXTERNAL_SITE_URL_');
|
||||
} elseif (empty($conf->global->$keyforcontent))
|
||||
{
|
||||
} elseif (empty($conf->global->$keyforcontent)) {
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorVariableKeyForContentMustBeSet", 'EXTERNAL_SITE_CONTENT_'.$keyforcontent, 'EXTERNAL_SITE_URL_'.$keyforcontent);
|
||||
} else {
|
||||
if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent))
|
||||
{
|
||||
if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) {
|
||||
print $conf->global->$keyforcontent;
|
||||
} elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent))
|
||||
{
|
||||
} elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
|
||||
/*print "
|
||||
<html>
|
||||
<head>
|
||||
@ -80,17 +74,17 @@ if (!empty($keyforcontent))
|
||||
</head>
|
||||
|
||||
<frameset ".(empty($conf->global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
|
||||
<frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
|
||||
<frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
|
||||
";
|
||||
print '<frame name="main" src="';
|
||||
print $conf->global->$keyforcontent;
|
||||
print '">';
|
||||
print "
|
||||
<noframes>
|
||||
<body>
|
||||
<noframes>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</noframes>
|
||||
</body>
|
||||
</noframes>
|
||||
</frameset>
|
||||
|
||||
<noframes>
|
||||
@ -111,8 +105,7 @@ if (!empty($keyforcontent))
|
||||
print '<div>';
|
||||
llxFooter();
|
||||
} else {
|
||||
if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL))
|
||||
{
|
||||
if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) {
|
||||
print "
|
||||
<html>
|
||||
<head>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user