62 $this->d_id=$this->
db->get_next_seq(
"document_d_id_seq");
64 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".$this->md_type);
65 $sql=
'insert into document(d_id,ag_id,d_number) values($1,$2,$3)';
83 $pos_prefix=strrpos($filename,
".");
85 $pos_prefix=strlen($filename);
86 $filename_no=substr($filename, 0, $pos_prefix);
87 $filename_suff=substr($filename, $pos_prefix, strlen($filename));
89 foreach (array(
'/',
'*',
'<',
'>',
';',
',',
'\\',
'.',
':',
'(',
')',
' ',
'[',
']',
"'") as
$i)
96 $new_filename=strtolower($filename_no.
"-".$pj.$filename_suff);
101 return $new_filename;
117 $dirname=tempnam($_ENV[
'TMP'],
'doc_');
119 throw new Exception (
'DC117 cannot create tmp file',5000);
124 throw new Exception (
"DC121 cannot create $dirname directory",5000);
128 $dm_info=
"select md_name,md_type,md_lob,md_filename,md_mimetype
129 from document_modele where md_id=$1";
130 $Res=$this->
db->exec_sql($dm_info, [$this->md_id]);
133 $this->d_lob=
$row[
'md_lob'];
134 $this->d_filename=
$row[
'md_filename'];
135 $this->d_mimetype=
$row[
'md_mimetype'];
136 $this->d_name=
$row[
'md_name'];
140 $filename=
$row[
'md_filename'];
141 $exp=$this->
db->lo_export(
$row[
'md_lob'],
$dirname.DIRECTORY_SEPARATOR.$filename);
144 record_log(sprintf(
'DOCUMENT.GENERATE.D1 , export failed %s %s',
$dirname, $filename));
145 throw new Exception(sprintf(
_(
"Export a échoué pour %s"), $filename));
151 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
155 if ($zip->open($filename)===TRUE)
157 $zip->extractTo(
$dirname.DIRECTORY_SEPARATOR);
162 record_log(sprintf(
'DOCUMENT.GENERATE.D2 unzip failed %s', $filename));
163 throw new Exception(sprintf(
_(
"Décompression a échoué %s", $filename)));
169 $file_to_parse=
"content.xml";
174 $file_to_parse=$filename;
177 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".
$row[
'md_type']);
184 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
188 $res=$zip->open($filename, ZipArchive::CREATE);
191 record_log(sprintf(
'DOCUMENT.GENERATE.D3 zip failed %s', $filename));
192 throw new Exception(
_(
'Echec compression'),5000);
194 $zip->add_recurse_folder(
$dirname.DIRECTORY_SEPARATOR);
199 $file_to_parse=$filename;
207 $href=http_build_query(array(
'gDossier'=>Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
208 $ret=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.
_(
'Document').
'</A>';
211 }
catch (Exception
$e) {
214 return span(
_(
"Génération du document a échoué"),
'class="notice"');
241 $infile_name=$p_dir.DIRECTORY_SEPARATOR.$p_file;
242 $h=fopen($infile_name,
"r");
245 $temp_dir=$_ENV[
'TMP'];
246 if (is_dir($temp_dir)==
false)
248 if (mkdir($temp_dir)==
false)
250 $msg=sprintf(
"D221.".
_(
"Ne peut pas créer le répertoire %s", $temp_dir));
252 throw new Exception(
$msg);
256 $output_name=tempnam($temp_dir,
"gen_doc_");
257 $output_file=fopen($output_name,
"w+");
261 $msg=sprintf(
"D232".
_(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $p_file);
263 throw new Exception(
$msg);
265 if ($output_file==
false)
267 $msg=sprintf(
"D264.".
_(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $output_name);
269 throw new Exception(
$msg);
274 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
280 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
291 while (preg_match_all($regex, $buffer,
$f)>0)
294 foreach (
$f as $apattern)
297 foreach ($apattern as $pattern)
309 if (strpos(
$value??
"",
'ERROR')!=
false)
321 fwrite($output_file, $buffer);
324 fclose($output_file);
325 if ((
$ret=copy($output_name, $infile_name))==FALSE)
327 $msg=
"D299 ".sprintf(
_(
'Ne peut pas sauver [%s] vers [%s] code erreur = [%s]'), $output_name, $infile_name,
330 throw new Exception(
$msg);
347 $this->d_lob=$this->
db->lo_import($p_file);
348 if ($this->d_lob==
false)
350 echo
"ne peut pas importer [$p_file]";
354 $sql=
"insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype)
355 values ($1,$2,$3,$4,$5)";
363 $this->d_id=$this->
db->get_current_seq(
"document_d_id_seq");
381 if (empty($aDocument)||is_array($aDocument)==
false)
383 throw new Exception(
"Document.download expects an array");
386 $dirname=tempnam($_ENV[
'TMP'],
'document_dwnall');
400 throw new Exception(
"Document.download.2 element is not a document object");
402 $filename=
$dirname.DIRECTORY_SEPARATOR.$aDocument[
$i]->d_filename;
404 if (file_exists($filename))
410 $filename=
$dirname.DIRECTORY_SEPARATOR.$nCopy.
"-".$aDocument[
$i]->d_filename;
411 if (!file_exists($filename))
419 $this->
db->lo_export($aDocument[
$i]->d_lob,$filename);
423 $name=
"document-".date (
"Ymd-His").
".zip";
424 if ( $zip->open($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name , ZipArchive::CREATE) !=
true)
426 die(
"Cannot create zip file");
428 $zip->add_recurse_folder(
$dirname .
"/");
431 ini_set(
'zlib.output_compression',
'off');
432 header(
"Pragma: public");
433 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
434 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
435 header(
"Cache-Control: must-revalidate");
436 header(
'Content-type: zip/application');
437 header(
'Content-Disposition: attachment;filename="'.
$name.
'"', FALSE);
438 header(
"Accept-Ranges: bytes");
439 $file=fopen($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name,
'r');
442 echo fread(
$file, 8192);
461 if (
sizeof($_FILES)==0)
468 $name=$_FILES[
'file_upload'][
'name'];
469 $document_saved=array();
471 $aDescription=
$http->post(
"input_desc",
"array",array());
477 if (strlen($_FILES[
'file_upload'][
'tmp_name'][
$i])!=0)
480 if (move_uploaded_file($_FILES[
'file_upload'][
'tmp_name'][
$i],
$new_name))
486 $this->
db->rollback();
492 $this->d_filename=$_FILES[
'file_upload'][
'name'][
$i];
493 $this->d_mimetype=$_FILES[
'file_upload'][
'type'][
$i];
494 if ( isset($aDescription[
$i])) {
499 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description)"
500 .
" values ($1,$2,$3,$4,$5,$6) returning d_id";
501 $document_id=$this->
db->get_value(
$sql,
502 array($p_ag_id, $this->d_lob, $this->d_filename, $this->d_mimetype, 1, $this->d_description));
505 $document_saved[]=$document_id;
510 return $document_saved;
526 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description) "
527 .
"values ($1,$2,$3,$4,$5,$6)";
528 $cn->exec_sql(
$sql, array($p_ag_id, $p_lob, $p_filename, $p_mimetype, 1, $p_description));
541 $image=
'<IMG SRC="image/insert_table.gif" title="'.$this->d_filename.
'" border="0">';
543 $href=http_build_query(array(
'gDossier'=>Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
545 $r=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.$image.
'</A>';
557 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
562 ini_set(
'zlib.output_compression',
'Off');
563 header(
"Pragma: public");
564 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
565 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
566 header(
"Cache-Control: must-revalidate");
567 header(
'Content-type: text');
568 header(
'Content-Disposition: attachment;filename="vide.txt"', FALSE);
569 header(
"Accept-Ranges: bytes");
575 $tmp=tempnam($_ENV[
'TMP'],
'document_');
577 $this->d_mimetype=
$row[
'd_mimetype'];
578 $this->d_filename=
$row[
'd_filename'];
581 ini_set(
'zlib.output_compression',
'Off');
582 header(
"Pragma: public");
583 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
584 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
585 header(
"Cache-Control: must-revalidate");
586 header(
'Content-type: '.$this->d_mimetype);
587 header(
'Content-Disposition: attachment;filename="'.$this->d_filename.
'"', FALSE);
588 header(
"Accept-Ranges: bytes");
591 echo fread(
$file, 8192);
607 $res=$this->
db->get_array(
'select d_id, ag_id, d_lob, d_number, d_filename,'.
608 ' d_mimetype,d_description from document where ag_id=$1', array(
$ag_id));
619 $doc->d_description=
$res[
$i][
'd_description'];
632 $sql=
"select * from document where d_id=$1";
640 $this->d_mimetype=
$row[
'd_mimetype'];
641 $this->d_filename=
$row[
'd_filename'];
642 $this->d_lob=
$row[
'd_lob'];
643 $this->d_number=
$row[
'd_number'];
644 $this->d_description=
$row[
'd_description'];
715 $p_tag=strtoupper($p_tag);
718 static $aComment=NULL;
719 static $counter_comment=1;
721 static $aRelatedAction=NULL;
722 static $counter_related_action=0;
724 static $aRelatedOperation=NULL;
725 static $counter_related_operation=0;
727 static $aFileAttached=NULL;
728 static $counter_file=0;
730 static $aOtherCard=NULL;
731 static $counter_other_card=0;
734 static $counter_tag=0;
736 static $aParameterExtra=NULL;
746 if (isset(
$p_array[
'ag_timestamp']))
806 $start_date=$this->
db->get_value(
"
807 select to_char(min(p_start),'YYYYMMDD') first_day
808 from parm_periode where p_exercice=$1"
811 $end_date =$this->
db->get_value(
"
812 select to_char(max(p_end),'YYYYMMDD') last_day
813 from parm_periode where p_exercice=$1"
815 $a=
$tiers->get_solde_detail(
" to_char(jrnx.j_date,'YYYYMMDD')>='{$start_date}' and to_char(jrnx.j_date,'YYYYMMDD') <= '{$end_date}' ");
816 $r = round(
$a[
'solde'],4);
819 $r = round(
$a[
'solde'],4);
875 case 'CUST_BANQUE_NO':
881 case 'CUST_BANQUE_NAME':
977 case 'BENEF_BANQUE_NO':
988 case 'BENEF_BANQUE_NAME':
1012 return $_SESSION[SESSION_KEY.
'use_name'].
', '.$_SESSION[SESSION_KEY.
'use_first_name'];
1035 case 'DATE_LIMIT_CALC':
1040 if (isset(
$p_array[
"ag_remind_date"]))
1049 if (isset(
$p_array[
"ag_remind_date"]))
1054 if ( isset (
$p_array[
'jr_date_paid']) ) {
return $p_array[
'jr_date_paid'];}
1061 case 'VEN_ART_NAME':
1063 if (!isset(
$p_array[
"e_march".$this->counter]))
1066 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1069 $f->get_by_qcode(
$p_array[
"e_march".$this->counter],
false);
1075 case 'VEN_ART_LABEL':
1076 $id=
'e_march'.$this->counter.
"_label";
1081 $id=
'e_march'.$this->counter;
1088 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1101 case 'VEN_ART_STOCK_CODE':
1102 $id=
'e_march'.$this->counter;
1109 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1119 $id=
'e_march'.$this->counter;
1124 case 'VEN_ART_PRICE':
1125 $id=
'e_march'.$this->counter.
'_price';
1134 case 'VEN_ART_TVA_RATE':
1135 $id=
'e_march'.$this->counter.
'_tva_id';
1140 $march_id=
'e_march'.$this->counter.
'_price';
1144 if ($tva->load()==-1)
1146 return $tva->get_parameter(
"rate");
1150 case 'VEN_ART_TVA_CODE':
1151 $id=
'e_march'.$this->counter.
'_tva_id';
1156 $qt=
'e_quant'.$this->counter;
1157 $price=
'e_march'.$this->counter.
'_price';
1165 $id=
'e_march'.$this->counter.
'_tva_id';
1168 $march_id=
'e_march'.$this->counter.
'_price';
1174 if ($tva->load()==-1)
1176 $r=$tva->get_parameter(
'label');
1183 $qt=
'e_quant'.$this->counter;
1184 $price=
'e_march'.$this->counter.
'_price';
1185 $tva=
'e_march'.$this->counter.
'_tva_id';
1189 if (!isset(
$p_array [
'e_march'.$this->counter]))
1196 $r=
$p_array[
'e_march'.$this->counter.
'_tva_amount'];
1201 $qt=
'e_quant'.$this->counter;
1202 $price=
'e_march'.$this->counter.
'_price';
1203 $tva=
'e_march'.$this->counter.
'_tva_id';
1204 if (!isset(
$p_array[
'e_march'.$this->counter]))
1212 if ($oTva->load()==-1)
1218 case 'VEN_ART_TVAC':
1219 $qt=
'e_quant'.$this->counter;
1220 $price=
'e_march'.$this->counter.
'_price';
1221 if (!isset(
$p_array[
'e_march'.$this->counter]))
1223 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1228 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1231 if ($tva->load()==-1)
1233 $r=noalyss_round($p_array[$price], 2);
1237 $r=noalyss_round($p_array[$price]*$tva->get_parameter(
'rate')+$p_array[$price], 2);
1242 case 'VEN_ART_QUANT':
1243 $id=
'e_quant'.$this->counter;
1253 $id=
'e_march'.$this->counter.
'_price';
1254 $quant=
'e_quant'.$this->counter;
1267 $id=
'e_march'.$this->counter.
'_tva_amount';
1268 $price=
'e_march'.$this->counter.
'_price';
1269 $quant=
'e_quant'.$this->counter;
1270 if (!isset(
$p_array[
'e_march'.$this->counter.
'_price'])||!isset(
$p_array[
'e_quant'.$this->counter]))
1275 if (
$p_array[
'e_march'.$this->counter.
'_price']==0||
$p_array[
'e_quant'.$this->counter]==0)
1292 case 'TOTAL_VEN_HTVA':
1299 $sell=
'e_march'.$i.
'_price';
1314 case 'TOTAL_VEN_TVAC':
1321 $tva=
'e_march'.$i.
'_tva_amount';
1329 $sell=
$p_array[
'e_march'.$i.
'_price'];
1346 $tva=
'e_march'.$i.
'_tva_amount';
1352 $tva_amount=($tva_amount==
"")?0:$tva_amount;
1360 case 'BON_COMMANDE':
1390 $ret=$this->
db->get_value(
'select r_name from public.stock_repository where r_id=$1',
1393 case 'STOCK_ADRESS':
1396 $ret=$this->
db->get_value(
'select r_adress from public.stock_repository where r_id=$1',
1399 case 'STOCK_COUNTRY':
1402 $ret=$this->
db->get_value(
'select r_country from public.stock_repository where r_id=$1',
1408 $ret=$this->
db->get_value(
'select r_city from public.stock_repository where r_id=$1',
1414 $ret=$this->
db->get_value(
'select r_phone from public.stock_repository where r_id=$1',
1430 .
" from action_gestion_comment "
1431 .
"where ag_id=$1 order by AGC_ID asc limit 1"
1447 if ($aComment==NULL)
1450 $aComment=$this->
db->get_array(
"select AGC_ID,agc_comment ,"
1451 .
" to_char(agc_date,'DD-MM-YY HH24:MI') as str_date ,"
1453 .
" from action_gestion_comment "
1454 .
"where ag_id=$1 order by 1"
1457 $nb_comment=count($aComment);
1459 if (count($aComment)>$counter_comment)
1461 $description.=sprintf(
_(
'le %s , %s écrit %s'), $aComment[$counter_comment][
'str_date'],
1462 $aComment[$counter_comment][
'tech_user'], $aComment[$counter_comment][
'agc_comment']);
1471 case 'RELATED_ACTION':
1475 if ($aRelatedAction==NULL)
1479 $aRelatedAction=array();
1480 $aParent=$followup->get_parent();
1483 $nb_parent=count($aParent);
1484 $sql_related_action=
"
1487 (select ad_value from fiche_detail fd1 where fd1.ad_id=23 and fd1.f_id=f_id_dest) as qcode,
1488 (select ad_value from fiche_detail fd1 where fd1.ad_id=1 and fd1.f_id=f_id_dest) as card_name,
1489 (select ad_value from fiche_detail fd1 where fd1.ad_id=32 and fd1.f_id=f_id_dest) as card_fname,
1491 to_char(ag_timestamp,'DD.MM.YYYY') as strdate,
1493 from action_gestion ag where ag_id=$1 ";
1495 for ($x=0; $x<$nb_parent; $x++)
1497 $aRelatedAction[]=$this->
db->get_row($sql_related_action, [$aParent[$x][
'aga_least']]);
1498 $aChild=$followup->get_children($aParent[$x][
'aga_least']);
1499 $nb_child=count($aChild);
1500 for ($y=0; $y<$nb_child; $y++)
1502 $aRelatedAction[]=$this->
db->get_row($sql_related_action,
1503 [$aChild[$y][
'aga_greatest']]);
1508 if (count($aRelatedAction)>$counter_related_action)
1511 $aRelatedAction[$counter_related_action][
'ag_id'],
1512 $aRelatedAction[$counter_related_action][
'ag_ref'],
1513 $aRelatedAction[$counter_related_action][
'strdate'],
1514 $aRelatedAction[$counter_related_action][
'qcode'],
1515 $aRelatedAction[$counter_related_action][
'card_fname'],
1516 $aRelatedAction[$counter_related_action][
'card_name'],
1517 $aRelatedAction[$counter_related_action][
'ag_title']
1520 $counter_related_action++;
1529 case 'CONCERNED_OPERATION':
1533 if ($aRelatedOperation==NULL)
1536 $aRelatedOperation=$this->
db->get_array(
"select ago_id,
1541 to_char(j.jr_date,'DD.MM.YY') as str_date
1543 join action_gestion_operation as ago on (j.jr_id=ago.jr_id)
1544 where ag_id=$1 order by jr_date,jr_id"
1548 if (count($aRelatedOperation)>$counter_related_operation)
1551 $aRelatedOperation[$counter_related_operation][
'str_date'],
1552 $aRelatedOperation[$counter_related_operation][
'jr_internal'],
1553 $aRelatedOperation[$counter_related_operation][
'jr_comment'],
1554 $aRelatedOperation[$counter_related_operation][
'jr_pj_number']
1556 $counter_related_operation++;
1568 if ($aOtherCard==NULL)
1571 $aOtherCard=$this->
db->get_array(
"
1573 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 1) as cname,
1574 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 32) as cfname,
1575 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 23) as qcode,
1576 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 18 ) as email,
1577 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 27 ) as mobile,
1578 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 17 ) as phone
1579 from action_person ap
1585 if (count($aOtherCard)>$counter_other_card)
1587 $description.=sprintf(
'%s %s %s %s %s %s ', $aOtherCard[$counter_other_card][
'cname'],
1588 $aOtherCard[$counter_other_card][
'cfname'], $aOtherCard[$counter_other_card][
'qcode'],
1589 $aOtherCard[$counter_other_card][
'email'], $aOtherCard[$counter_other_card][
'phone'],
1590 $aOtherCard[$counter_other_card][
'mobile']);
1591 $counter_other_card++;
1599 case 'ATTACHED_FILES':
1603 if ($aFileAttached==NULL)
1606 $aFileAttached=$this->
db->get_array(
"
1607 select d_filename,d_description from document d where ag_id=$1
1611 $nb_comment=count($aFileAttached);
1613 if (count($aFileAttached)>$counter_file)
1615 $description.=sprintf(
"%s %s ", $aFileAttached[$counter_file][
'd_filename'],
1616 $aFileAttached [$counter_file][
'd_description']);
1632 select t_tag from action_tags at2 join tags t using(t_id) where ag_id=$1 order by upper(t_tag)
1637 if (count(
$aTag)>$counter_tag)
1647 case 'COMM_PAYMENT':
1648 if (isset(
$p_array[
"e_comm_paiement"]))
1650 return $p_array[
"e_comm_paiement"];
1659 if (isset(
$p_array[
'ag_priority']))
1661 $aPriority=array(1=>
_(
"Haute"), 2=>
_(
"Normale"), 3=>
_(
"Basse"));
1662 return $aPriority[
$p_array[
"ag_priority"]];
1669 $profile=$this->
db->get_value(
"select p_name from profile where p_id=$1", array(
$p_array[
'ag_dest']));
1685 select s_value from document_state where s_id=$1", array(
$p_array[
'ag_state']));
1690 case 'DOCUMENT_TYPE':
1694 $ret=$this->
db->get_value(
"select dt_value
1696 join document_type dt on (ag_type=dt.dt_id)
1697 where ag_id=$1", array(
$p_array[
"ag_id"]));
1699 $ret = $this->
db->get_value(
"
1700 select md_name from public.document_modele where md_id=$1",
1705 return $p_array[
'jrn_note_input']??
"";
1713 if (preg_match(
'/^ATTR/', $p_tag)==1)
1717 if (isset(
$p_array[
'e_march'.$this->counter]))
1727 if (preg_match(
'/^BENEFATTR/', $p_tag)==1)
1735 if (preg_match(
'/^CUSTATTR/', $p_tag)==1)
1747 $pe_value=$this->
db->get_value(
"select pe_value from parameter_extra where pe_code=$1",[$p_tag]);
1748 if ( $this->
db->count() > 0 ) { return $pe_value;}
1760 $d_lob=$this->
db->get_value(
'select d_lob from document where d_id=$1', array($this->d_id));
1761 $sql=
'delete from document where d_id='.$this->d_id;
1762 $this->
db->exec_sql(
$sql);
1777 $sql=
"update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3 where jr_internal=$4";
1779 $this->
db->exec_sql(
$sql, array($this->d_lob, $this->d_filename, $this->d_mimetype, $p_internal));
1781 $sql=
'delete from document where d_id='.$this->d_id;
1782 $this->
db->exec_sql(
$sql);
1796 if ($p_qcode==
"")
return "";
1799 $found=
$f->get_by_qcode($p_qcode,
false);
1801 if ($found==1)
return "";
1804 $attr=preg_replace(
"/^.*ATTR/",
"", $p_tag);
1808 $ad_type=$this->
db->get_value(
"select ad_type from attr_def where ad_id=$1", array(
$attr));
1811 $ad_value=$this->
db->get_value(
"select ad_value from fiche_detail where f_id=$1 and ad_id=$2",
1815 if ($ad_type==
"select")
1817 $sql=$this->
db->get_value(
"select ad_extra from attr_def where ad_id=$1", array(
$attr));
1821 if (
$array[
$a][
'value']==$ad_value)
1831 $this->
db->exec_sql(
'update document set d_description = $1 where d_id=$2', array($p_desc, $this->d_id));
1844 $p_value=$p_value??
'';
1845 $check=str_replace([
'<',
'>',
'<',
'>',
'='],
"",
$check);
1846 if (preg_replace(
'/[^[:alnum:]^_]/',
'',
$check)!=
$check)
1848 throw new Exception(sprintf(
_(
"chaine à remplacer [%s] contient un caractère interdit"), $p_pattern));
1851 if (is_numeric($p_value)&&
$p_type==
'OOo')
1854 $searched=
'/office:value-type="string"><text:p>'.$p_pattern.
'/i';
1855 $replaced=
'office:value-type="float" office:value="'.$p_value.
'"><text:p>'.$p_value;
1856 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1860 $searched=
'/office:value-type="string" calcext:value-type="string"><text:p>(<text:s\/>)*'.$p_pattern.
'/i';
1861 $replaced=
'office:value-type="float" office:value="'.$p_value.
'" calcext:value-type="float"><text:p>'.$p_value;
1862 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1876 $p_buffer=preg_replace(
'/'.$p_pattern.
'/i', $p_value, $p_buffer, $p_limit);
1888 if ($this->d_id==0) {
1892 $ret=$this->
db->exec_sql(
1893 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
1900 $tmp=$p_destination_file;
1901 if ( $this->
db->lo_export(
$row[
'd_lob'],
$tmp) ==
true) {
1902 $this->d_mimetype=
$row[
'd_mimetype'];
1903 $this->d_filename=
$row[
'd_filename'];
1904 $this->
db->commit();
1907 $this->
db->commit();
1919 if (GENERATE_PDF ==
'NO' ) {
1921 throw new \Exception(
"Cannot not transform to PDF",5000);
1924 $dirname=tempnam($_ENV[
'TMP'],
"document");
1927 throw new Exception(
"D1862.cannot create tmp file",5000);
1932 throw new Exception(
"D1868.cannot create tmp directory",5000);
1938 passthru(OFFICE . escapeshellarg($destination_file),
$status);
1942 \record_log(__FILE__.
"D1879 Error cannot transform into PDF".
" output [$result]");
1943 throw new \Exception(
"D1879 Cannot not transform to PDF");
1946 $ext = strrpos($this->d_filename,
".");
1947 $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)
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.
generate($p_array, $p_filename="")
Generate the document, Call $this->replace to replace tag by value.
transform2pdf()
transform the current Document to a PDF, returns the full path of the PDF from the TMP folder
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.
moveDocumentPj($p_internal)
Move a document from the table document into the concerned row the document is not copied : it is onl...
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)
Save the generated 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)