61 $this->d_id=$this->
db->get_next_seq(
"document_d_id_seq");
63 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".$this->md_type);
64 $sql=
'insert into document(d_id,ag_id,d_number) values($1,$2,$3)';
82 $pos_prefix=strrpos($filename,
".");
84 $pos_prefix=strlen($filename);
85 $filename_no=substr($filename, 0, $pos_prefix);
86 $filename_suff=substr($filename, $pos_prefix, strlen($filename));
88 foreach (array(
'/',
'*',
'<',
'>',
';',
',',
'\\',
'.',
':',
'(',
')',
' ',
'[',
']',
"'") as
$i)
95 $new_filename=strtolower($filename_no.
"-".$pj.$filename_suff);
100 return $new_filename;
116 $dirname=tempnam($_ENV[
'TMP'],
'doc_');
118 throw new Exception (
'DC117 cannot create tmp file',5000);
123 throw new Exception (
"DC121 cannot create $dirname directory",5000);
127 $dm_info=
"select md_name,md_type,md_lob,md_filename,md_mimetype
128 from document_modele where md_id=$1";
129 $Res=$this->
db->exec_sql($dm_info, [$this->md_id]);
132 $this->d_lob=
$row[
'md_lob'];
133 $this->d_filename=
$row[
'md_filename'];
134 $this->d_mimetype=
$row[
'md_mimetype'];
135 $this->d_name=
$row[
'md_name'];
139 $filename=
$row[
'md_filename'];
140 $exp=$this->
db->lo_export(
$row[
'md_lob'],
$dirname.DIRECTORY_SEPARATOR.$filename);
143 record_log(sprintf(
'DOCUMENT.GENERATE.D1 , export failed %s %s',
$dirname, $filename));
144 throw new Exception(sprintf(_(
"Export a échoué pour %s"), $filename));
150 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
154 if ($zip->open($filename)===TRUE)
156 $zip->extractTo(
$dirname.DIRECTORY_SEPARATOR);
161 record_log(sprintf(
'DOCUMENT.GENERATE.D2 unzip failed %s', $filename));
162 throw new Exception(sprintf(_(
"Décompression a échoué %s", $filename)));
168 $file_to_parse=
"content.xml";
173 $file_to_parse=$filename;
176 $this->d_number=$this->
db->get_next_seq(
"seq_doc_type_".
$row[
'md_type']);
183 if (strpos(
$row[
'md_mimetype'],
'vnd.oasis')!=0)
187 $res=$zip->open($filename, ZipArchive::CREATE);
190 record_log(sprintf(
'DOCUMENT.GENERATE.D3 zip failed %s', $filename));
191 throw new Exception(_(
'Echec compression'),5000);
193 $zip->add_recurse_folder(
$dirname.DIRECTORY_SEPARATOR);
198 $file_to_parse=$filename;
206 $href=http_build_query(array(
'gDossier'=>
Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
207 $ret=
'<A class="mtitle" HREF="export.php?'.$href.
'">'._(
'Document').
'</A>';
210 }
catch (Exception
$e) {
213 return span(_(
"Génération du document a échoué"),
'class="notice"');
240 $infile_name=$p_dir.DIRECTORY_SEPARATOR.$p_file;
241 $h=fopen($infile_name,
"r");
244 $temp_dir=$_ENV[
'TMP'];
245 if (is_dir($temp_dir)==
false)
247 if (mkdir($temp_dir)==
false)
249 $msg=sprintf(
"D221."._(
"Ne peut pas créer le répertoire %s", $temp_dir));
251 throw new Exception(
$msg);
255 $output_name=tempnam($temp_dir,
"gen_doc_");
256 $output_file=fopen($output_name,
"w+");
260 $msg=sprintf(
"D232"._(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $p_file);
262 throw new Exception(
$msg);
264 if ($output_file==
false)
266 $msg=sprintf(
"D264."._(
"Ne peut pas ouvrir [%s] [%s]"), $p_dir, $output_name);
268 throw new Exception(
$msg);
273 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
279 $regex=
"/=*<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>/i";
290 while (preg_match_all($regex, $buffer,
$f)>0)
293 foreach (
$f as $apattern)
296 foreach ($apattern as $pattern)
308 if (strpos(
$value??
"",
'ERROR')!=
false)
320 fwrite($output_file, $buffer);
323 fclose($output_file);
324 if ((
$ret=copy($output_name, $infile_name))==FALSE)
326 $msg=
"D299 ".sprintf(_(
'Ne peut pas sauver [%s] vers [%s] code erreur = [%s]'), $output_name, $infile_name,
329 throw new Exception(
$msg);
346 $this->d_lob=$this->
db->lo_import($p_file);
347 if ($this->d_lob==
false)
349 echo
"ne peut pas importer [$p_file]";
353 $sql=
"insert into document(ag_id,d_lob,d_number,d_filename,d_mimetype)
354 values ($1,$2,$3,$4,$5)";
362 $this->d_id=$this->
db->get_current_seq(
"document_d_id_seq");
380 if (empty($aDocument)||is_array($aDocument)==
false)
382 throw new Exception(
"Document.download expects an array");
385 $dirname=tempnam($_ENV[
'TMP'],
'document_dwnall');
399 throw new Exception(
"Document.download.2 element is not a document object");
401 $filename=
$dirname.DIRECTORY_SEPARATOR.$aDocument[
$i]->d_filename;
403 if (file_exists($filename))
409 $filename=
$dirname.DIRECTORY_SEPARATOR.$nCopy.
"-".$aDocument[
$i]->d_filename;
410 if (!file_exists($filename))
418 $this->
db->lo_export($aDocument[
$i]->d_lob,$filename);
422 $name=
"document-".date (
"Ymd-His").
".zip";
423 if ( $zip->open($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name , ZipArchive::CREATE) !=
true)
425 die(
"Cannot create zip file");
427 $zip->add_recurse_folder(
$dirname .
"/");
430 ini_set(
'zlib.output_compression',
'off');
431 header(
"Pragma: public");
432 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
433 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
434 header(
"Cache-Control: must-revalidate");
435 header(
'Content-type: zip/application');
436 header(
'Content-Disposition: attachment;filename="'.
$name.
'"', FALSE);
437 header(
"Accept-Ranges: bytes");
438 $file=fopen($_ENV[
'TMP'].DIRECTORY_SEPARATOR.$name,
'r');
441 echo fread(
$file, 8192);
460 if (
sizeof($_FILES)==0)
467 $name=$_FILES[
'file_upload'][
'name'];
468 $document_saved=array();
470 $aDescription=
$http->post(
"input_desc",
"array",array());
476 if (strlen($_FILES[
'file_upload'][
'tmp_name'][
$i])!=0)
479 if (move_uploaded_file($_FILES[
'file_upload'][
'tmp_name'][
$i],
$new_name))
485 $this->
db->rollback();
491 $this->d_filename=$_FILES[
'file_upload'][
'name'][
$i];
492 $this->d_mimetype=$_FILES[
'file_upload'][
'type'][
$i];
493 if ( isset($aDescription[
$i])) {
498 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description)"
499 .
" values ($1,$2,$3,$4,$5,$6) returning d_id";
500 $document_id=$this->
db->get_value(
$sql,
501 array($p_ag_id, $this->d_lob, $this->d_filename, $this->d_mimetype, 1, $this->d_description));
504 $document_saved[]=$document_id;
509 return $document_saved;
525 $sql=
"insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description) "
526 .
"values ($1,$2,$3,$4,$5,$6)";
527 $cn->exec_sql(
$sql, array($p_ag_id, $p_lob, $p_filename, $p_mimetype, 1, $p_description));
540 $image=
'<IMG SRC="image/insert_table.gif" title="'.$this->d_filename.
'" border="0">';
542 $href=http_build_query(array(
'gDossier'=>
Dossier::id(),
"d_id"=>$this->d_id,
'act'=>
'RAW:document'));
544 $r=
'<A class="mtitle" HREF="export.php?'.$href.
'">'.$image.
'</A>';
556 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
561 ini_set(
'zlib.output_compression',
'Off');
562 header(
"Pragma: public");
563 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
564 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
565 header(
"Cache-Control: must-revalidate");
566 header(
'Content-type: text');
567 header(
'Content-Disposition: attachment;filename="vide.txt"', FALSE);
568 header(
"Accept-Ranges: bytes");
574 $tmp=tempnam($_ENV[
'TMP'],
'document_');
576 $this->d_mimetype=
$row[
'd_mimetype'];
577 $this->d_filename=
$row[
'd_filename'];
580 ini_set(
'zlib.output_compression',
'Off');
581 header(
"Pragma: public");
582 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
583 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
584 header(
"Cache-Control: must-revalidate");
585 header(
'Content-type: '.$this->d_mimetype);
586 header(
'Content-Disposition: attachment;filename="'.$this->d_filename.
'"', FALSE);
587 header(
"Accept-Ranges: bytes");
590 echo fread(
$file, 8192);
606 $res=$this->
db->get_array(
'select d_id, ag_id, d_lob, d_number, d_filename,'.
607 ' d_mimetype,d_description from document where ag_id=$1', array(
$ag_id));
618 $doc->d_description=
$res[
$i][
'd_description'];
631 $sql=
"select * from document where d_id=$1";
639 $this->d_mimetype=
$row[
'd_mimetype'];
640 $this->d_filename=
$row[
'd_filename'];
641 $this->d_lob=
$row[
'd_lob'];
642 $this->d_number=
$row[
'd_number'];
643 $this->d_description=
$row[
'd_description'];
714 $p_tag=strtoupper($p_tag);
717 static $aComment=NULL;
718 static $counter_comment=1;
720 static $aRelatedAction=NULL;
721 static $counter_related_action=0;
723 static $aRelatedOperation=NULL;
724 static $counter_related_operation=0;
726 static $aFileAttached=NULL;
727 static $counter_file=0;
729 static $aOtherCard=NULL;
730 static $counter_other_card=0;
733 static $counter_tag=0;
735 static $aParameterExtra=NULL;
745 if (isset(
$p_array[
'ag_timestamp']))
856 case 'CUST_BANQUE_NO':
862 case 'CUST_BANQUE_NAME':
958 case 'BENEF_BANQUE_NO':
969 case 'BENEF_BANQUE_NAME':
993 return $_SESSION[SESSION_KEY.
'use_name'].
', '.$_SESSION[SESSION_KEY.
'use_first_name'];
1016 case 'DATE_LIMIT_CALC':
1021 if (isset(
$p_array[
"ag_remind_date"]))
1030 if (isset(
$p_array[
"ag_remind_date"]))
1035 if ( isset (
$p_array[
'jr_date_paid']) ) {
return $p_array[
'jr_date_paid'];}
1042 case 'VEN_ART_NAME':
1044 if (!isset(
$p_array[
"e_march".$this->counter]))
1047 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1050 $f->get_by_qcode(
$p_array[
"e_march".$this->counter],
false);
1056 case 'VEN_ART_LABEL':
1057 $id=
'e_march'.$this->counter.
"_label";
1062 $id=
'e_march'.$this->counter;
1069 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1082 case 'VEN_ART_STOCK_CODE':
1083 $id=
'e_march'.$this->counter;
1090 if (
$p_array[
'e_march'.$this->counter.
'_price']!=0&&
$p_array[
'e_quant'.$this->counter]!=0)
1100 $id=
'e_march'.$this->counter;
1105 case 'VEN_ART_PRICE':
1106 $id=
'e_march'.$this->counter.
'_price';
1115 case 'VEN_ART_TVA_RATE':
1116 $id=
'e_march'.$this->counter.
'_tva_id';
1121 $march_id=
'e_march'.$this->counter.
'_price';
1126 if ($tva->load()==-1)
1128 return $tva->get_parameter(
"rate");
1132 case 'VEN_ART_TVA_CODE':
1133 $id=
'e_march'.$this->counter.
'_tva_id';
1138 $qt=
'e_quant'.$this->counter;
1139 $price=
'e_march'.$this->counter.
'_price';
1147 $id=
'e_march'.$this->counter.
'_tva_id';
1150 $march_id=
'e_march'.$this->counter.
'_price';
1156 if ($tva->load()==-1)
1158 $r=$tva->get_parameter(
'label');
1165 $qt=
'e_quant'.$this->counter;
1166 $price=
'e_march'.$this->counter.
'_price';
1167 $tva=
'e_march'.$this->counter.
'_tva_id';
1171 if (!isset(
$p_array [
'e_march'.$this->counter]))
1178 $r=
$p_array[
'e_march'.$this->counter.
'_tva_amount'];
1183 $qt=
'e_quant'.$this->counter;
1184 $price=
'e_march'.$this->counter.
'_price';
1185 $tva=
'e_march'.$this->counter.
'_tva_id';
1186 if (!isset(
$p_array[
'e_march'.$this->counter]))
1194 if ($oTva->load()==-1)
1200 case 'VEN_ART_TVAC':
1201 $qt=
'e_quant'.$this->counter;
1202 $price=
'e_march'.$this->counter.
'_price';
1203 if (!isset(
$p_array[
'e_march'.$this->counter]))
1205 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1210 if (!isset(
$p_array[
'e_march'.$this->counter.
'_tva_id']))
1213 if ($tva->load()==-1)
1224 case 'VEN_ART_QUANT':
1225 $id=
'e_quant'.$this->counter;
1235 $id=
'e_march'.$this->counter.
'_price';
1236 $quant=
'e_quant'.$this->counter;
1249 $id=
'e_march'.$this->counter.
'_tva_amount';
1250 $price=
'e_march'.$this->counter.
'_price';
1251 $quant=
'e_quant'.$this->counter;
1252 if (!isset(
$p_array[
'e_march'.$this->counter.
'_price'])||!isset(
$p_array[
'e_quant'.$this->counter]))
1257 if (
$p_array[
'e_march'.$this->counter.
'_price']==0||
$p_array[
'e_quant'.$this->counter]==0)
1274 case 'TOTAL_VEN_HTVA':
1281 $sell=
'e_march'.$i.
'_price';
1296 case 'TOTAL_VEN_TVAC':
1303 $tva=
'e_march'.$i.
'_tva_amount';
1311 $sell=
$p_array[
'e_march'.$i.
'_price'];
1328 $tva=
'e_march'.$i.
'_tva_amount';
1334 $tva_amount=($tva_amount==
"")?0:$tva_amount;
1342 case 'BON_COMMANDE':
1372 $ret=$this->
db->get_value(
'select r_name from public.stock_repository where r_id=$1',
1375 case 'STOCK_ADRESS':
1378 $ret=$this->
db->get_value(
'select r_adress from public.stock_repository where r_id=$1',
1381 case 'STOCK_COUNTRY':
1384 $ret=$this->
db->get_value(
'select r_country from public.stock_repository where r_id=$1',
1390 $ret=$this->
db->get_value(
'select r_city from public.stock_repository where r_id=$1',
1396 $ret=$this->
db->get_value(
'select r_phone from public.stock_repository where r_id=$1',
1412 .
" from action_gestion_comment "
1413 .
"where ag_id=$1 order by AGC_ID asc limit 1"
1414 , [$p_array[
'ag_id']]);
1429 if ($aComment==NULL)
1432 $aComment=$this->
db->get_array(
"select AGC_ID,agc_comment ,"
1433 .
" to_char(agc_date,'DD-MM-YY HH24:MI') as str_date ,"
1435 .
" from action_gestion_comment "
1436 .
"where ag_id=$1 order by 1"
1437 , [$p_array[
'ag_id']]);
1439 $nb_comment=count($aComment);
1441 if (count($aComment)>$counter_comment)
1443 $description.=sprintf(_(
'le %s , %s écrit %s'), $aComment[$counter_comment][
'str_date'],
1444 $aComment[$counter_comment][
'tech_user'], $aComment[$counter_comment][
'agc_comment']);
1453 case 'RELATED_ACTION':
1457 if ($aRelatedAction==NULL)
1460 $followup=
new Follow_Up($this->
db, $p_array[
"ag_id"]);
1461 $aRelatedAction=array();
1462 $aParent=$followup->get_parent();
1465 $nb_parent=count($aParent);
1466 $sql_related_action=
"
1469 (select ad_value from fiche_detail fd1 where fd1.ad_id=23 and fd1.f_id=f_id_dest) as qcode,
1470 (select ad_value from fiche_detail fd1 where fd1.ad_id=1 and fd1.f_id=f_id_dest) as card_name,
1471 (select ad_value from fiche_detail fd1 where fd1.ad_id=32 and fd1.f_id=f_id_dest) as card_fname,
1473 to_char(ag_timestamp,'DD.MM.YYYY') as strdate,
1475 from action_gestion ag where ag_id=$1 ";
1477 for ($x=0; $x<$nb_parent; $x++)
1479 $aRelatedAction[]=$this->
db->get_row($sql_related_action, [$aParent[$x][
'aga_least']]);
1480 $aChild=$followup->get_children($aParent[$x][
'aga_least']);
1481 $nb_child=count($aChild);
1482 for ($y=0; $y<$nb_child; $y++)
1484 $aRelatedAction[]=$this->
db->get_row($sql_related_action,
1485 [$aChild[$y][
'aga_greatest']]);
1490 if (count($aRelatedAction)>$counter_related_action)
1493 $aRelatedAction[$counter_related_action][
'ag_id'],
1494 $aRelatedAction[$counter_related_action][
'ag_ref'],
1495 $aRelatedAction[$counter_related_action][
'strdate'],
1496 $aRelatedAction[$counter_related_action][
'qcode'],
1497 $aRelatedAction[$counter_related_action][
'card_fname'],
1498 $aRelatedAction[$counter_related_action][
'card_name'],
1499 $aRelatedAction[$counter_related_action][
'ag_title']
1502 $counter_related_action++;
1511 case 'CONCERNED_OPERATION':
1515 if ($aRelatedOperation==NULL)
1518 $aRelatedOperation=$this->
db->get_array(
"select ago_id,
1523 to_char(j.jr_date,'DD.MM.YY') as str_date
1525 join action_gestion_operation as ago on (j.jr_id=ago.jr_id)
1526 where ag_id=$1 order by jr_date,jr_id"
1527 , [$p_array[
'ag_id']]);
1530 if (count($aRelatedOperation)>$counter_related_operation)
1533 $aRelatedOperation[$counter_related_operation][
'str_date'],
1534 $aRelatedOperation[$counter_related_operation][
'jr_internal'],
1535 $aRelatedOperation[$counter_related_operation][
'jr_comment'],
1536 $aRelatedOperation[$counter_related_operation][
'jr_pj_number']
1538 $counter_related_operation++;
1550 if ($aOtherCard==NULL)
1553 $aOtherCard=$this->
db->get_array(
"
1555 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 1) as cname,
1556 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 32) as cfname,
1557 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 23) as qcode,
1558 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 18 ) as email,
1559 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 27 ) as mobile,
1560 (select ad_value from fiche_detail where f_id = ap.f_id and ad_id = 17 ) as phone
1561 from action_person ap
1564 , [$p_array[
'ag_id']]);
1567 if (count($aOtherCard)>$counter_other_card)
1569 $description.=sprintf(
'%s %s %s %s %s %s ', $aOtherCard[$counter_other_card][
'cname'],
1570 $aOtherCard[$counter_other_card][
'cfname'], $aOtherCard[$counter_other_card][
'qcode'],
1571 $aOtherCard[$counter_other_card][
'email'], $aOtherCard[$counter_other_card][
'phone'],
1572 $aOtherCard[$counter_other_card][
'mobile']);
1573 $counter_other_card++;
1581 case 'ATTACHED_FILES':
1585 if ($aFileAttached==NULL)
1588 $aFileAttached=$this->
db->get_array(
"
1589 select d_filename,d_description from document d where ag_id=$1
1591 , [$p_array[
'ag_id']]);
1593 $nb_comment=count($aFileAttached);
1595 if (count($aFileAttached)>$counter_file)
1597 $description.=sprintf(
"%s %s ", $aFileAttached[$counter_file][
'd_filename'],
1598 $aFileAttached [$counter_file][
'd_description']);
1614 select t_tag from action_tags at2 join tags t using(t_id) where ag_id=$1 order by upper(t_tag)
1616 , [$p_array[
'ag_id']]);
1619 if (count(
$aTag)>$counter_tag)
1629 case 'COMM_PAYMENT':
1630 if (isset(
$p_array[
"e_comm_paiement"]))
1632 return $p_array[
"e_comm_paiement"];
1641 if (isset(
$p_array[
'ag_priority']))
1643 $aPriority=array(1=>_(
"Haute"), 2=>_(
"Normale"), 3=>_(
"Basse"));
1644 return $aPriority[
$p_array[
"ag_priority"]];
1651 $profile=$this->
db->get_value(
"select p_name from profile where p_id=$1", array(
$p_array[
'ag_dest']));
1667 select s_value from document_state where s_id=$1", array(
$p_array[
'ag_state']));
1672 case 'DOCUMENT_TYPE':
1676 $ret=$this->
db->get_value(
"select dt_value
1678 join document_type dt on (ag_type=dt.dt_id)
1679 where ag_id=$1", array(
$p_array[
"ag_id"]));
1681 $ret = $this->
db->get_value(
"
1682 select md_name from public.document_modele where md_id=$1",
1683 [$p_array[
'gen_doc']]);
1687 return $p_array[
'jrn_note_input']??
"";
1695 if (preg_match(
'/^ATTR/', $p_tag)==1)
1699 if (isset(
$p_array[
'e_march'.$this->counter]))
1709 if (preg_match(
'/^BENEFATTR/', $p_tag)==1)
1717 if (preg_match(
'/^CUSTATTR/', $p_tag)==1)
1729 $pe_value=$this->
db->get_value(
"select pe_value from parameter_extra where pe_code=$1",[$p_tag]);
1730 if ( $this->
db->count() > 0 ) {
return $pe_value;}
1742 $d_lob=$this->
db->get_value(
'select d_lob from document where d_id=$1', array($this->d_id));
1743 $sql=
'delete from document where d_id='.$this->d_id;
1744 $this->
db->exec_sql(
$sql);
1746 $this->
db->lo_unlink($d_lob);
1759 $sql=
"update jrn set jr_pj=$1,jr_pj_name=$2,jr_pj_type=$3 where jr_internal=$4";
1761 $this->
db->exec_sql(
$sql, array($this->d_lob, $this->d_filename, $this->d_mimetype, $p_internal));
1763 $sql=
'delete from document where d_id='.$this->d_id;
1764 $this->
db->exec_sql(
$sql);
1778 if ($p_qcode==
"")
return "";
1781 $found=
$f->get_by_qcode($p_qcode,
false);
1783 if ($found==1)
return "";
1786 $attr=preg_replace(
"/^.*ATTR/",
"", $p_tag);
1790 $ad_type=$this->
db->get_value(
"select ad_type from attr_def where ad_id=$1", array(
$attr));
1793 $ad_value=$this->
db->get_value(
"select ad_value from fiche_detail where f_id=$1 and ad_id=$2",
1797 if ($ad_type==
"select")
1799 $sql=$this->
db->get_value(
"select ad_extra from attr_def where ad_id=$1", array(
$attr));
1803 if (
$array[
$a][
'value']==$ad_value)
1813 $this->
db->exec_sql(
'update document set d_description = $1 where d_id=$2', array($p_desc, $this->d_id));
1826 $p_value=$p_value??
'';
1827 $check=str_replace([
'<',
'>',
'<',
'>',
'='],
"",
$check);
1828 if (preg_replace(
'/[^[:alnum:]^_]/',
'',
$check)!=
$check)
1830 throw new Exception(sprintf(_(
"chaine à remplacer [%s] contient un caractère interdit"), $p_pattern));
1833 if (is_numeric($p_value)&&
$p_type==
'OOo')
1836 $searched=
'/office:value-type="string"><text:p>'.$p_pattern.
'/i';
1837 $replaced=
'office:value-type="float" office:value="'.$p_value.
'"><text:p>'.$p_value;
1838 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1842 $searched=
'/office:value-type="string" calcext:value-type="string"><text:p>(<text:s\/>)*'.$p_pattern.
'/i';
1843 $replaced=
'office:value-type="float" office:value="'.$p_value.
'" calcext:value-type="float"><text:p>'.$p_value;
1844 $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit,
$count);
1858 $p_buffer=preg_replace(
'/'.$p_pattern.
'/i', $p_value, $p_buffer, $p_limit);
1870 if ($this->d_id==0) {
1874 $ret=$this->
db->exec_sql(
1875 "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]);
1882 $tmp=$p_destination_file;
1883 if ( $this->
db->lo_export(
$row[
'd_lob'],
$tmp) ==
true) {
1884 $this->d_mimetype=
$row[
'd_mimetype'];
1885 $this->d_filename=
$row[
'd_filename'];
1886 $this->
db->commit();
1889 $this->
db->commit();
1901 if (GENERATE_PDF ==
'NO' ) {
1903 throw new \Exception(
"Cannot not transform to PDF",5000);
1906 $dirname=tempnam($_ENV[
'TMP'],
"document");
1909 throw new Exception(
"D1862.cannot create tmp file",5000);
1914 throw new Exception(
"D1868.cannot create tmp directory",5000);
1920 passthru(OFFICE . escapeshellarg($destination_file),
$status);
1924 \record_log(__FILE__.
"D1879 Error cannot transform into PDF".
" output [$result]");
1925 throw new \Exception(
"D1879 Cannot not transform to PDF");
1928 $ext = strrpos($this->d_filename,
".");
1929 $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.
noalyss_bcmul($p_first, $p_second)
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Manage the account from the table jrn, jrnx or tmp_pcmn.
Acc_Tva is used for to map the table tva_rate parameter are.
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)
static id()
return the 'gDossier' value after a check
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
const ATTR_DEF_NUMBER_CUSTOMER
if( $delta< 0) elseif( $delta==0)