64 return "Document[db=" . $this->
db
65 .
", d_id=" . $this->d_id
66 .
", ag_id=" . $this->
ag_id
67 .
", d_mimetype=" . $this->d_mimetype
68 .
", d_filename=" . $this->d_filename
69 .
", d_lob=" . $this->d_lob
70 .
", d_description=" . $this->d_description
71 .
", d_number=" . $this->d_number
72 .
", md_id=" . $this->md_id
73 .
", f_id=" . $this->f_id
74 .
", counter=" . $this->counter
75 .
", d_name=" . $this->d_name
76 .
", md_type=" . $this->md_type
85 $this->d_id=$this->
db->get_next_seq(
"document_d_id_seq");
87 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".$this->md_type);
88 $sql=
'insert into document(d_id,ag_id,d_number) values($1,$2,$3)';
106 $pos_prefix=strrpos($filename,
".");
108 $pos_prefix=strlen($filename);
109 $filename_no=substr($filename, 0, $pos_prefix);
110 $filename_suff=substr($filename, $pos_prefix, strlen($filename));
112 foreach (array(
'/',
'*',
'<',
'>',
';',
',',
'\\',
'.',
':',
'(',
')',
' ',
'[',
']',
"'") as
$i)
119 $new_filename=strtolower($filename_no.
"-".$pj.$filename_suff);
124 return $new_filename;
139 function generate(
$p_array, $p_filename=
"")
144 $dirname=tempnam($_ENV[
'TMP'],
'doc_');
146 throw new Exception (
'DC117 cannot create tmp file',5000);
151 throw new Exception (
"DC121 cannot create $dirname directory",5000);
159 $file_to_parse=str_replace(
160 array(
'/',
'*',
'<',
'>',
';',
',',
'\\',
'.',
':',
'(',
')',
' ',
'[',
']')
162 ,
"inv-std-".
$p_array[
'e_pj']).
".pdf";
164 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_stdinv");
165 $this->d_filename=$file_to_parse;
166 $this->d_mimetype=
"application/pdf";
167 $this->d_name=$file_to_parse;
168 $standard_invoice=new \Noalyss\Invoice_PDF($this->
db,
$dirname,$file_to_parse);
169 $standard_invoice->set_data(
$p_array);
170 $standard_invoice->export();
173 $href=http_build_query(array(
'gDossier'=>Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
174 $ret=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.
_(
'Document').
'</A>';
180 $dm_info=
"select md_name,md_type,md_lob,md_filename,md_mimetype
181 from document_modele where md_id=$1";
182 $Res=$this->
db->exec_sql($dm_info, [$this->md_id]);
185 $this->d_lob=
$row[
'md_lob'];
186 $this->d_filename=
$row[
'md_filename'];
187 $this->d_mimetype=
$row[
'md_mimetype'];
188 $this->d_name=
$row[
'md_name'];
192 $filename=($p_filename ==
"")?
$row[
'md_filename']:$p_filename;
194 $exp=$this->
db->lo_export(
$row[
'md_lob'],
$dirname.DIRECTORY_SEPARATOR.$filename);
197 record_log(sprintf(
'DOCUMENT.GENERATE.D1 , export failed %s %s',
$dirname, $filename));
198 throw new Exception(sprintf(
_(
"Export a échoué pour %s"), $filename));
205 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
208 $zip=
new Zip_Extended;
209 if ($zip->open($filename)===TRUE)
211 $zip->extractTo(
$dirname.DIRECTORY_SEPARATOR);
216 record_log(sprintf(
'DOCUMENT.GENERATE.D2 unzip failed %s', $filename));
217 throw new Exception(sprintf(
_(
"Décompression a échoué %s", $filename)));
223 $file_to_parse=
"content.xml";
228 $file_to_parse=$filename;
231 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".
$row[
'md_type']);
238 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
241 $zip=
new Zip_Extended;
242 $res=$zip->open($filename, ZipArchive::CREATE);
245 record_log(sprintf(
'DOCUMENT.GENERATE.D3 zip failed %s', $filename));
246 throw new Exception(
_(
'Echec compression'),5000);
248 $zip->add_recurse_folder(
$dirname.DIRECTORY_SEPARATOR);
253 $file_to_parse=$filename;
261 $href=http_build_query(array(
'gDossier'=>Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
262 $ret=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.
_(
'Document').
'</A>';
265 }
catch (Exception
$e) {
267 return span(
_(
"Génération du document a échoué"),
'class="notice"');
294 $infile_name=$p_dir.DIRECTORY_SEPARATOR.$p_file;
295 $h=fopen($infile_name,
"r");
298 $temp_dir=$_ENV[
'TMP'];
299 if (is_dir($temp_dir)==
false)
301 if (mkdir($temp_dir)==
false)
303 $msg=sprintf(
"D221.".
_(
"Ne peut pas créer le répertoire %s"), $temp_dir);
305 throw new Exception(
$msg);
309 $output_name=tempnam($temp_dir,
"gen_doc_");
310 $output_file=fopen($output_name,
"w+");
314 $msg=sprintf(
"D232".
_(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $p_file);
316 throw new Exception(
$msg);
318 if ($output_file==
false)
320 $msg=sprintf(
"D264.".
_(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $output_name);
322 throw new Exception(
$msg);
327 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
333 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
344 while (preg_match_all($regex, $buffer,
$f)>0)
347 foreach (
$f as $apattern)
350 foreach ($apattern as $pattern)
362 if (strpos(
$value??
"",
'ERROR')!=
false)
374 fwrite($output_file, $buffer);
377 fclose($output_file);
378 if ((
$ret=copy($output_name, $infile_name))==FALSE)
380 $msg=
"D299 ".sprintf(
_(
'Ne peut pas sauver [%s] vers [%s] code erreur = [%s]'), $output_name, $infile_name,
383 throw new Exception(
$msg);
398 $this->d_lob=$this->
db->lo_import($p_file);
399 if ($this->d_lob==
false)
401 echo
"ne peut pas importer [$p_file]";
405 $sql=
"insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype)
406 values ($1,$2,$3,$4,$5)";
414 $this->d_id=$this->
db->get_current_seq(
"document_d_id_seq");
432 if (empty($aDocument)||is_array($aDocument)==
false)
434 throw new Exception(
"Document.download expects an array");
437 $dirname=tempnam($_ENV[
'TMP'],
'document_dwnall');
451 throw new Exception(
"Document.download.2 element is not a document object");
453 $filename=
$dirname.DIRECTORY_SEPARATOR.$aDocument[
$i]->d_filename;
455 if (file_exists($filename))
461 $filename=
$dirname.DIRECTORY_SEPARATOR.$nCopy.
"-".$aDocument[
$i]->d_filename;
462 if (!file_exists($filename))
470 $this->
db->lo_export($aDocument[
$i]->d_lob,$filename);
474 $name=
"document-".date (
"Ymd-His").
".zip";
475 if ( $zip->open($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name , ZipArchive::CREATE) !=
true)
477 die(
"Cannot create zip file");
479 $zip->add_recurse_folder(
$dirname .
"/");
482 ini_set(
'zlib.output_compression',
'off');
483 header(
"Pragma: public");
484 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
485 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
486 header(
"Cache-Control: must-revalidate");
487 header(
'Content-type: zip/application');
488 header(
'Content-Disposition: attachment;filename="'.
$name.
'"', FALSE);
489 header(
"Accept-Ranges: bytes");
490 $file=fopen($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name,
'r');
493 echo fread(
$file, 8192);
512 if (
sizeof($_FILES)==0)
519 $name=$_FILES[
'file_upload'][
'name'];
520 $document_saved=array();
522 $aDescription=
$http->post(
"input_desc",
"array",array());
528 if (strlen($_FILES[
'file_upload'][
'tmp_name'][
$i])!=0)
531 if (move_uploaded_file($_FILES[
'file_upload'][
'tmp_name'][
$i],
$new_name))
537 $this->
db->rollback();
543 $this->d_filename=$_FILES[
'file_upload'][
'name'][
$i];
544 $this->d_mimetype=$_FILES[
'file_upload'][
'type'][
$i];
545 if ( isset($aDescription[
$i])) {
550 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description)"
551 .
" values ($1,$2,$3,$4,$5,$6) returning d_id";
552 $document_id=$this->
db->get_value(
$sql,
553 array($p_ag_id, $this->d_lob, $this->d_filename, $this->d_mimetype, 1, $this->d_description));
556 $document_saved[]=$document_id;
561 return $document_saved;
577 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description) "
578 .
"values ($1,$2,$3,$4,$5,$6)";
579 $cn->exec_sql(
$sql, array($p_ag_id, $p_lob, $p_filename, $p_mimetype, 1, $p_description));
592 $image=
'<IMG SRC="image/insert_table.gif" title="'.$this->d_filename.
'" border="0">';
594 $href=http_build_query(array(
'gDossier'=>Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
596 $r=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.$image.
'</A>';
608 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
613 ini_set(
'zlib.output_compression',
'Off');
614 header(
"Pragma: public");
615 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
616 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
617 header(
"Cache-Control: must-revalidate");
618 header(
'Content-type: text');
619 header(
'Content-Disposition: attachment;filename="vide.txt"', FALSE);
620 header(
"Accept-Ranges: bytes");
626 $tmp=tempnam($_ENV[
'TMP'],
'document_');
628 $this->d_mimetype=
$row[
'd_mimetype'];
629 $this->d_filename=
$row[
'd_filename'];
632 ini_set(
'zlib.output_compression',
'Off');
633 header(
"Pragma: public");
634 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
635 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
636 header(
"Cache-Control: must-revalidate");
637 header(
'Content-type: '.$this->d_mimetype);
638 header(
'Content-Disposition: attachment;filename="'.$this->d_filename.
'"', FALSE);
639 header(
"Accept-Ranges: bytes");
642 echo fread(
$file, 8192);
658 $res=$this->
db->get_array(
'select d_id, ag_id, d_lob, d_number, d_filename,'.
659 ' d_mimetype,d_description from document where ag_id=$1', array(
$ag_id));
670 $doc->d_description=
$res[
$i][
'd_description'];
683 $sql=
"select * from document where d_id=$1";
691 $this->d_mimetype=
$row[
'd_mimetype'];
692 $this->d_filename=
$row[
'd_filename'];
693 $this->d_lob=
$row[
'd_lob'];
694 $this->d_number=
$row[
'd_number'];
695 $this->d_description=
$row[
'd_description'];
766 $p_tag=strtoupper($p_tag);
769 static $aComment=NULL;
770 static $counter_comment=1;
772 static $aRelatedAction=NULL;
773 static $counter_related_action=0;
775 static $aRelatedOperation=NULL;
776 static $counter_related_operation=0;
778 static $aFileAttached=NULL;
779 static $counter_file=0;
781 static $aOtherCard=NULL;
782 static $counter_other_card=0;
785 static $counter_tag=0;
787 static $aParameterExtra=NULL;
797 if (isset(
$p_array[
'ag_timestamp']))
861 $start_date=$this->
db->get_value(
"
862 select to_char(min(p_start),'YYYYMMDD') first_day
863 from parm_periode where p_exercice=$1"
866 $end_date =$this->
db->get_value(
"
867 select to_char(max(p_end),'YYYYMMDD') last_day
868 from parm_periode where p_exercice=$1"
870 $a=
$tiers->get_solde_detail(
" to_char(jrnx.j_date,'YYYYMMDD')>='{$start_date}' and to_char(jrnx.j_date,'YYYYMMDD') <= '{$end_date}' ");
871 $r = round(
$a[
'solde'],4);
874 $r = round(
$a[
'solde'],4);
930 case 'CUST_BANQUE_NO':
936 case 'CUST_BANQUE_NAME':
1032 case 'BENEF_BANQUE_NO':
1043 case 'BENEF_BANQUE_NAME':
1067 return $_SESSION[SESSION_KEY.
'use_name'].
', '.$_SESSION[SESSION_KEY.
'use_first_name'];
1090 case 'DATE_LIMIT_CALC':
1095 if (isset(
$p_array[
"ag_remind_date"]))
1104 if (isset(
$p_array[
"ag_remind_date"]))
1109 if ( isset (
$p_array[
'jr_date_paid']) ) {
return $p_array[
'jr_date_paid'];}
1116 case 'VEN_ART_NAME':
1118 if (!isset(
$p_array[
"e_march".$this->counter]))
1121 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1124 $f->get_by_qcode(
$p_array[
"e_march".$this->counter],
false);
1130 case 'VEN_ART_LABEL':
1131 $id=
'e_march'.$this->counter.
"_label";
1136 $id=
'e_march'.$this->counter;
1143 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1156 case 'VEN_ART_STOCK_CODE':
1157 $id=
'e_march'.$this->counter;
1164 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1174 $id=
'e_march'.$this->counter;
1179 case 'VEN_ART_PRICE':
1180 $id=
'e_march'.$this->counter.
'_price';
1189 case 'VEN_ART_TVA_RATE':
1190 $id=
'e_march'.$this->counter.
'_tva_id';
1195 $march_id=
'e_march'.$this->counter.
'_price';
1199 if ($tva->load()==-1)
1201 return $tva->get_parameter(
"rate");
1205 case 'VEN_ART_TVA_CODE':
1206 $id=
'e_march'.$this->counter.
'_tva_id';
1211 $qt=
'e_quant'.$this->counter;
1212 $price=
'e_march'.$this->counter.
'_price';
1220 $id=
'e_march'.$this->counter.
'_tva_id';
1223 $march_id=
'e_march'.$this->counter.
'_price';
1229 if ($tva->load()==-1)
1231 $r=$tva->get_parameter(
'label');
1238 $qt=
'e_quant'.$this->counter;
1239 $price=
'e_march'.$this->counter.
'_price';
1240 $tva=
'e_march'.$this->counter.
'_tva_id';
1244 if (!isset(
$p_array [
'e_march'.$this->counter]))
1251 $r=
$p_array[
'e_march'.$this->counter.
'_tva_amount'];
1256 $qt=
'e_quant'.$this->counter;
1257 $price=
'e_march'.$this->counter.
'_price';
1258 $tva=
'e_march'.$this->counter.
'_tva_id';
1259 if (!isset(
$p_array[
'e_march'.$this->counter]))
1267 if ($oTva->load()==-1)
1273 case 'VEN_ART_TVAC':
1274 $qt=
'e_quant'.$this->counter;
1275 $price=
'e_march'.$this->counter.
'_price';
1276 if (!isset(
$p_array[
'e_march'.$this->counter]))
1278 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1283 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1286 if ($tva->load()==-1)
1288 $r=noalyss_round($p_array[$price], 2);
1292 $r=noalyss_round($p_array[$price]*$tva->get_parameter(
'rate')+$p_array[$price], 2);
1297 case 'VEN_ART_QUANT':
1298 $id=
'e_quant'.$this->counter;
1308 $id=
'e_march'.$this->counter.
'_price';
1309 $quant=
'e_quant'.$this->counter;
1322 $id=
'e_march'.$this->counter.
'_tva_amount';
1323 $price=
'e_march'.$this->counter.
'_price';
1324 $quant=
'e_quant'.$this->counter;
1325 if (!isset(
$p_array[
'e_march'.$this->counter.
'_price'])||!isset(
$p_array[
'e_quant'.$this->counter]))
1330 if (
$p_array[
'e_march'.$this->counter.
'_price']==0||
$p_array[
'e_quant'.$this->counter]==0)
1347 case 'TOTAL_VEN_HTVA':
1354 $sell=
'e_march'.$i.
'_price';
1369 case 'TOTAL_VEN_TVAC':
1376 $tva=
'e_march'.$i.
'_tva_amount';
1384 $sell=
$p_array[
'e_march'.$i.
'_price'];
1401 $tva=
'e_march'.$i.
'_tva_amount';
1407 $tva_amount=($tva_amount==
"")?0:$tva_amount;
1415 case 'BON_COMMANDE':
1445 $ret=$this->
db->get_value(
'select r_name from public.stock_repository where r_id=$1',
1448 case 'STOCK_ADRESS':
1451 $ret=$this->
db->get_value(
'select r_adress from public.stock_repository where r_id=$1',
1454 case 'STOCK_COUNTRY':
1457 $ret=$this->
db->get_value(
'select r_country from public.stock_repository where r_id=$1',
1463 $ret=$this->
db->get_value(
'select r_city from public.stock_repository where r_id=$1',
1469 $ret=$this->
db->get_value(
'select r_phone from public.stock_repository where r_id=$1',
1485 .
" from action_gestion_comment "
1486 .
"where ag_id=$1 order by AGC_ID asc limit 1"
1502 if ($aComment==NULL)
1505 $aComment=$this->
db->get_array(
"select AGC_ID,agc_comment ,"
1506 .
" to_char(agc_date,'DD-MM-YY HH24:MI') as str_date ,"
1508 .
" from action_gestion_comment "
1509 .
"where ag_id=$1 order by 1"
1512 $nb_comment=count($aComment);
1514 if (count($aComment)>$counter_comment)
1516 $description.=sprintf(
_(
'le %s , %s écrit %s'), $aComment[$counter_comment][
'str_date'],
1517 $aComment[$counter_comment][
'tech_user'], $aComment[$counter_comment][
'agc_comment']);
1526 case 'RELATED_ACTION':
1530 if ($aRelatedAction==NULL)
1534 $aRelatedAction=array();
1535 $aParent=$followup->get_parent();
1538 $nb_parent=count($aParent);
1539 $sql_related_action=
"
1542 (select ad_value from fiche_detail fd1 where fd1.ad_id=23 and fd1.f_id=f_id_dest) as qcode,
1543 (select ad_value from fiche_detail fd1 where fd1.ad_id=1 and fd1.f_id=f_id_dest) as card_name,
1544 (select ad_value from fiche_detail fd1 where fd1.ad_id=32 and fd1.f_id=f_id_dest) as card_fname,
1546 to_char(ag_timestamp,'DD.MM.YYYY') as strdate,
1548 from action_gestion ag where ag_id=$1 ";
1550 for (
$x=0;
$x<$nb_parent;
$x++)
1552 $aRelatedAction[]=$this->
db->get_row($sql_related_action, [$aParent[
$x][
'aga_least']]);
1553 $aChild=$followup->get_children($aParent[
$x][
'aga_least']);
1554 $nb_child=count($aChild);
1555 for ($y=0; $y<$nb_child; $y++)
1557 $aRelatedAction[]=$this->
db->get_row($sql_related_action,
1558 [$aChild[$y][
'aga_greatest']]);
1563 if (count($aRelatedAction)>$counter_related_action)
1566 $aRelatedAction[$counter_related_action][
'ag_id'],
1567 $aRelatedAction[$counter_related_action][
'ag_ref'],
1568 $aRelatedAction[$counter_related_action][
'strdate'],
1569 $aRelatedAction[$counter_related_action][
'qcode'],
1570 $aRelatedAction[$counter_related_action][
'card_fname'],
1571 $aRelatedAction[$counter_related_action][
'card_name'],
1572 $aRelatedAction[$counter_related_action][
'ag_title']
1575 $counter_related_action++;
1584 case 'CONCERNED_OPERATION':
1588 if ($aRelatedOperation==NULL)
1591 $aRelatedOperation=$this->
db->get_array(
"select ago_id,
1596 to_char(j.jr_date,'DD.MM.YY') as str_date
1598 join action_gestion_operation as ago on (j.jr_id=ago.jr_id)
1599 where ag_id=$1 order by jr_date,jr_id"
1603 if (count($aRelatedOperation)>$counter_related_operation)
1606 $aRelatedOperation[$counter_related_operation][
'str_date'],
1607 $aRelatedOperation[$counter_related_operation][
'jr_internal'],
1608 $aRelatedOperation[$counter_related_operation][
'jr_comment'],
1609 $aRelatedOperation[$counter_related_operation][
'jr_pj_number']
1611 $counter_related_operation++;
1623 if ($aOtherCard==NULL)
1626 $aOtherCard=$this->
db->get_array(
"
1628 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 1) as cname,
1629 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 32) as cfname,
1630 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 23) as qcode,
1631 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 18 ) as email,
1632 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 27 ) as mobile,
1633 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 17 ) as phone
1634 from action_person ap
1640 if (count($aOtherCard)>$counter_other_card)
1642 $description.=sprintf(
'%s %s %s %s %s %s ', $aOtherCard[$counter_other_card][
'cname'],
1643 $aOtherCard[$counter_other_card][
'cfname'], $aOtherCard[$counter_other_card][
'qcode'],
1644 $aOtherCard[$counter_other_card][
'email'], $aOtherCard[$counter_other_card][
'phone'],
1645 $aOtherCard[$counter_other_card][
'mobile']);
1646 $counter_other_card++;
1654 case 'ATTACHED_FILES':
1658 if ($aFileAttached==NULL)
1661 $aFileAttached=$this->
db->get_array(
"
1662 select d_filename,d_description from document d where ag_id=$1
1666 $nb_comment=count($aFileAttached);
1668 if (count($aFileAttached)>$counter_file)
1670 $description.=sprintf(
"%s %s ", $aFileAttached[$counter_file][
'd_filename'],
1671 $aFileAttached [$counter_file][
'd_description']);
1687 select t_tag from action_tags at2 join tags t using(t_id) where ag_id=$1 order by upper(t_tag)
1692 if (count(
$aTag)>$counter_tag)
1702 case 'COMM_PAYMENT':
1703 if (isset(
$p_array[
"e_comm_paiement"]))
1705 return $p_array[
"e_comm_paiement"];
1714 if (isset(
$p_array[
'ag_priority']))
1716 $aPriority=array(1=>
_(
"Haute"), 2=>
_(
"Normale"), 3=>
_(
"Basse"));
1717 return $aPriority[
$p_array[
"ag_priority"]];
1724 $profile=$this->
db->get_value(
"select p_name from profile where p_id=$1", array(
$p_array[
'ag_dest']));
1740 select s_value from document_state where s_id=$1", array(
$p_array[
'ag_state']));
1745 case 'DOCUMENT_TYPE':
1749 $ret=$this->
db->get_value(
"select dt_value
1751 join document_type dt on (ag_type=dt.dt_id)
1752 where ag_id=$1", array(
$p_array[
"ag_id"]));
1754 if (
$p_array[
'gen_doc'] == -2)
return _(
"Facture standard");
1755 $ret = $this->
db->get_value(
"
1756 select md_name from public.document_modele where md_id=$1",
1761 return strip_tags(html_entity_decode(
$p_array[
'jrn_note_input']??
""));
1769 if (preg_match(
'/^ATTR/', $p_tag)==1)
1773 if (isset(
$p_array[
'e_march'.$this->counter]))
1783 if (preg_match(
'/^BENEFATTR/', $p_tag)==1)
1791 if (preg_match(
'/^CUSTATTR/', $p_tag)==1)
1803 $pe_value=$this->
db->get_value(
"select pe_value from parameter_extra where pe_code=$1",[$p_tag]);
1804 if ( $this->
db->count() > 0 ) { return $pe_value;}
1816 $d_lob=$this->
db->get_value(
'select d_lob from document where d_id=$1', array($this->d_id));
1817 $sql=
'delete from document where d_id='.$this->d_id;
1818 $this->
db->exec_sql(
$sql);
1834 if ($p_qcode==
"")
return "";
1837 $found=
$f->get_by_qcode($p_qcode,
false);
1839 if ($found==1)
return "";
1842 $attr=preg_replace(
"/^.*ATTR/",
"", $p_tag);
1846 $ad_type=$this->
db->get_value(
"select ad_type from attr_def where ad_id=$1", array(
$attr));
1849 $ad_value=$this->
db->get_value(
"select ad_value from fiche_detail where f_id=$1 and ad_id=$2",
1853 if ($ad_type==
"select")
1855 $sql=$this->
db->get_value(
"select ad_extra from attr_def where ad_id=$1", array(
$attr));
1859 if (
$array[
$a][
'value']==$ad_value)
1869 $this->
db->exec_sql(
'update document set d_description = $1 where d_id=$2', array($p_desc, $this->d_id));
1882 $p_value=$p_value??
'';
1883 $check=str_replace([
'<',
'>',
'<',
'>',
'='],
"",
$check);
1884 if (preg_replace(
'/[^[:alnum:]^_]/',
'',
$check)!=
$check)
1886 throw new Exception(sprintf(
_(
"chaine à remplacer [%s] contient un caractère interdit"), $p_pattern));
1889 if (is_numeric($p_value)&&
$p_type==
'OOo')
1892 $searched=
'/office:value-type="string"><text:p>'.$p_pattern.
'/i';
1893 $replaced=
'office:value-type="float" office:value="'.$p_value.
'"><text:p>'.$p_value;
1894 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1898 $searched=
'/office:value-type="string" calcext:value-type="string"><text:p>(<text:s\/>)*'.$p_pattern.
'/i';
1899 $replaced=
'office:value-type="float" office:value="'.$p_value.
'" calcext:value-type="float"><text:p>'.$p_value;
1900 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1914 $p_buffer=preg_replace(
'/'.$p_pattern.
'/i', $p_value, $p_buffer, $p_limit);
1926 if ($this->d_id==0) {
1930 $ret=$this->
db->exec_sql(
1931 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
1938 $tmp=$p_destination_file;
1939 if ( $this->
db->lo_export(
$row[
'd_lob'],
$tmp) ==
true) {
1940 $this->d_mimetype=
$row[
'd_mimetype'];
1941 $this->d_filename=
$row[
'd_filename'];
1942 $this->
db->commit();
1945 $this->
db->commit();
1961 $dirname=tempnam($_ENV[
'TMP'],
"document");
1964 throw new Exception(
"D1862.cannot create tmp file",5000);
1969 throw new Exception(
"D1868.cannot create tmp directory",5000);
1971 if ( $this->d_mimetype ==
"application/pdf") {
1974 return $dirname.
"/".$destination_file;
1977 if (GENERATE_PDF ==
'NO' ) {
1979 throw new \Exception(
"Cannot not transform to PDF",5000);
1985 passthru(OFFICE . escapeshellarg($destination_file),
$status);
1989 \record_log(__FILE__.
"D1879 Error cannot transform into PDF".
" output [$result]");
1990 throw new \Exception(
"D1879 Cannot not transform to PDF");
1993 $ext = strrpos($this->d_filename,
".");
1994 $pdf_file = substr($this->d_filename, 0,
$ext);
noalyss_round($p_first, $p_second)
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
noalyss_bcadd($p_first, $p_second, $p_decimal=4)
sanitize_filename($filename, $with_date=true)
removed invalid character when computing a filename, the suffix is kept
span($p_string, $p_extra='')
noalyss_strlentrim($p_string)
noalyss_str_replace($search, $replace, $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...
noalyss_bcmul($p_first, $p_second)
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
_("actif, passif,charge,...")
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
Class Document corresponds to the table DOCUMENT.
transform2pdf()
transform the current Document to a PDF, returns the full path of the PDF from the TMP folder if the ...
export_file($p_destination_file)
export the file to the file system and complet $this->d_mimetype, d_filename and
compute_filename($pj, $filename)
Insert the receipt number into the filename , each generated file will have the name of the template ...
replace_special_tag($p_qcode, $p_tag)
replace a special tag *TAGxxxx with the value from fiche_detail, the xxxx is the ad_value
upload($p_ag_id)
upload a file into document all the needed data are in $_FILES we don't increment the seq $_FILES : a...
get_all($ag_id)
get all the document of a given action
anchor()
create and compute a string for reference the doc <A ...>
download($aDocument)
Download all documents in a ZIP files.
static replace_value($p_buffer, $p_pattern, $p_value, $p_limit=-1, $p_type='OOo')
replace a pattern with a value in the buffer , handle the change for OOo type file and amount
parseDocument($p_dir, $p_file, $p_type, $p_array)
This function parse a document and replace all the predefined tags by a value.
saveGenerated($p_file)
insert the generated Document into the database, update the $this->d_id that is the PK of document....
blank()
insert a minimal document and set the d_id
__construct($p_cn, $p_d_id=0)
Constructor.
static insert_existing_document($p_ag_id, $p_lob, $p_filename, $p_mimetype, $p_description="")
Copy a existing OID (LOB) into the table document.
replace($p_tag, $p_array)
replace the TAG by the real value, this value can be into the database or in $_POST The possible tags...
update_description($p_desc)
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
class_action for manipulating actions action can be :
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
const ATTR_DEF_NUMBER_CUSTOMER
$user_exercice
Get exercice.
if( $delta< 0) elseif( $delta==0)