64 $this->d_filename= basename($p_file);
65 $this->d_mimetype= mime_content_type($p_file);
66 $this->d_lob=$this->
db->lo_import($p_file);
67 if ($this->d_lob==
false)
69 echo
"ne peut pas importer [$p_file]";
72 $sql=
"update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3 where jr_id=$4 returning jr_id";
73 $id=$this->
db->get_value(
$sql, array($this->d_lob, $this->d_filename, $this->d_mimetype, $this->d_id));
76 throw new Exception(
"AD99 FILE NOT SAVED INTO DB",99);
101 $row = $this->
db->get_row(
"select jr_comment
109 jr_id=$1", [$this->d_id]);
113 $this->d_name=
$row[
'jr_pj_number'];
114 $this->d_description=
$row[
'jr_comment'];
115 $this->d_mimetype=
$row[
'jr_pj_type'];
116 $this->d_filename=
$row[
'jr_pj_name'];
117 $this->d_lob=
$row[
'jr_pj'];
118 $this->document_xml=
$row[
'jr_document_xml'];
130 if ($this->d_id == 0)
return false;
131 if ( ! file_exists($filename))
return false;
133 $this->d_mimetype= mime_content_type($filename);
134 $this->d_filename= basename($filename);
135 if ( $this->d_lob ==
"") {
136 $this->
db->lo_unlink($this->d_lob);
139 $this->d_lob=$this->
db->lo_import($filename);
141 "update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3
143 [$this->d_lob,$this->d_filename,$this->d_mimetype,$this->d_id]
154 if ($this->d_lob !=
"")
156 $this->
db->lo_unlink($this->d_lob);
158 $this->d_lob=$new_oid;
159 $this->
db->exec_sql(
"
179 $this->
db->exec_sql(
"update jrn set jr_document_xml=$1 where
238 $p_array[
'e_pj'] = $this->
db->get_value(
"select jr_pj_number from jrn where jr_id=$1"
242 $filename=$this->
db->get_value (
"select md_filename from document_modele where md_id=$1",
244 $filename =
$p_array[
'e_pj'].
"-".$filename;
247 $this->generate(
$p_array, $filename);
251 $sql =
"update jrn set jr_comment=' document " . $this->d_number .
"' where jr_internal=$1";
252 $this->
db->exec_sql(
$sql, [$internal]);
263 if (empty($this->d_filename)) {
268 if ($this->
db->lo_export($this->d_lob, $destination_file) ==
false) {
275 return $destination_file;
292 if ( $_FILES[
'pj'][
'name']==
"") {
295 $a_file= $this->
db->upload(
'pj',only_oid:
false);
296 if ($a_file ==
false) {
301 $old_oid = $this->
db->get_value(
"select jr_pj from jrn where jr_id=$1"
306 $this->
db->lo_unlink( $old_oid);
310 if ( $_FILES[
'pj'][
'type'] ==
'text/xml'
311 || $_FILES[
'pj'][
'type'] ==
'application/xml'
315 $this->
db->exec_sql(
"update jrn set jr_document_xml = $1
320 $xmlreader= \Noalyss\XMLDocument\XML_Reader::build_from_file($a_file[
'filename']);
328 $pdf=$xmlreader->to_pdf();
329 $file_oid=$this->
db->lo_write(
$pdf->Output(
"S"));
332 $this->d_name=
"invoice.pdf";
333 $this->d_description=
"Auto generated invoice";
334 $this->d_lob=$file_oid;
335 $this->d_mimetype=
"application/pdf";
338 $this->
db->exec_sql(
"update jrn set jr_pj=$1 , jr_pj_name=$2,
339 jr_pj_type=$3 where jr_id=$4",
343 , $this->d_description
349 $embedded_file=$xmlreader->get_embedded_document();
350 $nb_file = count($embedded_file);
351 for (
$i=0;
$i <$nb_file ;
$i++)
355 $binary=$embedded_file[
$i]->getBinary_object();
358 $sup_oid=$this->
db->lo_write($binary->filecontent);
362 $jrn_sup_document->js_mimetype=$binary->mimecode;
363 $jrn_sup_document->js_filename=$binary->filename;
364 $jrn_sup_document->js_lob=$sup_oid;
365 $jrn_sup_document->js_description=$embedded_file[
$i]->getDescription();
366 $jrn_sup_document->js_cbc_id=$embedded_file[
$i]->getId();
367 $jrn_sup_document->save();
370 }
catch (\Exception
$e ) {
372 throw new \Exception(
"X281 ",281,
$e);
376 $this->d_name=$_FILES[
'pj'][
'name'];
377 $this->d_description=$_FILES[
'pj'][
'type'];
380 $this->
db->exec_sql(
"update jrn set jr_pj=$1 , jr_pj_name=$2,
381 jr_pj_type=$3 where jr_id=$4",
385 , $this->d_description
400 $xml_oid=$this->
db->get_value(
"select jr_document_xml from jrn where jr_id=$1",
402 if ($xml_oid ==
"") {
return "";}
403 $url=
"export.php?".http_build_query(
405 "gDossier"=>\Dossier::id(),
406 "jr_id"=>$this->d_id,
407 "act"=>
'RAW:xml-invoice'
409 $r = sprintf(
'<a class="mtitle line" href="%s">',
$url);
411 .
'<i class="icon-download">'
420 $a_row=
$q->collect_objects(
" where jr_id=$1 order by js_cbc_id", [
$jr_id]);
424 foreach (
$a_row as $item) {
426 $script=
"Supplement_Document.delete_document('$gDossier','$div','{$item->js_id}','$jr_id')";
427 $rowid=sprintf(
"row_js_%s_%s",
$div,$item->js_id);
429 $download=
"export.php?". http_build_query(
431 "act"=>
"RAW:suppl-document"
432 ,
"js_id"=>$item->js_id
436 <div
class=
"row" id=
"<?=$rowid?>">
438 <a href=
"<?=$download?>" download> <?=$item->js_filename?></a>
441 <?=$item->js_description?>
noalyss_strlentrim($p_string)
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")
Document used in accountancy : invoice , credit note, ... It is a specialization of Document used in ...
set_id($jr_id)
set_id fill up d_filename, d_mimetype,d_lob,d_description,jr_pj_number
update($filename)
save the file into DB, will create a large object if there is no document to replace.
save_receipt()
Save a "piece justificative" , the name must be a receipt.
set_document_xml($document_xml)
replace_receipt($new_oid)
for FACTURX we replace the PDF save in DB by this one, always a PDF (since it is a FACTURX document)
update_document_xml($oid)
save the Large Object $oid in the column JRN.JR_DOCUMENT_XML
saveGenerated($p_file)
insert the generated Document into the database, update the $this->d_id that is the PK of document....
$document_xml
$document_xml (oid) XML document e-invoice
export_file($destination_file)
export the file to the file system and complet $this->d_mimetype, d_filename and
create_document($internal, $p_array)
create the invoice and saved it as attachment to the operation,
static display_supplementary_doc($cn, $div, $jr_id)
link_download_xml()
return a string with a link download XML or an empty string if there is no XML to download
__construct($cn, $jr_id=0)
constructor
Class Document corresponds to the table DOCUMENT.
download($aDocument)
Download all documents in a ZIP files.
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
abstract of the table public.jrn_sup_document
Get information from an XML Exception code :