Work on odt generation
Add warning if postgresql has a wrong configuration
This commit is contained in:
parent
20b2c211b7
commit
359fab73c5
@ -79,7 +79,8 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
|
||||
{
|
||||
create_exdir($conf->mycompany->dir_output.'/logos/');
|
||||
}
|
||||
if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']) > 0)
|
||||
$result=dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']);
|
||||
if ($result > 0)
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file,'chaine',0,'',$conf->entity);
|
||||
|
||||
@ -108,6 +109,12 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update')
|
||||
}
|
||||
else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING);
|
||||
}
|
||||
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$tmparray=explode(':',$result);
|
||||
$message .= '<div class="error">'.$langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]).'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
|
||||
@ -64,13 +64,13 @@ $base=0;
|
||||
$sqls = array();
|
||||
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
|
||||
{
|
||||
$sqls[0] = "SHOW VARIABLES";
|
||||
$sqls[1] = "SHOW STATUS";
|
||||
$sqls[0] = "SHOW VARIABLES"; // TODO Use function getServerParametersValues
|
||||
$sqls[1] = "SHOW STATUS"; // TODO Use function getServerStatusValues
|
||||
$base=1;
|
||||
}
|
||||
else if ($conf->db->type == 'pgsql')
|
||||
{
|
||||
$sqls[0] = "select name,setting from pg_settings;";
|
||||
$sqls[0] = "select name,setting from pg_settings";
|
||||
$base=2;
|
||||
}
|
||||
else if ($conf->db->type == 'mssql')
|
||||
|
||||
@ -89,9 +89,20 @@ $dblabel=$db->getLabel();
|
||||
$dbversion=$db->getVersion();
|
||||
print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n";
|
||||
print '</table>';
|
||||
// Add checks on database options
|
||||
if ($db->type == 'pgsql')
|
||||
{
|
||||
// Check option standard_conforming_strings is on
|
||||
$paramarray=$db->getServerParametersValues('standard_conforming_strings');
|
||||
if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1)
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<div class="error">'.$langs->trans("ErrorDatabaseParameterWrong",'standard_conforming_strings','on').'</div>';
|
||||
}
|
||||
}
|
||||
print '<br>';
|
||||
|
||||
// Database
|
||||
// Browser
|
||||
print '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Browser")."</td></tr>\n";
|
||||
print "<tr $bc[0]><td width=\"280\">".$langs->trans("UserAgent")."</td><td>" .$_SERVER["HTTP_USER_AGENT"]."</td></tr>\n";
|
||||
|
||||
@ -92,7 +92,7 @@ class modFacture extends DolibarrModules
|
||||
|
||||
$this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/odttemplates/invoices";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
@ -217,9 +217,9 @@ class modFacture extends DolibarrModules
|
||||
$this->remove();
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
|
||||
$dirodt=DOL_DATA_ROOT.'/odttemplates/invoices';
|
||||
$dirodt=DOL_DATA_ROOT.'/doctemplates/invoices';
|
||||
create_exdir($dirodt);
|
||||
dol_copy(DOL_DOCUMENT_ROOT.'/install/odttemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0);
|
||||
dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0);
|
||||
|
||||
$sql = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
|
||||
|
||||
@ -104,7 +104,7 @@ class modSociete extends DolibarrModules
|
||||
|
||||
$this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/odttemplates/thirdparties";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
@ -277,9 +277,9 @@ class modSociete extends DolibarrModules
|
||||
//$this->remove($options);
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
|
||||
$dirodt=DOL_DATA_ROOT.'/odttemplates/thirdparties';
|
||||
$dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties';
|
||||
create_exdir($dirodt);
|
||||
dol_copy(DOL_DOCUMENT_ROOT.'/install/odttemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0);
|
||||
dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0);
|
||||
|
||||
$sql = array();
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
function get_substitutionarray_mysoc($mysoc)
|
||||
{
|
||||
return array(
|
||||
'mycompany_logo'=>$mysoc->logo,
|
||||
'mycompany_name'=>$mysoc->name,
|
||||
'mycompany_email'=>$mysoc->email,
|
||||
'mycompany_phone'=>$mysoc->phone,
|
||||
@ -90,13 +91,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
'mycompany_zip'=>$mysoc->zip,
|
||||
'mycompany_town'=>$mysoc->town,
|
||||
'mycompany_country'=>$mysoc->country,
|
||||
'mycompany_url'=>$mysoc->url,
|
||||
'mycompany_web'=>$mysoc->url,
|
||||
'mycompany_juridicalstatus'=>$mysoc->forme_juridique,
|
||||
'mycompany_capital'=>$mysoc->capital,
|
||||
'mycompany_barcode'=>$mysoc->gencode,
|
||||
'mycompany_vat'=>$mysoc->tva_intra,
|
||||
'mycompany_idprof1'=>$mysoc->profid1,
|
||||
'mycompany_idprof2'=>$mysoc->profid2,
|
||||
'mycompany_idprof3'=>$mysoc->profid3,
|
||||
'mycompany_idprof4'=>$mysoc->profid4,
|
||||
'mycompany_vatnumber'=>$mysoc->tva_intra,
|
||||
'mycompany_note'=>$mysoc->note
|
||||
);
|
||||
}
|
||||
@ -118,13 +121,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
'company_zip'=>$object->zip,
|
||||
'company_town'=>$object->town,
|
||||
'company_country'=>$object->country,
|
||||
'company_url'=>$object->url,
|
||||
'company_web'=>$object->url,
|
||||
'company_barcode'=>$object->gencode,
|
||||
'company_vat'=>$object->tva_intra,
|
||||
'company_vatnumber'=>$object->tva_intra,
|
||||
'company_customercode'=>$object->code_client,
|
||||
'company_suppliercode'=>$object->code_fournisseur,
|
||||
'company_customeraccountancycode'=>$object->code_compta,
|
||||
'company_supplieraccountancycode'=>$object->code_compta_fournisseur,
|
||||
'company_juridicalstatus'=>$object->forme_juridique,
|
||||
'company_capital'=>$object->capital,
|
||||
'company_idprof1'=>$object->idprof1,
|
||||
'company_idprof2'=>$object->idprof2,
|
||||
'company_idprof3'=>$object->idprof3,
|
||||
|
||||
BIN
htdocs/install/doctemplates/thirdparties/template_thirdparty.odt
Normal file
BIN
htdocs/install/doctemplates/thirdparties/template_thirdparty.odt
Normal file
Binary file not shown.
Binary file not shown.
@ -69,3 +69,4 @@ WarningsOnXLines=Warnings on <b>%s</b> source lines
|
||||
ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus)
|
||||
ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s"
|
||||
WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup.
|
||||
ErrorDatabaseParameterWrong=Database setup parameter '<b>%s</b>' has a value not compatible to use Dolibarr (must have value '<b>%s</b>').
|
||||
|
||||
@ -70,3 +70,4 @@ WarningsOnXLines=Alertes sur <b>%s</b> lignes sources
|
||||
ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) !
|
||||
ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis pour le champ "%s"
|
||||
WarningNoDocumentModelActivated=Aucun modèle, pour la génération de document, n'a été activé. Un modèle sera pris par défaut en attendant la correction de configuration du module.
|
||||
ErrorDatabaseParameterWrong=Le paramètre de configuration de la base de donnée '<b>%s</b>' a une valeur non compatible pour une utilisation de Dolibarr (doit avoir la valeur '<b>%s</b>').
|
||||
@ -1155,6 +1155,47 @@ class DoliDb
|
||||
return $fullpathofimport;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server parameters
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
*/
|
||||
function getServerParametersValues($filter='')
|
||||
{
|
||||
$result=array();
|
||||
|
||||
$sql='SHOW VARIABLES';
|
||||
if ($filter) $sql.=" LIKE '".addslashes($key)."'";
|
||||
$resql=$this->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->fetch_object($resql);
|
||||
$result[$obj->Variable_name]=$obj->Value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server status
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
*/
|
||||
function getServerStatusValues($key,$filter='')
|
||||
{
|
||||
$result=array();
|
||||
|
||||
$sql='SHOW STATUS';
|
||||
if ($filter) $sql.=" LIKE '".addslashes($key)."'";
|
||||
$resql=$this->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->fetch_object($resql);
|
||||
$result[$obj->Variable_name]=$obj->Value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1167,6 +1167,47 @@ class DoliDb
|
||||
return $fullpathofimport;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server parameters
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
*/
|
||||
function getServerParametersValues($key,$filter='')
|
||||
{
|
||||
$result=array();
|
||||
|
||||
$sql='SHOW VARIABLES';
|
||||
if ($filter) $sql.=" LIKE '".addslashes($key)."'";
|
||||
$resql=$this->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->fetch_object($resql);
|
||||
$result[$obj->Variable_name]=$obj->Value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server status
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
*/
|
||||
function getServerStatusValues($filter='')
|
||||
{
|
||||
$result=array();
|
||||
|
||||
$sql='SHOW STATUS';
|
||||
if ($filter) $sql.=" LIKE '".addslashes($key)."'";
|
||||
$resql=$this->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->fetch_object($resql);
|
||||
$result[$obj->Variable_name]=$obj->Value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1221,5 +1221,25 @@ class DoliDb
|
||||
return $fullpathofmysqldump;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return value of server parameters
|
||||
* \param filter Filter list on a particular value
|
||||
* \return string Value for parameter
|
||||
*/
|
||||
function getServerParametersValues($filter='')
|
||||
{
|
||||
$result=array();
|
||||
|
||||
$resql='select name,setting from pg_settings';
|
||||
if ($filter) $resql.=" WHERE name = '".addslashes($filter)."'";
|
||||
$resql=$this->query($resql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->fetch_object($resql);
|
||||
$result[$obj->name]=$obj->setting;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -294,40 +294,47 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
|
||||
/*
|
||||
* Generate document
|
||||
*/
|
||||
if ($_REQUEST['action'] == 'builddoc' && ! is_numeric($_REQUEST['model'])) // En get ou en post
|
||||
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
$soc->fetch_client();
|
||||
|
||||
/*if ($_REQUEST['model'])
|
||||
if (is_numeric($_REQUEST['model']))
|
||||
{
|
||||
$fac->setDocModel($user, $_REQUEST['model']);
|
||||
}
|
||||
*/
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||
exit;
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
$soc->fetch_client();
|
||||
|
||||
/*if ($_REQUEST['model'])
|
||||
{
|
||||
$fac->setDocModel($user, $_REQUEST['model']);
|
||||
}
|
||||
*/
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user