New: Allow to use ODT templates for prososal like it's done for invoices

This commit is contained in:
Laurent Destailleur
2012-02-05 19:37:52 +01:00
parent 0e827b7c20
commit 2093b3f0be
36 changed files with 309 additions and 95 deletions

View File

@@ -90,7 +90,7 @@ class modCommande extends DolibarrModules
$this->const[$r][2] = "mod_commande_marbre";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
@@ -195,7 +195,7 @@ class modCommande extends DolibarrModules
*/
function init($options='')
{
global $conf;
global $conf,$langs;
// Permissions
$this->remove();
@@ -204,11 +204,18 @@ class modCommande extends DolibarrModules
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$dirodt=DOL_DATA_ROOT.'/doctemplates/orders';
create_exdir($dirodt);
dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt',$dirodt.'/template_order.odt',0,0);
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dest=$dirodt.'/template_order.odt';
$result=dol_copy($src,$dest,0,0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0;
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."'",
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES('".$this->const[0][2]."','order')"
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','order',".$conf->entity.")"
);
return $this->_init($sql,$options);
@@ -216,8 +223,12 @@ class modCommande extends DolibarrModules
/**
* \brief Fonction appelee lors de la desactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module.
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove()
{