1.
<?php
2.
3.
/*
4.
Généalogik
5.
6.
Class for table : document.
7.
8.
07/03/2021 10:45
9.
10.
lvardon@laposte.net - 2021
11.
12.
Licence libre
13.
14.
Usage examples :
15.
16.
<?php
17.
18.
include_once("classdir/dbconnect.php);
19.
include_once("classdir/class_document.php);
20.
21.
// Class instance
22.
$mydocument = document( $db );
23.
24.
// Select all reccords :
25.
$results = $mydocument->selectAll();
26.
foreach($results as $row) {
27.
print_r($row);
28.
}
29.
30.
// Select reccord #12 :
31.
$id = 12;
32.
$row = $mydocument->select($id);
33.
print_r($row);
34.
35.
?>
36.
37.
*/
38.
class _document {
39.
40.
public $db;
41.
public $lasterror="";
42.
public $lastInsertId=-1;
43.
public $count = 0;
44.
45.
/*
46.
Initialise object with dbHanler.
47.
48.
*/
49.
function __construct( $db ) {
50.
$this->db = $db;
51.
}
52.
53.
/*
54.
Select one reccord from document.
55.
56.
parameters : $id (reccord id).
57.
return : associative array of reccord.
58.
*/
59.
function select($id) {
60.
61.
$this->lasterror="";
62.
63.
$sqlSt="
64.
select
65.
a.id as 'a.id',
66.
a.name as 'a.name',
67.
a.description as 'a.description',
68.
a.private as 'a.private',
69.
a.icon as 'a.icon',
70.
a.url as 'a.url',
71.
a.cote as 'a.cote',
72.
a.notesearch as 'a.notesearch',
73.
a.datecreated as 'a.datecreated',
74.
a.depot_id as 'a.depot_id',
75.
a.documenttype_id as 'a.documenttype_id',
76.
77.
b1.id as 'b1.id',
78.
b1.name as 'b1.name',
79.
b1.code as 'b1.code',
80.
b1.description as 'b1.description',
81.
b1.icon as 'b1.icon',
82.
b1.url as 'b1.url',
83.
b1.adress_1 as 'b1.adress_1',
84.
b1.adress_2 as 'b1.adress_2',
85.
b1.city as 'b1.city',
86.
b1.zip as 'b1.zip',
87.
b1.country as 'b1.country',
88.
c2.id as 'c2.id',
89.
c2.name as 'c2.name',
90.
c2.code as 'c2.code',
91.
c2.description as 'c2.description',
92.
c2.icon as 'c2.icon'
93.
94.
from document a
95.
left outer join documenttype c2 on c2.id = a.documenttype_id
96.
left outer join depot b1 on b1.id = a.depot_id
97.
98.
where a.id = :id;
99.
";
100.
101.
try {
102.
103.
$stmt = $this->db->prepare($sqlSt);
104.
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
105.
$stmt->execute();
106.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
107.
return $results;
108.
109.
} catch (Exception $e) {
110.
$this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
111.
return false;
112.
}
113.
}
114.
115.
function selectPrev($id) {
116.
117.
$this->lasterror="";
118.
119.
$sqlSt="
120.
select
121.
a.id as 'a.id',
122.
a.name as 'a.name',
123.
a.description as 'a.description',
124.
a.private as 'a.private',
125.
a.icon as 'a.icon',
126.
a.url as 'a.url',
127.
a.cote as 'a.cote',
128.
a.notesearch as 'a.notesearch',
129.
a.datecreated as 'a.datecreated',
130.
a.depot_id as 'a.depot_id',
131.
a.documenttype_id as 'a.documenttype_id',
132.
133.
b1.id as 'b1.id',
134.
b1.name as 'b1.name',
135.
b1.code as 'b1.code',
136.
b1.description as 'b1.description',
137.
b1.icon as 'b1.icon',
138.
b1.url as 'b1.url',
139.
b1.adress_1 as 'b1.adress_1',
140.
b1.adress_2 as 'b1.adress_2',
141.
b1.city as 'b1.city',
142.
b1.zip as 'b1.zip',
143.
b1.country as 'b1.country',
144.
c2.id as 'c2.id',
145.
c2.name as 'c2.name',
146.
c2.code as 'c2.code',
147.
c2.description as 'c2.description',
148.
c2.icon as 'c2.icon'
149.
150.
from document a
151.
left outer join documenttype c2 on c2.id = a.documenttype_id
152.
left outer join depot b1 on b1.id = a.depot_id
153.
154.
where a.id = (SELECT id FROM document WHERE id < :id ORDER BY id DESC LIMIT 1) ;
155.
";
156.
157.
try {
158.
159.
$stmt = $this->db->prepare($sqlSt);
160.
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
161.
$stmt->execute();
162.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
163.
return $results;
164.
165.
} catch (Exception $e) {
166.
$this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
167.
return false;
168.
}
169.
}
170.
171.
172.
function selectNext($id) {
173.
174.
$this->lasterror="";
175.
176.
$sqlSt="
177.
select
178.
a.id as 'a.id',
179.
a.name as 'a.name',
180.
a.description as 'a.description',
181.
a.private as 'a.private',
182.
a.icon as 'a.icon',
183.
a.url as 'a.url',
184.
a.cote as 'a.cote',
185.
a.notesearch as 'a.notesearch',
186.
a.datecreated as 'a.datecreated',
187.
a.depot_id as 'a.depot_id',
188.
a.documenttype_id as 'a.documenttype_id',
189.
190.
b1.id as 'b1.id',
191.
b1.name as 'b1.name',
192.
b1.code as 'b1.code',
193.
b1.description as 'b1.description',
194.
b1.icon as 'b1.icon',
195.
b1.url as 'b1.url',
196.
b1.adress_1 as 'b1.adress_1',
197.
b1.adress_2 as 'b1.adress_2',
198.
b1.city as 'b1.city',
199.
b1.zip as 'b1.zip',
200.
b1.country as 'b1.country',
201.
c2.id as 'c2.id',
202.
c2.name as 'c2.name',
203.
c2.code as 'c2.code',
204.
c2.description as 'c2.description',
205.
c2.icon as 'c2.icon'
206.
207.
from document a
208.
left outer join documenttype c2 on c2.id = a.documenttype_id
209.
left outer join depot b1 on b1.id = a.depot_id
210.
211.
where a.id = (SELECT id FROM document WHERE id > :id ORDER BY id ASC LIMIT 1) ;
212.
";
213.
214.
try {
215.
216.
$stmt = $this->db->prepare($sqlSt);
217.
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
218.
$stmt->execute();
219.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
220.
return $results;
221.
222.
} catch (Exception $e) {
223.
$this->lasterror = $e->getMessage().' (<b>Id</b> = '.$idkeyname.')';
224.
return false;
225.
}
226.
}
227.
228.
/*
229.
Select all reccords from document (with default order).
230.
231.
parameters : None
232.
return : associative array of reccords.
233.
*/
234.
function selectAll() {
235.
236.
$this->lasterror="";
237.
238.
$sqlSt="
239.
select
240.
a.id as 'a.id',
241.
a.name as 'a.name',
242.
a.description as 'a.description',
243.
a.private as 'a.private',
244.
a.icon as 'a.icon',
245.
a.url as 'a.url',
246.
a.cote as 'a.cote',
247.
a.notesearch as 'a.notesearch',
248.
a.datecreated as 'a.datecreated',
249.
a.depot_id as 'a.depot_id',
250.
a.documenttype_id as 'a.documenttype_id',
251.
252.
b1.id as 'b1.id',
253.
b1.name as 'b1.name',
254.
b1.code as 'b1.code',
255.
b1.description as 'b1.description',
256.
b1.icon as 'b1.icon',
257.
b1.url as 'b1.url',
258.
b1.adress_1 as 'b1.adress_1',
259.
b1.adress_2 as 'b1.adress_2',
260.
b1.city as 'b1.city',
261.
b1.zip as 'b1.zip',
262.
b1.country as 'b1.country',
263.
c2.id as 'c2.id',
264.
c2.name as 'c2.name',
265.
c2.code as 'c2.code',
266.
c2.description as 'c2.description',
267.
c2.icon as 'c2.icon'
268.
269.
from document a
270.
left outer join documenttype c2 on c2.id = a.documenttype_id
271.
left outer join depot b1 on b1.id = a.depot_id
272.
273.
;
274.
";
275.
276.
try {
277.
278.
$stmt = $this->db->prepare($sqlSt);
279.
$stmt->execute();
280.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
281.
return $results;
282.
283.
} catch (Exception $e) {
284.
$this->lasterror = $e->getMessage();
285.
$this->count = 0;
286.
return false;
287.
}
288.
}
289.
290.
/*
291.
Update document
292.
293.
parameters : $id (reccord id) and fields list values.
294.
return : True if no error.
295.
*/
296.
function update( $id, $name,$description,$private,$icon,$url,$cote,$notesearch,$datecreated,$depot_id,$documenttype_id ) {
297.
298.
$this->lasterror="";
299.
300.
if ($name == '') $name = null;
301.
if ($description == '') $description = null;
302.
if ($private == '') $private = null;
303.
if ($icon == '') $icon = null;
304.
if ($url == '') $url = null;
305.
if ($cote == '') $cote = null;
306.
if ($notesearch == '') $notesearch = null;
307.
if ($datecreated == '') $datecreated = null;
308.
if ($depot_id == '') $depot_id = null;
309.
if ($documenttype_id == '') $documenttype_id = null;
310.
311.
312.
if ($this->checkValue( array(
313.
$name => '',
314.
$description => '',
315.
$private => '',
316.
$icon => '',
317.
$url => '',
318.
$cote => '',
319.
$notesearch => '',
320.
$datecreated => '',
321.
$depot_id => '',
322.
$documenttype_id => ''
323.
324.
) ) == false )
325.
{
326.
$this->lasterror="Check fields false";
327.
return false;
328.
}
329.
330.
$sqlSt="
331.
update document set
332.
name = :name,
333.
description = :description,
334.
private = :private,
335.
icon = :icon,
336.
url = :url,
337.
cote = :cote,
338.
notesearch = :notesearch,
339.
datecreated = :datecreated,
340.
depot_id = :depot_id,
341.
documenttype_id = :documenttype_id
342.
343.
where id = :id;
344.
";
345.
346.
try {
347.
348.
$stmt = $this->db->prepare($sqlSt);
349.
350.
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
351.
352.
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
353.
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
354.
$stmt->bindParam(':private', $private, PDO::PARAM_INT);
355.
$stmt->bindParam(':icon', $icon, PDO::PARAM_STR);
356.
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
357.
$stmt->bindParam(':cote', $cote, PDO::PARAM_STR);
358.
$stmt->bindParam(':notesearch', $notesearch, PDO::PARAM_STR);
359.
$stmt->bindParam(':datecreated', $datecreated, PDO::PARAM_STR);
360.
$stmt->bindParam(':depot_id', $depot_id, PDO::PARAM_INT);
361.
$stmt->bindParam(':documenttype_id', $documenttype_id, PDO::PARAM_INT);
362.
363.
$stmt->execute();
364.
365.
if ($stmt->rowCount() == 0) {
366.
$this->lasterror = 'Erreur Sql update '.' (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>url</b> = [$url],<b>cote</b> = [$cote],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated],<b>depot_id</b> = [$depot_id],<b>documenttype_id</b> = [$documenttype_id]";
367.
368.
return false;
369.
}
370.
371.
return true;
372.
373.
} catch (Exception $e) {
374.
$this->lasterror = $e->getMessage().' (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>url</b> = [$url],<b>cote</b> = [$cote],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated],<b>depot_id</b> = [$depot_id],<b>documenttype_id</b> = [$documenttype_id]";
375.
return false;
376.
}
377.
378.
}
379.
380.
/*
381.
Insert new reccord into document.
382.
383.
Parameters : fields values list.
384.
return : True if no error.
385.
*/
386.
function insert( $name,$description,$private,$icon,$url,$cote,$notesearch,$datecreated,$depot_id,$documenttype_id ) {
387.
388.
$this->lasterror="";
389.
$this->lastInsertId = -1;
390.
391.
if ($name == '') $name = null;
392.
if ($description == '') $description = null;
393.
if ($private == '') $private = null;
394.
if ($icon == '') $icon = null;
395.
if ($url == '') $url = null;
396.
if ($cote == '') $cote = null;
397.
if ($notesearch == '') $notesearch = null;
398.
if ($datecreated == '') $datecreated = null;
399.
if ($depot_id == '') $depot_id = null;
400.
if ($documenttype_id == '') $documenttype_id = null;
401.
402.
403.
if ($this->checkValue( array(
404.
$name => '',
405.
$description => '',
406.
$private => '',
407.
$icon => '',
408.
$url => '',
409.
$cote => '',
410.
$notesearch => '',
411.
$datecreated => '',
412.
$depot_id => '',
413.
$documenttype_id => ''
414.
415.
) ) == false )
416.
{
417.
$this->lasterror="Check fields error";
418.
return false;
419.
}
420.
421.
$sqlSt="
422.
insert into document (
423.
name,
424.
description,
425.
private,
426.
icon,
427.
url,
428.
cote,
429.
notesearch,
430.
datecreated,
431.
depot_id,
432.
documenttype_id
433.
434.
)
435.
values (
436.
:name,
437.
:description,
438.
:private,
439.
:icon,
440.
:url,
441.
:cote,
442.
:notesearch,
443.
:datecreated,
444.
:depot_id,
445.
:documenttype_id
446.
447.
);
448.
";
449.
450.
try {
451.
452.
$stmt = $this->db->prepare($sqlSt);
453.
454.
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
455.
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
456.
$stmt->bindParam(':private', $private, PDO::PARAM_INT);
457.
$stmt->bindParam(':icon', $icon, PDO::PARAM_STR);
458.
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
459.
$stmt->bindParam(':cote', $cote, PDO::PARAM_STR);
460.
$stmt->bindParam(':notesearch', $notesearch, PDO::PARAM_STR);
461.
$stmt->bindParam(':datecreated', $datecreated, PDO::PARAM_STR);
462.
$stmt->bindParam(':depot_id', $depot_id, PDO::PARAM_INT);
463.
$stmt->bindParam(':documenttype_id', $documenttype_id, PDO::PARAM_INT);
464.
465.
466.
$stmt->execute();
467.
$this->lastInsertId = $this->db->lastInsertId();
468.
469.
if ($stmt->rowCount() == 0) {
470.
$this->lasterror = 'Erreur Sql insert'.' (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>url</b> = [$url],<b>cote</b> = [$cote],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated],<b>depot_id</b> = [$depot_id],<b>documenttype_id</b> = [$documenttype_id]";
471.
return false;
472.
}
473.
474.
return true;
475.
476.
} catch (Exception $e) {
477.
$this->lasterror = $e->getMessage().' (<b>Id</b> = '.$id.'). <b>Sqlst</b> = ['.$sqlSt.'] values : '."<b>name</b> = [$name],<b>description</b> = [$description],<b>private</b> = [$private],<b>icon</b> = [$icon],<b>url</b> = [$url],<b>cote</b> = [$cote],<b>notesearch</b> = [$notesearch],<b>datecreated</b> = [$datecreated],<b>depot_id</b> = [$depot_id],<b>documenttype_id</b> = [$documenttype_id]";
478.
return false;
479.
}
480.
}
481.
482.
/*
483.
Delete one reccord from document.
484.
485.
parameters : $id (reccord id).
486.
return : True if no error.
487.
*/
488.
function delete($id) {
489.
490.
$this->lasterror="";
491.
492.
$sqlSt="
493.
delete from document
494.
where id = :id;
495.
";
496.
497.
try {
498.
499.
$stmt = $this->db->prepare($sqlSt);
500.
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
501.
$stmt->execute();
502.
503.
if ($stmt->rowCount() == 0) {
504.
$this->lasterror = "Erreur Sql delete ".' (<b>Id</b> ='.$id.')';
505.
return false;
506.
}
507.
508.
} catch (Exception $e) {
509.
$this->lasterror = $e->getMessage().' (<b>Id</b>='.$id.')';
510.
return false;
511.
}
512.
return true;
513.
}
514.
515.
/*
516.
Get id min, id max, record count from document
517.
518.
parameters : None
519.
return : count value or False in case of error
520.
*/
521.
function getCount() {
522.
523.
$this->lasterror="";
524.
525.
$sqlSt="
526.
select min(id) as minid, max(id) as maxid, count(*) as count
527.
from document
528.
";
529.
530.
try {
531.
532.
$stmt = $this->db->prepare($sqlSt);
533.
$stmt->execute();
534.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
535.
return $results[0];
536.
537.
} catch (Exception $e) {
538.
$this->lasterror = $e->getMessage();
539.
return array( 'minid' => -1, 'maxid' => -1, 'count' => -1);
540.
}
541.
542.
//return $this->count;
543.
return $results[0];
544.
}
545.
546.
547.
548.
549.
public $colmeta = [
550.
'a.id' => array (
551.
'metades' => "",
552.
'sortformat' => "{{sortformat}}",
553.
'listlen' => 4,
554.
'listlib' => 'id',
555.
'listlink' => 'on',
556.
'selectlen' => 4,
557.
'selectlib' => 'id',
558.
'selectlink' => 'on',
559.
'selectdisplay' => '',
560.
'selectdisplaywidth' => '0',
561.
'selectdisplayheight' => '0',
562.
'listdisplay' => '',
563.
'listdisplaywidth' => '0',
564.
'listdisplayheight' => '0'
565.
566.
),
567.
'a.name' => array (
568.
'metades' => "",
569.
'sortformat' => "",
570.
'listlen' => 12,
571.
'listlib' => 'name' ,
572.
'listlink' => '',
573.
'selectlen' => 12,
574.
'selectlib' => 'name' ,
575.
'selectlink' => '',
576.
'selectdisplay' => 'text',
577.
'selectdisplaywidth' => '0',
578.
'selectdisplayheight' => '0',
579.
'listdisplay' => 'text',
580.
'listdisplaywidth' => '0',
581.
'listdisplayheight' => '0'
582.
),
583.
'a.description' => array (
584.
'metades' => "",
585.
'sortformat' => "",
586.
'listlen' => 0,
587.
'listlib' => 'description' ,
588.
'listlink' => '',
589.
'selectlen' => 0,
590.
'selectlib' => 'description' ,
591.
'selectlink' => '',
592.
'selectdisplay' => 'text',
593.
'selectdisplaywidth' => '0',
594.
'selectdisplayheight' => '0',
595.
'listdisplay' => 'text',
596.
'listdisplaywidth' => '0',
597.
'listdisplayheight' => '0'
598.
),
599.
'a.private' => array (
600.
'metades' => "",
601.
'sortformat' => "",
602.
'listlen' => 4,
603.
'listlib' => 'private' ,
604.
'listlink' => '',
605.
'selectlen' => 4,
606.
'selectlib' => 'private' ,
607.
'selectlink' => '',
608.
'selectdisplay' => 'text',
609.
'selectdisplaywidth' => '0',
610.
'selectdisplayheight' => '0',
611.
'listdisplay' => 'text',
612.
'listdisplaywidth' => '0',
613.
'listdisplayheight' => '0'
614.
),
615.
'a.icon' => array (
616.
'metades' => "",
617.
'sortformat' => "",
618.
'listlen' => 12,
619.
'listlib' => 'icon' ,
620.
'listlink' => '',
621.
'selectlen' => 12,
622.
'selectlib' => 'icon' ,
623.
'selectlink' => '',
624.
'selectdisplay' => 'urlpic',
625.
'selectdisplaywidth' => '{{selectdisplaywidth}}',
626.
'selectdisplayheight' => '{{selectdisplayheight}}',
627.
'listdisplay' => 'urlpic',
628.
'listdisplaywidth' => '{{listdisplaywidth}}',
629.
'listdisplayheight' => '{{listdisplayheight}}'
630.
),
631.
'a.url' => array (
632.
'metades' => "",
633.
'sortformat' => "",
634.
'listlen' => 12,
635.
'listlib' => 'url' ,
636.
'listlink' => '',
637.
'selectlen' => 12,
638.
'selectlib' => 'url' ,
639.
'selectlink' => '',
640.
'selectdisplay' => 'text',
641.
'selectdisplaywidth' => '0',
642.
'selectdisplayheight' => '0',
643.
'listdisplay' => 'url',
644.
'listdisplaywidth' => '0',
645.
'listdisplayheight' => '0'
646.
),
647.
'a.cote' => array (
648.
'metades' => "",
649.
'sortformat' => "",
650.
'listlen' => 12,
651.
'listlib' => 'cote' ,
652.
'listlink' => '',
653.
'selectlen' => 12,
654.
'selectlib' => 'cote' ,
655.
'selectlink' => '',
656.
'selectdisplay' => 'text',
657.
'selectdisplaywidth' => '0',
658.
'selectdisplayheight' => '0',
659.
'listdisplay' => 'text',
660.
'listdisplaywidth' => '0',
661.
'listdisplayheight' => '0'
662.
),
663.
'a.notesearch' => array (
664.
'metades' => "",
665.
'sortformat' => "",
666.
'listlen' => 12,
667.
'listlib' => 'notesearch' ,
668.
'listlink' => '',
669.
'selectlen' => 12,
670.
'selectlib' => 'notesearch' ,
671.
'selectlink' => '',
672.
'selectdisplay' => 'text',
673.
'selectdisplaywidth' => '0',
674.
'selectdisplayheight' => '0',
675.
'listdisplay' => 'text',
676.
'listdisplaywidth' => '0',
677.
'listdisplayheight' => '0'
678.
),
679.
'a.datecreated' => array (
680.
'metades' => "",
681.
'sortformat' => "date",
682.
'listlen' => 4,
683.
'listlib' => 'datecreated' ,
684.
'listlink' => '',
685.
'selectlen' => 4,
686.
'selectlib' => 'datecreated' ,
687.
'selectlink' => '',
688.
'selectdisplay' => 'text',
689.
'selectdisplaywidth' => '0',
690.
'selectdisplayheight' => '0',
691.
'listdisplay' => 'text',
692.
'listdisplaywidth' => '0',
693.
'listdisplayheight' => '0'
694.
),
695.
'a.depot_id' => array (
696.
'metades' => "",
697.
'sortformat' => "",
698.
'listlen' => 4,
699.
'listlib' => 'depot_id' ,
700.
'listlink' => '',
701.
'selectlen' => 4,
702.
'selectlib' => 'depot_id' ,
703.
'selectlink' => '',
704.
'selectdisplay' => 'text',
705.
'selectdisplaywidth' => '0',
706.
'selectdisplayheight' => '0',
707.
'listdisplay' => 'text',
708.
'listdisplaywidth' => '0',
709.
'listdisplayheight' => '0'
710.
),
711.
'a.documenttype_id' => array (
712.
'metades' => "",
713.
'sortformat' => "",
714.
'listlen' => 4,
715.
'listlib' => 'documenttype_id' ,
716.
'listlink' => '',
717.
'selectlen' => 4,
718.
'selectlib' => 'documenttype_id' ,
719.
'selectlink' => '',
720.
'selectdisplay' => 'text',
721.
'selectdisplaywidth' => '0',
722.
'selectdisplayheight' => '0',
723.
'listdisplay' => 'text',
724.
'listdisplaywidth' => '0',
725.
'listdisplayheight' => '0'
726.
),
727.
728.
'b1.id' => array ( // Depot
729.
'metades' => "",
730.
'sortformat' => "",
731.
'listlen' => 4,
732.
'listlib' => 'b_id',
733.
'listlink' => 'on' ,
734.
'selectlen' => 4,
735.
'selectlib' => 'b_id',
736.
'selectlink' => '{{fkselectlink}}',
737.
'selectdisplay' => 'text',
738.
'selectdisplaywidth' => '0',
739.
'selectdisplayheight' => '0',
740.
'listdisplay' => 'text',
741.
'listdisplaywidth' => '0',
742.
'listdisplayheight' => '0'
743.
),
744.
'b1.name' => array ( // Depot
745.
'metades' => "",
746.
'sortformat' => "",
747.
'listlen' => 12,
748.
'listlib' => 'b_name',
749.
'listlink' => '' ,
750.
'selectlen' => 12,
751.
'selectlib' => 'b_name',
752.
'selectlink' => '{{fkselectlink}}',
753.
'selectdisplay' => 'text',
754.
'selectdisplaywidth' => '0',
755.
'selectdisplayheight' => '0',
756.
'listdisplay' => 'text',
757.
'listdisplaywidth' => '0',
758.
'listdisplayheight' => '0'
759.
),
760.
'b1.code' => array ( // Depot
761.
'metades' => "",
762.
'sortformat' => "",
763.
'listlen' => 12,
764.
'listlib' => 'b_code',
765.
'listlink' => '' ,
766.
'selectlen' => 12,
767.
'selectlib' => 'b_code',
768.
'selectlink' => '{{fkselectlink}}',
769.
'selectdisplay' => 'text',
770.
'selectdisplaywidth' => '0',
771.
'selectdisplayheight' => '0',
772.
'listdisplay' => 'text',
773.
'listdisplaywidth' => '0',
774.
'listdisplayheight' => '0'
775.
),
776.
'b1.description' => array ( // Depot
777.
'metades' => "",
778.
'sortformat' => "",
779.
'listlen' => 12,
780.
'listlib' => 'b_description',
781.
'listlink' => '' ,
782.
'selectlen' => 12,
783.
'selectlib' => 'b_description',
784.
'selectlink' => '{{fkselectlink}}',
785.
'selectdisplay' => 'text',
786.
'selectdisplaywidth' => '0',
787.
'selectdisplayheight' => '0',
788.
'listdisplay' => 'text',
789.
'listdisplaywidth' => '0',
790.
'listdisplayheight' => '0'
791.
),
792.
'b1.icon' => array ( // Depot
793.
'metades' => "",
794.
'sortformat' => "",
795.
'listlen' => 12,
796.
'listlib' => 'b_icon',
797.
'listlink' => '' ,
798.
'selectlen' => 12,
799.
'selectlib' => 'b_icon',
800.
'selectlink' => '{{fkselectlink}}',
801.
'selectdisplay' => 'text',
802.
'selectdisplaywidth' => '0',
803.
'selectdisplayheight' => '0',
804.
'listdisplay' => 'text',
805.
'listdisplaywidth' => '0',
806.
'listdisplayheight' => '0'
807.
),
808.
'b1.url' => array ( // Depot
809.
'metades' => "",
810.
'sortformat' => "",
811.
'listlen' => 12,
812.
'listlib' => 'b_url',
813.
'listlink' => '' ,
814.
'selectlen' => 12,
815.
'selectlib' => 'b_url',
816.
'selectlink' => '{{fkselectlink}}',
817.
'selectdisplay' => 'text',
818.
'selectdisplaywidth' => '0',
819.
'selectdisplayheight' => '0',
820.
'listdisplay' => 'text',
821.
'listdisplaywidth' => '0',
822.
'listdisplayheight' => '0'
823.
),
824.
'b1.adress_1' => array ( // Depot
825.
'metades' => "",
826.
'sortformat' => "",
827.
'listlen' => 12,
828.
'listlib' => 'b_adress_1',
829.
'listlink' => '' ,
830.
'selectlen' => 12,
831.
'selectlib' => 'b_adress_1',
832.
'selectlink' => '{{fkselectlink}}',
833.
'selectdisplay' => 'text',
834.
'selectdisplaywidth' => '0',
835.
'selectdisplayheight' => '0',
836.
'listdisplay' => 'text',
837.
'listdisplaywidth' => '0',
838.
'listdisplayheight' => '0'
839.
),
840.
'b1.adress_2' => array ( // Depot
841.
'metades' => "",
842.
'sortformat' => "",
843.
'listlen' => 12,
844.
'listlib' => 'b_adress_2',
845.
'listlink' => '' ,
846.
'selectlen' => 12,
847.
'selectlib' => 'b_adress_2',
848.
'selectlink' => '{{fkselectlink}}',
849.
'selectdisplay' => 'text',
850.
'selectdisplaywidth' => '0',
851.
'selectdisplayheight' => '0',
852.
'listdisplay' => 'text',
853.
'listdisplaywidth' => '0',
854.
'listdisplayheight' => '0'
855.
),
856.
'b1.city' => array ( // Depot
857.
'metades' => "",
858.
'sortformat' => "",
859.
'listlen' => 12,
860.
'listlib' => 'b_city',
861.
'listlink' => '' ,
862.
'selectlen' => 12,
863.
'selectlib' => 'b_city',
864.
'selectlink' => '{{fkselectlink}}',
865.
'selectdisplay' => 'text',
866.
'selectdisplaywidth' => '0',
867.
'selectdisplayheight' => '0',
868.
'listdisplay' => 'text',
869.
'listdisplaywidth' => '0',
870.
'listdisplayheight' => '0'
871.
),
872.
'b1.zip' => array ( // Depot
873.
'metades' => "",
874.
'sortformat' => "",
875.
'listlen' => 12,
876.
'listlib' => 'b_zip',
877.
'listlink' => '' ,
878.
'selectlen' => 12,
879.
'selectlib' => 'b_zip',
880.
'selectlink' => '{{fkselectlink}}',
881.
'selectdisplay' => 'text',
882.
'selectdisplaywidth' => '0',
883.
'selectdisplayheight' => '0',
884.
'listdisplay' => 'text',
885.
'listdisplaywidth' => '0',
886.
'listdisplayheight' => '0'
887.
),
888.
'b1.country' => array ( // Depot
889.
'metades' => "",
890.
'sortformat' => "",
891.
'listlen' => 12,
892.
'listlib' => 'b_country',
893.
'listlink' => '' ,
894.
'selectlen' => 12,
895.
'selectlib' => 'b_country',
896.
'selectlink' => '{{fkselectlink}}',
897.
'selectdisplay' => 'text',
898.
'selectdisplaywidth' => '0',
899.
'selectdisplayheight' => '0',
900.
'listdisplay' => 'text',
901.
'listdisplaywidth' => '0',
902.
'listdisplayheight' => '0'
903.
),
904.
'c2.id' => array ( // Documenttype
905.
'metades' => "",
906.
'sortformat' => "",
907.
'listlen' => 4,
908.
'listlib' => 'c_id',
909.
'listlink' => 'on' ,
910.
'selectlen' => 4,
911.
'selectlib' => 'c_id',
912.
'selectlink' => '{{fkselectlink}}',
913.
'selectdisplay' => 'text',
914.
'selectdisplaywidth' => '0',
915.
'selectdisplayheight' => '0',
916.
'listdisplay' => 'text',
917.
'listdisplaywidth' => '0',
918.
'listdisplayheight' => '0'
919.
),
920.
'c2.name' => array ( // Documenttype
921.
'metades' => "",
922.
'sortformat' => "",
923.
'listlen' => 12,
924.
'listlib' => 'c_name',
925.
'listlink' => '' ,
926.
'selectlen' => 12,
927.
'selectlib' => 'c_name',
928.
'selectlink' => '{{fkselectlink}}',
929.
'selectdisplay' => 'text',
930.
'selectdisplaywidth' => '0',
931.
'selectdisplayheight' => '0',
932.
'listdisplay' => 'text',
933.
'listdisplaywidth' => '0',
934.
'listdisplayheight' => '0'
935.
),
936.
'c2.code' => array ( // Documenttype
937.
'metades' => "",
938.
'sortformat' => "",
939.
'listlen' => 12,
940.
'listlib' => 'c_code',
941.
'listlink' => '' ,
942.
'selectlen' => 12,
943.
'selectlib' => 'c_code',
944.
'selectlink' => '{{fkselectlink}}',
945.
'selectdisplay' => 'text',
946.
'selectdisplaywidth' => '0',
947.
'selectdisplayheight' => '0',
948.
'listdisplay' => 'text',
949.
'listdisplaywidth' => '0',
950.
'listdisplayheight' => '0'
951.
),
952.
'c2.description' => array ( // Documenttype
953.
'metades' => "",
954.
'sortformat' => "",
955.
'listlen' => 12,
956.
'listlib' => 'c_description',
957.
'listlink' => '' ,
958.
'selectlen' => 12,
959.
'selectlib' => 'c_description',
960.
'selectlink' => '{{fkselectlink}}',
961.
'selectdisplay' => 'text',
962.
'selectdisplaywidth' => '0',
963.
'selectdisplayheight' => '0',
964.
'listdisplay' => 'text',
965.
'listdisplaywidth' => '0',
966.
'listdisplayheight' => '0'
967.
),
968.
'c2.icon' => array ( // Documenttype
969.
'metades' => "",
970.
'sortformat' => "",
971.
'listlen' => 12,
972.
'listlib' => 'c_icon',
973.
'listlink' => '' ,
974.
'selectlen' => 12,
975.
'selectlib' => 'c_icon',
976.
'selectlink' => '{{fkselectlink}}',
977.
'selectdisplay' => 'text',
978.
'selectdisplaywidth' => '0',
979.
'selectdisplayheight' => '0',
980.
'listdisplay' => 'text',
981.
'listdisplaywidth' => '0',
982.
'listdisplayheight' => '0'
983.
)
984.
985.
];
986.
987.
/*
988.
Get field property value
989.
990.
Parameters : field name and property name.
991.
return : value of property.
992.
*/
993.
994.
function getMeta( $fieldkey , $metakey ) {
995.
return $this->colmeta [$fieldkey][$metakey];
996.
}
997.
998.
/*
999.
Get labels for list table header.
1000.
1001.
Parameters : None.
1002.
return : String.
1003.
*/
1004.
1005.
function getTableHeaderList() {
1006.
1007.
$labelsStr ='';
1008.
1009.
foreach ( $this->colmeta as $k => $v) {
1010.
if ( $v['listlen'] > 0 )
1011.
$labelsStr = $labelsStr.'<th title="'.$v['metades'].'" >'.$v['listlib'] .'</th>'."\n";
1012.
}
1013.
return $labelsStr;
1014.
}
1015.
1016.
function getTableFieldLenList( $field ) {
1017.
1018.
return $this->colmeta[$field]['listlen'];
1019.
}
1020.
1021.
function getTableFieldLinkList( $field ) {
1022.
1023.
return $this->colmeta[$field]['listlink'];
1024.
}
1025.
1026.
/*
1027.
Get labels for select table header.
1028.
1029.
Parameters : None.
1030.
return : String.
1031.
*/
1032.
1033.
function getTableHeaderSelect() {
1034.
1035.
$labelsStr ='';
1036.
1037.
foreach ( $this->colmeta as $k => $v) {
1038.
if ( $v['selectlen'] > 0 )
1039.
$labelsStr = $labelsStr.'<th title="'.$v['metades'].'" >'.$v['selectlib'] .'</th>'."\n";
1040.
}
1041.
return $labelsStr;
1042.
}
1043.
1044.
function getTableFieldLenSelect( $field ) {
1045.
1046.
return $this->colmeta[$field]['selectlen'];
1047.
}
1048.
1049.
function getTableFieldLinkSelect( $field ) {
1050.
1051.
return $this->colmeta[$field]['selectlink'];
1052.
}
1053.
1054.
1055.
/*
1056.
Check user input values for document.
1057.
1058.
Parameters : array of fields with regexp paterns. ex: array( $nom =>'^(?!\s*$).+' , $icone => '')
1059.
return : False if at last one regexp does not match.
1060.
*/
1061.
function checkValue( $arrayCheck ) {
1062.
1063.
$indexfield=1;
1064.
foreach ( $arrayCheck as $value => $pattern) {
1065.
1066.
if ($pattern=='') continue;
1067.
1068.
$pattern='/'.$pattern.'/';
1069.
1070.
if (!preg_match($pattern, $value)) {
1071.
$this->lasterror = "Erreur champ #".$indexfield. '. Valeur:['.$value.']';
1072.
return false;
1073.
}
1074.
1075.
$indexfield+=1;
1076.
1077.
}
1078.
1079.
return true;
1080.
}
1081.
1082.
} // end class
1083.
1084.
?>
1085.