Several fixes in export and repair tool

This commit is contained in:
Laurent Destailleur 2020-11-27 15:27:35 +01:00
parent ac3c129735
commit 4a5cdd0092
5 changed files with 12 additions and 45 deletions

View File

@ -212,7 +212,7 @@ class Interfaces
if ($result < 0)
{
// Action KO
//dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR);
//dol_syslog("Error in trigger ".$action." - result = ".$result." - Nb of error strings returned = ".count($objMod->errors), LOG_ERR);
$nbtotal++;
$nbko++;
if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors);

View File

@ -300,6 +300,7 @@ class modBom extends DolibarrModules
$this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bom_extrafields as extra on (t.rowid = extra.fk_object)';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid';
$this->export_sql_end[$r] .= ' WHERE 1 = 1';
$this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')';

View File

@ -176,56 +176,20 @@ class modCategorie extends DolibarrModules
's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company',
's.fk_stcomm'=>'company'
); // We define here only fields that use another picto
$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object ';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
$this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories
// Add extra fields
$sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj = $this->db->fetch_object($resql))
{
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$typeFilter = "Text";
switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
$typeFilter = "Date";
break;
case 'boolean':
$typeFilter = "Boolean";
break;
case 'sellist':
$typeFilter = "List:".$obj->param;
break;
case 'select':
$typeFilter = "Select:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname] = 'company';
}
}
// End add axtra fields
$r++;
$this->export_code[$r] = 'category_'.$r;
$this->export_label[$r] = 'CatProdList';

View File

@ -102,6 +102,7 @@ class Export
// Search module files
while (($file = readdir($handle)) !== false)
{
$reg = array();
if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg))
{
$modulename = $reg[1];

View File

@ -231,7 +231,7 @@ if ($ok && GETPOST('standard', 'alpha'))
$listofmodulesextra = array('societe'=>'societe', 'adherent'=>'adherent', 'product'=>'product',
'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture',
'supplier_proposal'=>'supplier_proposal', 'commande_fournisseur'=>'commande_fournisseur', 'facture_fourn'=>'facture_fourn',
'actioncomm'=>'actioncomm',
'actioncomm'=>'actioncomm', 'bom_bom'=>'bom_bom', 'mrp_mo'=>'mrp_mo',
'adherent_type'=>'adherent_type', 'user'=>'user', 'projet'=>'projet', 'projet_task'=>'projet_task');
print '<tr><td colspan="2"><br>*** Check fields into extra table structure match table of definition. If not add column into table</td></tr>';
foreach ($listofmodulesextra as $tablename => $elementtype)
@ -268,6 +268,7 @@ if ($ok && GETPOST('standard', 'alpha'))
$arrayoffieldsfound[$fieldname] = array('type'=>$fieldtype);
}
// If it does not match, we create fields
foreach ($arrayoffieldsdesc as $code => $label)
{