From 4a46480ef54c0867de4de77da5bffe62066d5f46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 18 May 2017 12:40:20 +0200 Subject: [PATCH] Fix preview of PDF contract --- htdocs/admin/salaries.php | 4 +- htdocs/core/lib/files.lib.php | 6 +++ htdocs/core/modules/modContrat.class.php | 54 ++++++++++++++++++++---- htdocs/core/modules/modFacture.class.php | 16 +++---- 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index 52470be4106..8f115d3963b 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -85,7 +85,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="update">'; -dol_fiche_head(); +//dol_fiche_head(null, '', '', -1); /* * Params @@ -122,7 +122,7 @@ print '</tr>'; print "</table>\n"; -dol_fiche_end(); +//dol_fiche_end(); print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>'; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 39865905553..4c3be3cc4d1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1706,6 +1706,12 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu if ($fuser->rights->ficheinter->lire) $accessallowed=1; $original_file=$conf->ficheinter->dir_output.'/'.$original_file; } + // Wrapping pour les apercu conat + elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output)) + { + if ($fuser->rights->contrat->lire) $accessallowed=1; + $original_file=$conf->contrat->dir_output.'/'.$original_file; + } // Wrapping pour les apercu supplier proposal elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index c4c8cd500fb..52127c4e6f4 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -70,12 +70,29 @@ class modContrat extends DolibarrModules // Constants $this->const = array(); - $this->const[0][0] = "CONTRACT_ADDON"; - $this->const[0][1] = "chaine"; - $this->const[0][2] = "mod_contract_serpis"; - $this->const[0][3] = 'Nom du gestionnaire de numerotation des contrats'; - $this->const[0][4] = 0; - + $r=0; + + $this->const[$r][0] = "CONTRACT_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_contract_serpis"; + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des contrats'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "CONTRACT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "strato"; + $this->const[$r][3] = 'Name of PDF model of contract'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "CONTRACT_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/contracts"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + // Boxes $this->boxes = array( 0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'), @@ -202,8 +219,29 @@ class modContrat extends DolibarrModules // Nettoyage avant activation $this->remove($options); - $sql = array(); - + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/contracts'; + $dest=$dirodt.'/template_contract.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $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->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")" + ); + return $this->_init($sql,$options); } } diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 7029b7ffd78..b16c7749e40 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -79,17 +79,17 @@ class modFacture extends DolibarrModules $this->const = array(); $r=0; - $this->const[$r][0] = "FACTURE_ADDON_PDF"; + $this->const[$r][0] = "FACTURE_ADDON"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "crabe"; - $this->const[$r][3] = 'Name of PDF model of invoice'; + $this->const[$r][2] = "mod_facture_terre"; + $this->const[$r][3] = 'Name of numbering numerotation rules of invoice'; $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "FACTURE_ADDON"; + $this->const[$r][0] = "FACTURE_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "mod_facture_terre"; - $this->const[$r][3] = 'Name of numbering numerotation rules of invoice'; + $this->const[$r][2] = "crabe"; + $this->const[$r][3] = 'Name of PDF model of invoice'; $this->const[$r][4] = 0; $r++; @@ -311,8 +311,8 @@ class modFacture extends DolibarrModules } $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'invoice' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','invoice',".$conf->entity.")" + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'invoice' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','invoice',".$conf->entity.")" ); return $this->_init($sql,$options); -- GitLab