Fix preview of PDF contract

This commit is contained in:
Laurent Destailleur 2017-05-18 12:40:20 +02:00
parent a36a9fab2f
commit 4a46480ef5
4 changed files with 63 additions and 19 deletions

View File

@ -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>';

View File

@ -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))
{

View File

@ -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);
}
}

View File

@ -79,13 +79,6 @@ class modFacture extends DolibarrModules
$this->const = array();
$r=0;
$this->const[$r][0] = "FACTURE_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "crabe";
$this->const[$r][3] = 'Name of PDF model of invoice';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "FACTURE_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_facture_terre";
@ -93,6 +86,13 @@ class modFacture extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "FACTURE_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "crabe";
$this->const[$r][3] = 'Name of PDF model of invoice';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices";
@ -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);