Add error management to avoid blank page when there is no permission to

read file.
This commit is contained in:
Laurent Destailleur 2013-10-23 19:19:54 +02:00
parent fe4df6770a
commit 16bcd6b5e5
7 changed files with 132 additions and 84 deletions

View File

@ -392,6 +392,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -401,6 +402,12 @@ class doc_generic_order_odt extends ModelePDFCommandes
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -392,6 +392,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -401,6 +402,12 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -423,6 +423,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -432,6 +433,12 @@ class doc_generic_invoice_odt extends ModelePDFFactures
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -469,6 +469,7 @@ class doc_generic_project_odt extends ModelePDFProjects
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -478,6 +479,12 @@ class doc_generic_project_odt extends ModelePDFProjects
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -455,6 +455,7 @@ class doc_generic_task_odt extends ModelePDFTask
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -464,6 +465,12 @@ class doc_generic_task_odt extends ModelePDFTask
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -344,6 +344,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -353,6 +354,12 @@ class doc_generic_proposal_odt extends ModelePDFPropales
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and // After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --] // [!-- BEGIN lines --]*[!-- END lines --]

View File

@ -236,6 +236,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
@ -245,7 +246,12 @@ class doc_generic_odt extends ModeleThirdPartyDoc
'DELIMITER_RIGHT' => '}' 'DELIMITER_RIGHT' => '}'
) )
); );
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
//print $odfHandler->__toString()."\n"; //print $odfHandler->__toString()."\n";
// Make substitutions into odt of user info // Make substitutions into odt of user info