forked from Wavyzz/dolibarr
Fix: Removed warning and fix pb with extra fields.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
include_once("./inc.php");
|
include_once("./inc.php");
|
||||||
if (file_exists($conffile)) include_once($conffile);
|
if (file_exists($conffile)) include_once($conffile);
|
||||||
require_once($dolibarr_main_document_root."/core/lib/admin.lib.php");
|
require_once($dolibarr_main_document_root."/core/lib/admin.lib.php");
|
||||||
|
require_once($dolibarr_main_document_root."/core/class/extrafields.class.php");
|
||||||
|
|
||||||
|
|
||||||
$grant_query='';
|
$grant_query='';
|
||||||
@@ -189,6 +190,67 @@ if ($ok)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Search list of fields declared and list of fields created into databases and create fields missing
|
||||||
|
$extrafields=new ExtraFields($db);
|
||||||
|
$listofmodulesextra=array('societe'=>'company','adherent'=>'member','product'=>'product');
|
||||||
|
foreach($listofmodulesextra as $tablename => $elementtype)
|
||||||
|
{
|
||||||
|
// Get list of fields
|
||||||
|
$tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields';
|
||||||
|
|
||||||
|
// Define $arrayoffieldsdesc
|
||||||
|
$arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype);
|
||||||
|
|
||||||
|
// Define $arrayoffieldsfound
|
||||||
|
$arrayoffieldsfound=array();
|
||||||
|
$resql=$db->DDLDescTable($tableextra);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
print '<tr><td>Check availability of extra field for '.$tableextra."<br>\n";
|
||||||
|
$i=0;
|
||||||
|
while($obj=$db->fetch_object($resql))
|
||||||
|
{
|
||||||
|
$fieldname = isset($obj->Key)?$obj->Key:$obj->attname;
|
||||||
|
$fieldtype = isset($obj->Type)?$obj->Type:'varchar';
|
||||||
|
|
||||||
|
if (empty($fieldname)) continue;
|
||||||
|
if (in_array($fieldname,array('rowid','tms','fk_object','import_key'))) continue;
|
||||||
|
$arrayoffieldsfound[$fieldname]=$fieldtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it does not match, we create fields
|
||||||
|
foreach($arrayoffieldsdesc as $code => $label)
|
||||||
|
{
|
||||||
|
if (! in_array($code,array_keys($arrayoffieldsfound)))
|
||||||
|
{
|
||||||
|
print 'Found field '.$code.' declared into '.MAIN_DB_PREFIX.'extrafields table but not found into desc of table '.$tableextra." -> ";
|
||||||
|
$field_desc=array(
|
||||||
|
'type'=>'varchar',
|
||||||
|
'value'=>'',
|
||||||
|
'attribute'=>'',
|
||||||
|
'default'=>'',
|
||||||
|
'extra'=>'',
|
||||||
|
'null'=>'null'
|
||||||
|
);
|
||||||
|
|
||||||
|
$result=$db->DDLAddField($tableextra,$code,$field_desc,"");
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
print "KO ".$db->lasterror."<br>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "OK<br>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</td><td> </td></tr>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Run purge of directory
|
// Run purge of directory
|
||||||
if (GETPOST('purge'))
|
if (GETPOST('purge'))
|
||||||
{
|
{
|
||||||
@@ -198,7 +260,7 @@ if (GETPOST('purge'))
|
|||||||
foreach ($listmodulepart as $modulepart)
|
foreach ($listmodulepart as $modulepart)
|
||||||
{
|
{
|
||||||
$filearray=array();
|
$filearray=array();
|
||||||
$upload_dir = $conf->$modulepart->dir_output;
|
$upload_dir = isset($conf->$modulepart->dir_output)?$conf->$modulepart->dir_output:'';
|
||||||
if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
|
if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
|
||||||
if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output;
|
if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output;
|
||||||
if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
|
if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
|
||||||
|
|||||||
Reference in New Issue
Block a user