diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index b8ba94391..e4175573b 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -1109,6 +1109,7 @@ class Acc_Detail extends Acc_Operation ,currency_id ,currency_rate ,currency_rate_ref + ,jr_document_xml FROM jrn where jr_id=$1"; $array=$this->db->get_array($sql,array($this->jr_id)); if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvée'); diff --git a/include/export/export_xml-invoice.php b/include/export/export_xml-invoice.php new file mode 100644 index 000000000..b02ac65f3 --- /dev/null +++ b/include/export/export_xml-invoice.php @@ -0,0 +1,122 @@ +get('jr_id',"number"); +} +catch (Exception $exc) +{ + record_log($exc); + return; +} + +$cn=Dossier::connect(); + +$r=$cn->exec_sql("select jr_def_id from jrn where jr_id=$1",array($jr_id)); + +if ( Database::num_row($r) == 0 ) +{ + echo_error("Invalid operation id jr_id=$jr_id"); + exit; +} +$a=Database::fetch_array($r,0); +$jrn=$a['jr_def_id']; +global $g_user; +if ($g_user->check_jrn($jrn) == 'X' ) +{ + /* Cannot Access */ + NoAccess(); + exit -1; +} + +$ret=$cn->exec_sql("select jr_pj_name,jr_pj_number ,jr_document_xml from jrn where jr_id=$1", + array($jr_id)); + +if ( Database::num_row ($ret) == 0 ) + return; + +$row=Database::fetch_array($ret,0); + +if ( $row['jr_document_xml']==null ) +{ + ini_set('zlib.output_compression','Off'); + header("Pragma: public"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Cache-Control: must-revalidate"); + header('Content-type: '.'text/plain'); + header('Content-Disposition: attachment;filename=vide.txt',FALSE); + header("Accept-Ranges: bytes"); + echo "******************"; + echo _("Fichier effacé"); + echo "******************"; + exit(); +} +$tmp=tempnam($_ENV['TMP'],'document_'); + +$new_name=$row['jr_pj_name']; +$receipt_number=clean_filename($row['jr_pj_number']); +$receipt_number=noalyss_str_replace('.','-',$receipt_number); +if ( ! empty($receipt_number) && strpos($new_name,$receipt_number) === false ) { + + $new_name=$receipt_number.'-'.$new_name; +} +// replace extension by xml (normally a PDF) +//@var $pos_ext (int) where is the last dot +$pos_ext=strrpos($new_name,'.'); +if ( $pos_ext == 0) +{ + // there is no extension + $new_name.='.xml'; +}else { + $new_name=substr_replace($new_name,'.xml',$pos_ext); +} +$cn->start(); + +$cn->lo_export($row['jr_document_xml'],$tmp); +$cn->commit(); + +ini_set('zlib.output_compression','Off'); +header("Pragma: public"); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); +header("Cache-Control: must-revalidate"); +header('Content-type: application/xml'); +header('Content-Disposition: attachment;filename="'.$new_name.'"',FALSE); +header("Accept-Ranges: bytes"); + +$file=fopen($tmp,'r'); +while ( !feof ($file) ) + echo fread($file,8192); + +fclose($file); + +unlink ($tmp); diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 3cd985c44..afd7307d8 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -9,7 +9,7 @@ * @brief show the common parts of operation details * * Variables : $div = popup or box (det[0-9] - * + *@var $obj = Acc_Operation */ bcscale(2); \Noalyss\Dbg::echo_file(__FILE__); @@ -44,13 +44,28 @@ $a_tab['linked_operation_div']=array('id'=>'linked_operation_div'.$div,'label'=> $a_tab['document_operation_div']=array('id'=>'document_operation_div'.$div,'label'=>_('Document').'('.$nb_document.')','display'=>'block'); $a_tab['linked_action_div']=array('id'=>'linked_action_div'.$div,'label'=>_('Actions Gestion').'('.count($a_followup).')','display'=>'none'); $a_tab['analytic_div']=array('id'=>'analytic_div'.$div,'label'=>_('Comptabilité Analytique'),'display'=>'none'); - +//var $g_parameter \Noalyss_Parameter_Folder +global $g_parameter; +// if using the XML Belgian format, add a tab for showing it +if ($obj->det->jr_document_xml != "") +{ + $a_tab['xml_document_div']= + [ + "id"=>"xml_document_div".$div + , "label"=>_("XML - UBL21") + , "display"=>'none' + ]; + +} // show tabs if ( $div != "popup") : $a_tab['document_operation_div']['display']='block'; + $tabs=array_column($a_tab,"id"); + ?> +">
@@ -317,7 +332,28 @@ require_once NOALYSS_TEMPLATE.'/ledger_detail_file.php'; - +det->jr_document_xml != "") { + printf ('