Merge pull request #873 from FHenry/develop
Add debug script and better ODT error management
This commit is contained in:
commit
f67bf0eef2
@ -137,6 +137,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|||||||
$sql.= $db->order($sortfield,$sortorder);
|
$sql.= $db->order($sortfield,$sortorder);
|
||||||
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||||
|
|
||||||
|
dol_syslog('comm:list.php: sql='.$sql,LOG_DEBUG);
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -245,10 +245,10 @@ abstract class CommonDocGenerator
|
|||||||
$array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
$array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
||||||
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
|
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
|
||||||
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
||||||
$array_key.'_total_ht'=>price2num($object->total_ht2,2),
|
$array_key.'_total_ht'=>price($object->total_ht2),
|
||||||
$array_key.'_total_vat'=>price2num($object->total_tva,2),
|
$array_key.'_total_vat'=>price($object->total_tva),
|
||||||
$array_key.'_total_ttc'=>price2num($object->total_ttc,2),
|
$array_key.'_total_ttc'=>price($object->total_ttc),
|
||||||
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount(),2),
|
$array_key.'_total_discount_ht' => price($object->getTotalDiscount()),
|
||||||
$array_key.'_vatrate'=>vatrate($object->tva),
|
$array_key.'_vatrate'=>vatrate($object->tva),
|
||||||
$array_key.'_note_private'=>$object->note,
|
$array_key.'_note_private'=>$object->note,
|
||||||
$array_key.'_note'=>$object->note_public,
|
$array_key.'_note'=>$object->note_public,
|
||||||
@ -293,12 +293,12 @@ abstract class CommonDocGenerator
|
|||||||
'line_product_label'=>$line->product_label,
|
'line_product_label'=>$line->product_label,
|
||||||
'line_desc'=>$line->desc,
|
'line_desc'=>$line->desc,
|
||||||
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
||||||
'line_up'=>price2num($line->subprice, 2),
|
'line_up'=>price($line->subprice),
|
||||||
'line_qty'=>$line->qty,
|
'line_qty'=>$line->qty,
|
||||||
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
||||||
'line_price_ht'=>price2num($line->total_ht,2),
|
'line_price_ht'=>price($line->total_ht),
|
||||||
'line_price_ttc'=>price2num($line->total_ttc,2),
|
'line_price_ttc'=>price($line->total_ttc),
|
||||||
'line_price_vat'=>price2num($line->total_tva,2),
|
'line_price_vat'=>price($line->total_tva),
|
||||||
'line_date_start'=>$line->date_start,
|
'line_date_start'=>$line->date_start,
|
||||||
'line_date_end'=>$line->date_end
|
'line_date_end'=>$line->date_end
|
||||||
);
|
);
|
||||||
|
|||||||
@ -520,10 +520,20 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
try {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
@ -498,10 +498,20 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
try {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
@ -974,10 +974,20 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
try {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
@ -483,10 +483,20 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
try {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
@ -325,10 +325,20 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||||||
|
|
||||||
// Write new file
|
// Write new file
|
||||||
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
|
||||||
$odfHandler->exportAsAttachedPDF($file);
|
try {
|
||||||
|
$odfHandler->exportAsAttachedPDF($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
$odfHandler->saveToDisk($file);
|
$odfHandler->saveToDisk($file);
|
||||||
|
}catch (Exception $e){
|
||||||
|
$this->error=$e->getMessage();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
@ -452,14 +452,18 @@ IMG;
|
|||||||
|
|
||||||
if( $name == "" ) $name = md5(uniqid());
|
if( $name == "" ) $name = md5(uniqid());
|
||||||
|
|
||||||
//dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG);
|
dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG);
|
||||||
$this->saveToDisk($name);
|
$this->saveToDisk($name);
|
||||||
|
|
||||||
$execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2
|
$execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2
|
||||||
|
|
||||||
$name=str_replace('.odt', '', $name);
|
$name=str_replace('.odt', '', $name);
|
||||||
$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name;
|
$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name;
|
||||||
//dol_syslog('$execmethod='.$execmethod.' Run command='.$command);
|
|
||||||
|
//$dirname=dirname($name);
|
||||||
|
//$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name.' '.$dirname;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this).'::exportAsAttachedPDF $execmethod='.$execmethod.' Run command='.$command,LOG_DEBUG);
|
||||||
if ($execmethod == 1)
|
if ($execmethod == 1)
|
||||||
{
|
{
|
||||||
exec($command, $output_arr, $retval);
|
exec($command, $output_arr, $retval);
|
||||||
@ -470,7 +474,7 @@ IMG;
|
|||||||
$handle = fopen($outputfile, 'w');
|
$handle = fopen($outputfile, 'w');
|
||||||
if ($handle)
|
if ($handle)
|
||||||
{
|
{
|
||||||
dol_syslog("Run command ".$command);
|
dol_syslog(get_class($this)."Run command ".$command,LOG_DEBUG);
|
||||||
$handlein = popen($command, 'r');
|
$handlein = popen($command, 'r');
|
||||||
while (!feof($handlein))
|
while (!feof($handlein))
|
||||||
{
|
{
|
||||||
@ -486,7 +490,7 @@ IMG;
|
|||||||
|
|
||||||
if($retval == 0)
|
if($retval == 0)
|
||||||
{
|
{
|
||||||
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||||
if (headers_sent($filename, $linenum)) {
|
if (headers_sent($filename, $linenum)) {
|
||||||
throw new OdfException("headers already sent ($filename at $linenum)");
|
throw new OdfException("headers already sent ($filename at $linenum)");
|
||||||
}
|
}
|
||||||
@ -498,12 +502,18 @@ IMG;
|
|||||||
}
|
}
|
||||||
unlink("$name.odt");
|
unlink("$name.odt");
|
||||||
} else {
|
} else {
|
||||||
//dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG);
|
||||||
//dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr,true), LOG_DEBUG);
|
dol_syslog(get_class($this).'::exportAsAttachedPDF $output_arr='.var_export($output_arr,true), LOG_DEBUG);
|
||||||
echo "Error occured:<br>";
|
|
||||||
foreach($output_arr as $line)
|
if ($retval==126) {
|
||||||
echo $line."<br>";
|
throw new OdfException('Permission execute convert script : ' . $command);
|
||||||
//dol_syslog(get_class($this).'::exportAsAttachedPDF ERROR $line='.$line, LOG_DEBUG);
|
}
|
||||||
|
else {
|
||||||
|
foreach($output_arr as $line) {
|
||||||
|
$errors.= $line."<br>";
|
||||||
|
}
|
||||||
|
throw new OdfException('ODT to PDF convert fail : ' . $errors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
|
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
|
||||||
|
# @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
|
||||||
|
|
||||||
|
#
|
||||||
|
#if [ -f "$1.odt" ]
|
||||||
|
# then
|
||||||
|
# soffice --invisible --convert-to pdf:writer_pdf_Export --outdir $2 "$1.odt"
|
||||||
|
# retcode=$?
|
||||||
|
# if [ $retcode -ne 0 ]
|
||||||
|
# then
|
||||||
|
# echo "Error while converting odt to pdf: $retcode";
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# echo "Error: Odt file does not exist"
|
||||||
|
# exit 1
|
||||||
|
#fi
|
||||||
|
|
||||||
if [ -f "$1.odt" ]
|
if [ -f "$1.odt" ]
|
||||||
then
|
then
|
||||||
pgrep -U `id -u` soffice
|
nbprocess=$(pgrep -c soffice)
|
||||||
if [ $? -ne 0 ]
|
if [ $nbprocess -ne 1 ]
|
||||||
then
|
then
|
||||||
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
|
soffice --invisible --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard --headless
|
||||||
sleep 2
|
retcode=$?
|
||||||
fi
|
if [ $retcode -ne 0 ]
|
||||||
jodconverter "$1.odt" "$1.pdf"
|
then
|
||||||
if [ $? -ne 0 ]
|
echo "Error running soffice: $retcode"
|
||||||
then
|
exit 1
|
||||||
echo "Error while converting odt to pdf"
|
fi
|
||||||
exit 1
|
sleep 2
|
||||||
fi
|
fi
|
||||||
sleep 1
|
jodconverter "$1.odt" "$1.pdf"
|
||||||
else
|
retcode=$?
|
||||||
echo "Error: Odt file does not exist"
|
if [ $retcode -ne 0 ]
|
||||||
exit 1
|
then
|
||||||
|
echo "Error while converting odt to pdf: $retcode"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
echo "Error: Odt file does not exist"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -354,6 +354,7 @@ ExtrafieldPhone=Telèfon
|
|||||||
ExtrafieldPrice=Preu
|
ExtrafieldPrice=Preu
|
||||||
ExtrafieldMail=Correu
|
ExtrafieldMail=Correu
|
||||||
ExtrafieldSelect=Llista de selecció
|
ExtrafieldSelect=Llista de selecció
|
||||||
|
ExtrafieldSelectList=Llista de selecció de table
|
||||||
ExtrafieldSeparator=Separador
|
ExtrafieldSeparator=Separador
|
||||||
ExtrafieldCheckBox=Casella de verificació
|
ExtrafieldCheckBox=Casella de verificació
|
||||||
ExtrafieldRadio=Botó de selecció excloent
|
ExtrafieldRadio=Botó de selecció excloent
|
||||||
|
|||||||
@ -359,6 +359,7 @@ ExtrafieldPhone = Phone
|
|||||||
ExtrafieldPrice = Price
|
ExtrafieldPrice = Price
|
||||||
ExtrafieldMail = Email
|
ExtrafieldMail = Email
|
||||||
ExtrafieldSelect = Select list
|
ExtrafieldSelect = Select list
|
||||||
|
ExtrafieldSelectList = Select from table
|
||||||
ExtrafieldSeparator=Separator
|
ExtrafieldSeparator=Separator
|
||||||
ExtrafieldCheckBox=Checkbox
|
ExtrafieldCheckBox=Checkbox
|
||||||
ExtrafieldRadio=Radio button
|
ExtrafieldRadio=Radio button
|
||||||
|
|||||||
@ -356,6 +356,7 @@ ExtrafieldPhone=Teléfono
|
|||||||
ExtrafieldPrice=Precio
|
ExtrafieldPrice=Precio
|
||||||
ExtrafieldMail=Correo
|
ExtrafieldMail=Correo
|
||||||
ExtrafieldSelect=Lista de selección
|
ExtrafieldSelect=Lista de selección
|
||||||
|
ExtrafieldSelectList=Llista de selección de table
|
||||||
ExtrafieldSeparator=Separador
|
ExtrafieldSeparator=Separador
|
||||||
ExtrafieldCheckBox=Casilla de verificación
|
ExtrafieldCheckBox=Casilla de verificación
|
||||||
ExtrafieldRadio=Botón de selección excluyente
|
ExtrafieldRadio=Botón de selección excluyente
|
||||||
|
|||||||
@ -356,6 +356,7 @@ ExtrafieldPhone = Téléphone
|
|||||||
ExtrafieldPrice = Prix
|
ExtrafieldPrice = Prix
|
||||||
ExtrafieldMail = Email
|
ExtrafieldMail = Email
|
||||||
ExtrafieldSelect = Liste de sélection
|
ExtrafieldSelect = Liste de sélection
|
||||||
|
ExtrafieldSelectList = Liste issue d'une table
|
||||||
ExtrafieldSeparator = Séparateur de champ
|
ExtrafieldSeparator = Séparateur de champ
|
||||||
ExtrafieldCheckBox=Case à cocher
|
ExtrafieldCheckBox=Case à cocher
|
||||||
ExtrafieldRadio=Case d'option
|
ExtrafieldRadio=Case d'option
|
||||||
|
|||||||
@ -169,7 +169,7 @@ else
|
|||||||
$sql.= $db->order($sortfield,$sortorder);
|
$sql.= $db->order($sortfield,$sortorder);
|
||||||
$sql.= $db->plimit($limit + 1, $offset);
|
$sql.= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
dol_syslog("sql=".$sql);
|
dol_syslog("product:list.php: sql=".$sql);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user