@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function contract_prepare_head(Contrat $object) |
32 | 32 | { |
33 | - global $db, $langs, $conf; |
|
33 | + global $db, $langs, $conf; |
|
34 | 34 | |
35 | - $h = 0; |
|
36 | - $head = array(); |
|
37 | - |
|
38 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/card.php?id='.$object->id; |
|
39 | - $head[$h][1] = $langs->trans("ContractCard"); |
|
40 | - $head[$h][2] = 'card'; |
|
41 | - $h++; |
|
42 | - |
|
43 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
44 | - { |
|
45 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
46 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; |
|
47 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
48 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
49 | - $head[$h][2] = 'contact'; |
|
50 | - $h++; |
|
51 | - } |
|
35 | + $h = 0; |
|
36 | + $head = array(); |
|
37 | + |
|
38 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/card.php?id='.$object->id; |
|
39 | + $head[$h][1] = $langs->trans("ContractCard"); |
|
40 | + $head[$h][2] = 'card'; |
|
41 | + $h++; |
|
42 | + |
|
43 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
44 | + { |
|
45 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
46 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; |
|
47 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
48 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
49 | + $head[$h][2] = 'contact'; |
|
50 | + $h++; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | // Show more tabs from modules |
54 | 54 | // Entries must be declared in modules descriptor with line |
@@ -58,35 +58,35 @@ discard block |
||
58 | 58 | |
59 | 59 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 60 | { |
61 | - $nbNote = 0; |
|
61 | + $nbNote = 0; |
|
62 | 62 | if(!empty($object->note_private)) $nbNote++; |
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; |
|
65 | - $head[$h][1] = $langs->trans("Notes"); |
|
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | - $head[$h][2] = 'note'; |
|
68 | - $h++; |
|
63 | + if(!empty($object->note_public)) $nbNote++; |
|
64 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; |
|
65 | + $head[$h][1] = $langs->trans("Notes"); |
|
66 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | + $head[$h][2] = 'note'; |
|
68 | + $h++; |
|
69 | 69 | } |
70 | 70 | |
71 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
71 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
72 | 72 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
73 | - $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
74 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
73 | + $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
74 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
75 | 75 | $nbLinks=Link::count($db, $object->element, $object->id); |
76 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; |
|
77 | - $head[$h][1] = $langs->trans("Documents"); |
|
78 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
79 | - $head[$h][2] = 'documents'; |
|
80 | - $h++; |
|
76 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; |
|
77 | + $head[$h][1] = $langs->trans("Documents"); |
|
78 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
79 | + $head[$h][2] = 'documents'; |
|
80 | + $h++; |
|
81 | 81 | |
82 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id; |
|
83 | - $head[$h][1] = $langs->trans("Info"); |
|
84 | - $head[$h][2] = 'info'; |
|
85 | - $h++; |
|
82 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id; |
|
83 | + $head[$h][1] = $langs->trans("Info"); |
|
84 | + $head[$h][2] = 'info'; |
|
85 | + $h++; |
|
86 | 86 | |
87 | 87 | complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove'); |
88 | 88 | |
89 | - return $head; |
|
89 | + return $head; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function contract_admin_prepare_head() |
98 | 98 | { |
99 | - global $langs, $conf, $user; |
|
99 | + global $langs, $conf, $user; |
|
100 | 100 | |
101 | - $h = 0; |
|
102 | - $head = array(); |
|
101 | + $h = 0; |
|
102 | + $head = array(); |
|
103 | 103 | |
104 | - $head[$h][0] = DOL_URL_ROOT."/admin/contract.php"; |
|
105 | - $head[$h][1] = $langs->trans("Contracts"); |
|
106 | - $head[$h][2] = 'contract'; |
|
107 | - $h++; |
|
104 | + $head[$h][0] = DOL_URL_ROOT."/admin/contract.php"; |
|
105 | + $head[$h][1] = $langs->trans("Contracts"); |
|
106 | + $head[$h][2] = 'contract'; |
|
107 | + $h++; |
|
108 | 108 | |
109 | - // Show more tabs from modules |
|
110 | - // Entries must be declared in modules descriptor with line |
|
111 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
112 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
113 | - complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin'); |
|
109 | + // Show more tabs from modules |
|
110 | + // Entries must be declared in modules descriptor with line |
|
111 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
112 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
113 | + complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin'); |
|
114 | 114 | |
115 | - $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; |
|
116 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
115 | + $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; |
|
116 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
117 | 117 | $head[$h][2] = 'attributes'; |
118 | 118 | $h++; |
119 | 119 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove'); |
|
127 | + complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove'); |
|
128 | 128 | |
129 | - return $head; |
|
129 | + return $head; |
|
130 | 130 | } |
131 | 131 |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
44 | 44 | { |
45 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
45 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
46 | 46 | $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; |
47 | 47 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
48 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
48 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
49 | 49 | $head[$h][2] = 'contact'; |
50 | 50 | $h++; |
51 | 51 | } |
@@ -54,28 +54,28 @@ discard block |
||
54 | 54 | // Entries must be declared in modules descriptor with line |
55 | 55 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
56 | 56 | // $this->tabs = array('entity:-tabname); to remove a tab |
57 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'contract'); |
|
57 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract'); |
|
58 | 58 | |
59 | 59 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 60 | { |
61 | 61 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
62 | + if (!empty($object->note_private)) $nbNote++; |
|
63 | + if (!empty($object->note_public)) $nbNote++; |
|
64 | 64 | $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; |
65 | 65 | $head[$h][1] = $langs->trans("Notes"); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
66 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | 67 | $head[$h][2] = 'note'; |
68 | 68 | $h++; |
69 | 69 | } |
70 | 70 | |
71 | 71 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
72 | 72 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
73 | - $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
74 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
75 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
73 | + $upload_dir = $conf->contrat->dir_output."/".dol_sanitizeFileName($object->ref); |
|
74 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
75 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
76 | 76 | $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; |
77 | 77 | $head[$h][1] = $langs->trans("Documents"); |
78 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
78 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
79 | 79 | $head[$h][2] = 'documents'; |
80 | 80 | $h++; |
81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $head[$h][2] = 'info'; |
85 | 85 | $h++; |
86 | 86 | |
87 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove'); |
|
87 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract', 'remove'); |
|
88 | 88 | |
89 | 89 | return $head; |
90 | 90 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | // Entries must be declared in modules descriptor with line |
111 | 111 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
112 | 112 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
113 | - complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin'); |
|
113 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin'); |
|
114 | 114 | |
115 | 115 | $head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php'; |
116 | 116 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove'); |
|
127 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove'); |
|
128 | 128 | |
129 | 129 | return $head; |
130 | 130 | } |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
46 | 46 | $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; |
47 | 47 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
48 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
48 | + if ($nbContact > 0) { |
|
49 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
50 | + } |
|
49 | 51 | $head[$h][2] = 'contact'; |
50 | 52 | $h++; |
51 | 53 | } |
@@ -59,11 +61,17 @@ discard block |
||
59 | 61 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 62 | { |
61 | 63 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | + if(!empty($object->note_private)) { |
|
65 | + $nbNote++; |
|
66 | + } |
|
67 | + if(!empty($object->note_public)) { |
|
68 | + $nbNote++; |
|
69 | + } |
|
64 | 70 | $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; |
65 | 71 | $head[$h][1] = $langs->trans("Notes"); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + if ($nbNote > 0) { |
|
73 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + } |
|
67 | 75 | $head[$h][2] = 'note'; |
68 | 76 | $h++; |
69 | 77 | } |
@@ -75,7 +83,9 @@ discard block |
||
75 | 83 | $nbLinks=Link::count($db, $object->element, $object->id); |
76 | 84 | $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; |
77 | 85 | $head[$h][1] = $langs->trans("Documents"); |
78 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
86 | + if (($nbFiles+$nbLinks) > 0) { |
|
87 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
88 | + } |
|
79 | 89 | $head[$h][2] = 'documents'; |
80 | 90 | $h++; |
81 | 91 |
@@ -64,6 +64,6 @@ |
||
64 | 64 | // We add characteristics to the name |
65 | 65 | foreach($_Avery_Labels as $key => $val) |
66 | 66 | { |
67 | - $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; |
|
67 | + $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; |
|
68 | 68 | } |
69 | 69 |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | { |
39 | 39 | while ($row = $db->fetch_array($resql)) |
40 | 40 | { |
41 | - $_Avery_Labels[$row['code']]['name']=$row['name']; |
|
42 | - $_Avery_Labels[$row['code']]['paper-size']=$row['paper_size']; |
|
43 | - $_Avery_Labels[$row['code']]['orientation']=$row['orientation']; |
|
44 | - $_Avery_Labels[$row['code']]['metric']=$row['metric']; |
|
45 | - $_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin']; |
|
46 | - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; |
|
47 | - $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; |
|
48 | - $_Avery_Labels[$row['code']]['NX']=$row['nx']; |
|
49 | - $_Avery_Labels[$row['code']]['NY']=$row['ny']; |
|
50 | - $_Avery_Labels[$row['code']]['SpaceX']=$row['spacex']; |
|
51 | - $_Avery_Labels[$row['code']]['SpaceY']=$row['spacey']; |
|
52 | - $_Avery_Labels[$row['code']]['width']=$row['width']; |
|
53 | - $_Avery_Labels[$row['code']]['height']=$row['height']; |
|
54 | - $_Avery_Labels[$row['code']]['font-size']=$row['font_size']; |
|
55 | - $_Avery_Labels[$row['code']]['custom_x']=$row['custom_x']; |
|
56 | - $_Avery_Labels[$row['code']]['custom_y']=$row['custom_y']; |
|
41 | + $_Avery_Labels[$row['code']]['name'] = $row['name']; |
|
42 | + $_Avery_Labels[$row['code']]['paper-size'] = $row['paper_size']; |
|
43 | + $_Avery_Labels[$row['code']]['orientation'] = $row['orientation']; |
|
44 | + $_Avery_Labels[$row['code']]['metric'] = $row['metric']; |
|
45 | + $_Avery_Labels[$row['code']]['marginLeft'] = $row['leftmargin']; |
|
46 | + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; |
|
47 | + $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; |
|
48 | + $_Avery_Labels[$row['code']]['NX'] = $row['nx']; |
|
49 | + $_Avery_Labels[$row['code']]['NY'] = $row['ny']; |
|
50 | + $_Avery_Labels[$row['code']]['SpaceX'] = $row['spacex']; |
|
51 | + $_Avery_Labels[$row['code']]['SpaceY'] = $row['spacey']; |
|
52 | + $_Avery_Labels[$row['code']]['width'] = $row['width']; |
|
53 | + $_Avery_Labels[$row['code']]['height'] = $row['height']; |
|
54 | + $_Avery_Labels[$row['code']]['font-size'] = $row['font_size']; |
|
55 | + $_Avery_Labels[$row['code']]['custom_x'] = $row['custom_x']; |
|
56 | + $_Avery_Labels[$row['code']]['custom_y'] = $row['custom_y']; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | else |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | // We add characteristics to the name |
65 | -foreach($_Avery_Labels as $key => $val) |
|
65 | +foreach ($_Avery_Labels as $key => $val) |
|
66 | 66 | { |
67 | - $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; |
|
67 | + $_Avery_Labels[$key]['name'] .= ' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; |
|
68 | 68 | } |
69 | 69 |
@@ -55,8 +55,7 @@ |
||
55 | 55 | $_Avery_Labels[$row['code']]['custom_x']=$row['custom_x']; |
56 | 56 | $_Avery_Labels[$row['code']]['custom_y']=$row['custom_y']; |
57 | 57 | } |
58 | -} |
|
59 | -else |
|
58 | +} else |
|
60 | 59 | { |
61 | 60 | dol_print_error($db); |
62 | 61 | } |
@@ -32,31 +32,31 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function contact_prepare_head(Contact $object) |
34 | 34 | { |
35 | - global $db, $langs, $conf, $user; |
|
35 | + global $db, $langs, $conf, $user; |
|
36 | 36 | |
37 | - $tab = 0; |
|
38 | - $head = array(); |
|
37 | + $tab = 0; |
|
38 | + $head = array(); |
|
39 | 39 | |
40 | - $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id; |
|
41 | - $head[$tab][1] = $langs->trans("Card"); |
|
42 | - $head[$tab][2] = 'card'; |
|
43 | - $tab++; |
|
40 | + $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id; |
|
41 | + $head[$tab][1] = $langs->trans("Card"); |
|
42 | + $head[$tab][2] = 'card'; |
|
43 | + $tab++; |
|
44 | 44 | |
45 | - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
46 | - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) |
|
47 | - { |
|
48 | - $langs->load("ldap"); |
|
45 | + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
46 | + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) |
|
47 | + { |
|
48 | + $langs->load("ldap"); |
|
49 | 49 | |
50 | - $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id; |
|
51 | - $head[$tab][1] = $langs->trans("LDAPCard"); |
|
52 | - $head[$tab][2] = 'ldap'; |
|
53 | - $tab++; |
|
54 | - } |
|
50 | + $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id; |
|
51 | + $head[$tab][1] = $langs->trans("LDAPCard"); |
|
52 | + $head[$tab][2] = 'ldap'; |
|
53 | + $tab++; |
|
54 | + } |
|
55 | 55 | |
56 | - $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id; |
|
57 | - $head[$tab][1] = $langs->trans("PersonalInformations"); |
|
58 | - $head[$tab][2] = 'perso'; |
|
59 | - $tab++; |
|
56 | + $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id; |
|
57 | + $head[$tab][1] = $langs->trans("PersonalInformations"); |
|
58 | + $head[$tab][2] = 'perso'; |
|
59 | + $tab++; |
|
60 | 60 | |
61 | 61 | // Show more tabs from modules |
62 | 62 | // Entries must be declared in modules descriptor with line |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | $head[$tab][2] = 'info'; |
104 | 104 | $tab++;*/ |
105 | 105 | |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove'); |
|
106 | + complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove'); |
|
107 | 107 | |
108 | - return $head; |
|
108 | + return $head; |
|
109 | 109 | } |
110 | 110 |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $head[$tab][2] = 'card'; |
43 | 43 | $tab++; |
44 | 44 | |
45 | - if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
46 | - && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) |
|
45 | + if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
46 | + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) |
|
47 | 47 | { |
48 | 48 | $langs->load("ldap"); |
49 | 49 | |
@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | // Entries must be declared in modules descriptor with line |
63 | 63 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
64 | 64 | // $this->tabs = array('entity:-tabname); to remove a tab |
65 | - complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact'); |
|
65 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact'); |
|
66 | 66 | |
67 | 67 | // Notes |
68 | 68 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { |
69 | - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
|
69 | + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); |
|
70 | 70 | $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; |
71 | 71 | $head[$tab][1] = $langs->trans("Note"); |
72 | - if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + if ($nbNote > 0) $head[$tab][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
73 | 73 | $head[$tab][2] = 'note'; |
74 | 74 | $tab++; |
75 | 75 | } |
76 | 76 | |
77 | 77 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
78 | 78 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
79 | - $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref); |
|
80 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
81 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
79 | + $upload_dir = $conf->societe->dir_output."/contact/".dol_sanitizeFileName($object->ref); |
|
80 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
81 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
82 | 82 | $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id; |
83 | 83 | $head[$tab][1] = $langs->trans("Documents"); |
84 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
84 | + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
85 | 85 | $head[$tab][2] = 'documents'; |
86 | 86 | $tab++; |
87 | 87 | |
88 | 88 | // Agenda / Events |
89 | 89 | $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; |
90 | - $head[$tab][1].= $langs->trans("Events"); |
|
91 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
90 | + $head[$tab][1] .= $langs->trans("Events"); |
|
91 | + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
|
92 | 92 | { |
93 | - $head[$tab][1].= '/'; |
|
94 | - $head[$tab][1].= $langs->trans("Agenda"); |
|
93 | + $head[$tab][1] .= '/'; |
|
94 | + $head[$tab][1] .= $langs->trans("Agenda"); |
|
95 | 95 | } |
96 | 96 | $head[$tab][2] = 'agenda'; |
97 | 97 | $tab++; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $head[$tab][2] = 'info'; |
104 | 104 | $tab++;*/ |
105 | 105 | |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove'); |
|
106 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact', 'remove'); |
|
107 | 107 | |
108 | 108 | return $head; |
109 | 109 | } |
@@ -69,7 +69,9 @@ discard block |
||
69 | 69 | $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
70 | 70 | $head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id; |
71 | 71 | $head[$tab][1] = $langs->trans("Note"); |
72 | - if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + if($nbNote > 0) { |
|
73 | + $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + } |
|
73 | 75 | $head[$tab][2] = 'note'; |
74 | 76 | $tab++; |
75 | 77 | } |
@@ -81,7 +83,9 @@ discard block |
||
81 | 83 | $nbLinks=Link::count($db, $object->element, $object->id); |
82 | 84 | $head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id; |
83 | 85 | $head[$tab][1] = $langs->trans("Documents"); |
84 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
86 | + if (($nbFiles+$nbLinks) > 0) { |
|
87 | + $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
88 | + } |
|
85 | 89 | $head[$tab][2] = 'documents'; |
86 | 90 | $tab++; |
87 | 91 |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | $tab = 0; |
37 | 37 | $head = array(); |
38 | 38 | |
39 | - $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id; |
|
40 | - $head[$tab][1] = $langs->trans('Card'); |
|
41 | - $head[$tab][2] = 'card'; |
|
42 | - $tab++; |
|
39 | + $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id; |
|
40 | + $head[$tab][1] = $langs->trans('Card'); |
|
41 | + $head[$tab][2] = 'card'; |
|
42 | + $tab++; |
|
43 | 43 | |
44 | - $head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id; |
|
45 | - $head[$tab][1] = $langs->trans('FinancialCommitment'); |
|
46 | - $head[$tab][2] = 'FinancialCommitment'; |
|
47 | - $tab++; |
|
44 | + $head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id; |
|
45 | + $head[$tab][1] = $langs->trans('FinancialCommitment'); |
|
46 | + $head[$tab][2] = 'FinancialCommitment'; |
|
47 | + $tab++; |
|
48 | 48 | |
49 | 49 | // Show more tabs from modules |
50 | 50 | // Entries must be declared in modules descriptor with line |
@@ -52,26 +52,26 @@ discard block |
||
52 | 52 | // $this->tabs = array('entity:-tabname); to remove a tab |
53 | 53 | complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan'); |
54 | 54 | |
55 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
55 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
56 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
57 | - $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
58 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
57 | + $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
58 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
59 | 59 | $nbLinks=Link::count($db, $object->element, $object->id); |
60 | - $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; |
|
61 | - $head[$tab][1] = $langs->trans("Documents"); |
|
62 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
63 | - $head[$tab][2] = 'documents'; |
|
64 | - $tab++; |
|
60 | + $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; |
|
61 | + $head[$tab][1] = $langs->trans("Documents"); |
|
62 | + if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
63 | + $head[$tab][2] = 'documents'; |
|
64 | + $tab++; |
|
65 | 65 | |
66 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
67 | - { |
|
68 | - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
|
69 | - $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; |
|
70 | - $head[$tab][1] = $langs->trans("Notes"); |
|
71 | - if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | - $head[$tab][2] = 'note'; |
|
73 | - $tab++; |
|
74 | - } |
|
66 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
67 | + { |
|
68 | + $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
|
69 | + $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; |
|
70 | + $head[$tab][1] = $langs->trans("Notes"); |
|
71 | + if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + $head[$tab][2] = 'note'; |
|
73 | + $tab++; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id; |
77 | 77 | $head[$tab][1] = $langs->trans("Info"); |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | // Entries must be declared in modules descriptor with line |
51 | 51 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
52 | 52 | // $this->tabs = array('entity:-tabname); to remove a tab |
53 | - complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan'); |
|
53 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan'); |
|
54 | 54 | |
55 | 55 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
56 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
57 | - $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
58 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
59 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
57 | + $upload_dir = $conf->loan->dir_output."/".dol_sanitizeFileName($object->ref); |
|
58 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
59 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
60 | 60 | $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; |
61 | 61 | $head[$tab][1] = $langs->trans("Documents"); |
62 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
62 | + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
63 | 63 | $head[$tab][2] = 'documents'; |
64 | 64 | $tab++; |
65 | 65 | |
66 | 66 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
67 | 67 | { |
68 | - $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
|
68 | + $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1); |
|
69 | 69 | $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; |
70 | 70 | $head[$tab][1] = $langs->trans("Notes"); |
71 | - if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
71 | + if ($nbNote > 0) $head[$tab][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | 72 | $head[$tab][2] = 'note'; |
73 | 73 | $tab++; |
74 | 74 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $head[$tab][2] = 'info'; |
79 | 79 | $tab++; |
80 | 80 | |
81 | - complete_head_from_modules($conf,$langs,$object,$head,$tab,'loan','remove'); |
|
81 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove'); |
|
82 | 82 | |
83 | 83 | return $head; |
84 | 84 | } |
@@ -59,7 +59,9 @@ discard block |
||
59 | 59 | $nbLinks=Link::count($db, $object->element, $object->id); |
60 | 60 | $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id; |
61 | 61 | $head[$tab][1] = $langs->trans("Documents"); |
62 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
62 | + if (($nbFiles+$nbLinks) > 0) { |
|
63 | + $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
64 | + } |
|
63 | 65 | $head[$tab][2] = 'documents'; |
64 | 66 | $tab++; |
65 | 67 | |
@@ -68,7 +70,9 @@ discard block |
||
68 | 70 | $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1); |
69 | 71 | $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id; |
70 | 72 | $head[$tab][1] = $langs->trans("Notes"); |
71 | - if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
73 | + if($nbNote > 0) { |
|
74 | + $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
75 | + } |
|
72 | 76 | $head[$tab][2] = 'note'; |
73 | 77 | $tab++; |
74 | 78 | } |
@@ -74,24 +74,24 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function dol_getImageSize($file, $url = false) |
76 | 76 | { |
77 | - $ret=array(); |
|
77 | + $ret=array(); |
|
78 | 78 | |
79 | - if (image_format_supported($file) < 0) return $ret; |
|
79 | + if (image_format_supported($file) < 0) return $ret; |
|
80 | 80 | |
81 | - $filetoread = $file; |
|
82 | - if (!$url) |
|
83 | - { |
|
84 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | - } |
|
81 | + $filetoread = $file; |
|
82 | + if (!$url) |
|
83 | + { |
|
84 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | + } |
|
86 | 86 | |
87 | - if ($filetoread) |
|
88 | - { |
|
89 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
90 | - $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | - $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
92 | - } |
|
87 | + if ($filetoread) |
|
88 | + { |
|
89 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
90 | + $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | + $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
92 | + } |
|
93 | 93 | |
94 | - return $ret; |
|
94 | + return $ret; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -108,191 +108,191 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0) |
110 | 110 | { |
111 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
112 | - |
|
113 | - global $conf,$langs; |
|
114 | - |
|
115 | - dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
|
116 | - |
|
117 | - // Clean parameters |
|
118 | - $file=trim($file); |
|
119 | - |
|
120 | - // Check parameters |
|
121 | - if (! $file) |
|
122 | - { |
|
123 | - // Si le fichier n'a pas ete indique |
|
124 | - return 'Bad parameter file'; |
|
125 | - } |
|
126 | - elseif (! file_exists($file)) |
|
127 | - { |
|
128 | - // Si le fichier passe en parametre n'existe pas |
|
129 | - return $langs->trans("ErrorFileNotFound",$file); |
|
130 | - } |
|
131 | - elseif(image_format_supported($file) < 0) |
|
132 | - { |
|
133 | - return 'This filename '.$file.' does not seem to be an image filename.'; |
|
134 | - } |
|
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | - { |
|
137 | - return 'Wrong value for parameter newWidth or newHeight'; |
|
138 | - } |
|
139 | - elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | - { |
|
141 | - return 'At least newHeight or newWidth must be defined for resizing'; |
|
142 | - } |
|
143 | - elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | - { |
|
145 | - return 'Both newHeight or newWidth must be defined for croping'; |
|
146 | - } |
|
147 | - |
|
148 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | - |
|
150 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
151 | - $imgWidth = $infoImg[0]; // Largeur de l'image |
|
152 | - $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
153 | - |
|
154 | - if ($mode == 0) // If resize, we check parameters |
|
155 | - { |
|
156 | - if ($newWidth <= 0) |
|
157 | - { |
|
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | - } |
|
160 | - if ($newHeight <= 0) |
|
161 | - { |
|
162 | - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - $imgfonction=''; |
|
167 | - switch($infoImg[2]) |
|
168 | - { |
|
169 | - case 1: // IMG_GIF |
|
170 | - $imgfonction = 'imagecreatefromgif'; |
|
171 | - break; |
|
172 | - case 2: // IMG_JPG |
|
173 | - $imgfonction = 'imagecreatefromjpeg'; |
|
174 | - break; |
|
175 | - case 3: // IMG_PNG |
|
176 | - $imgfonction = 'imagecreatefrompng'; |
|
177 | - break; |
|
178 | - case 4: // IMG_WBMP |
|
179 | - $imgfonction = 'imagecreatefromwbmp'; |
|
180 | - break; |
|
181 | - } |
|
182 | - if ($imgfonction) |
|
183 | - { |
|
184 | - if (! function_exists($imgfonction)) |
|
185 | - { |
|
186 | - // Fonctions de conversion non presente dans ce PHP |
|
187 | - return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - // Initialisation des variables selon l'extension de l'image |
|
192 | - switch($infoImg[2]) |
|
193 | - { |
|
194 | - case 1: // Gif |
|
195 | - $img = imagecreatefromgif($filetoread); |
|
196 | - $extImg = '.gif'; // File name extension of image |
|
197 | - $newquality='NU'; // Quality is not used for this format |
|
198 | - break; |
|
199 | - case 2: // Jpg |
|
200 | - $img = imagecreatefromjpeg($filetoread); |
|
201 | - $extImg = '.jpg'; |
|
202 | - $newquality=100; // % quality maximum |
|
203 | - break; |
|
204 | - case 3: // Png |
|
205 | - $img = imagecreatefrompng($filetoread); |
|
206 | - $extImg = '.png'; |
|
207 | - $newquality=0; // No compression (0-9) |
|
208 | - break; |
|
209 | - case 4: // Bmp |
|
210 | - $img = imagecreatefromwbmp($filetoread); |
|
211 | - $extImg = '.bmp'; |
|
212 | - $newquality='NU'; // Quality is not used for this format |
|
213 | - break; |
|
214 | - } |
|
215 | - |
|
216 | - // Create empty image |
|
217 | - if ($infoImg[2] == 1) |
|
218 | - { |
|
219 | - // Compatibilite image GIF |
|
220 | - $imgThumb = imagecreate($newWidth, $newHeight); |
|
221 | - } |
|
222 | - else |
|
223 | - { |
|
224 | - $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
|
225 | - } |
|
226 | - |
|
227 | - // Activate antialiasing for better quality |
|
228 | - if (function_exists('imageantialias')) |
|
229 | - { |
|
230 | - imageantialias($imgThumb, true); |
|
231 | - } |
|
232 | - |
|
233 | - // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
234 | - if (function_exists('imagesavealpha')) |
|
235 | - { |
|
236 | - imagesavealpha($imgThumb, true); |
|
237 | - } |
|
238 | - |
|
239 | - // Initialisation des variables selon l'extension de l'image |
|
240 | - switch($infoImg[2]) |
|
241 | - { |
|
242 | - case 1: // Gif |
|
243 | - $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
244 | - imagecolortransparent($imgThumb,$trans_colour); |
|
245 | - break; |
|
246 | - case 2: // Jpg |
|
247 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
248 | - break; |
|
249 | - case 3: // Png |
|
250 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | - break; |
|
253 | - case 4: // Bmp |
|
254 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
255 | - break; |
|
256 | - } |
|
257 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
258 | - |
|
259 | - dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
|
260 | - //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
261 | - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
262 | - |
|
263 | - $imgThumbName = $file; |
|
264 | - |
|
265 | - // Check if permission are ok |
|
266 | - //$fp = fopen($imgThumbName, "w"); |
|
267 | - //fclose($fp); |
|
268 | - |
|
269 | - // Create image on disk |
|
270 | - switch($infoImg[2]) |
|
271 | - { |
|
272 | - case 1: // Gif |
|
273 | - imagegif($imgThumb, $imgThumbName); |
|
274 | - break; |
|
275 | - case 2: // Jpg |
|
276 | - imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
277 | - break; |
|
278 | - case 3: // Png |
|
279 | - imagepng($imgThumb, $imgThumbName, $newquality); |
|
280 | - break; |
|
281 | - case 4: // Bmp |
|
282 | - image2wbmp($imgThumb, $imgThumbName); |
|
283 | - break; |
|
284 | - } |
|
285 | - |
|
286 | - // Set permissions on file |
|
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | - |
|
289 | - // Free memory. This does not delete image. |
|
111 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
112 | + |
|
113 | + global $conf,$langs; |
|
114 | + |
|
115 | + dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
|
116 | + |
|
117 | + // Clean parameters |
|
118 | + $file=trim($file); |
|
119 | + |
|
120 | + // Check parameters |
|
121 | + if (! $file) |
|
122 | + { |
|
123 | + // Si le fichier n'a pas ete indique |
|
124 | + return 'Bad parameter file'; |
|
125 | + } |
|
126 | + elseif (! file_exists($file)) |
|
127 | + { |
|
128 | + // Si le fichier passe en parametre n'existe pas |
|
129 | + return $langs->trans("ErrorFileNotFound",$file); |
|
130 | + } |
|
131 | + elseif(image_format_supported($file) < 0) |
|
132 | + { |
|
133 | + return 'This filename '.$file.' does not seem to be an image filename.'; |
|
134 | + } |
|
135 | + elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | + { |
|
137 | + return 'Wrong value for parameter newWidth or newHeight'; |
|
138 | + } |
|
139 | + elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | + { |
|
141 | + return 'At least newHeight or newWidth must be defined for resizing'; |
|
142 | + } |
|
143 | + elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | + { |
|
145 | + return 'Both newHeight or newWidth must be defined for croping'; |
|
146 | + } |
|
147 | + |
|
148 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | + |
|
150 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
151 | + $imgWidth = $infoImg[0]; // Largeur de l'image |
|
152 | + $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
153 | + |
|
154 | + if ($mode == 0) // If resize, we check parameters |
|
155 | + { |
|
156 | + if ($newWidth <= 0) |
|
157 | + { |
|
158 | + $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | + } |
|
160 | + if ($newHeight <= 0) |
|
161 | + { |
|
162 | + $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + $imgfonction=''; |
|
167 | + switch($infoImg[2]) |
|
168 | + { |
|
169 | + case 1: // IMG_GIF |
|
170 | + $imgfonction = 'imagecreatefromgif'; |
|
171 | + break; |
|
172 | + case 2: // IMG_JPG |
|
173 | + $imgfonction = 'imagecreatefromjpeg'; |
|
174 | + break; |
|
175 | + case 3: // IMG_PNG |
|
176 | + $imgfonction = 'imagecreatefrompng'; |
|
177 | + break; |
|
178 | + case 4: // IMG_WBMP |
|
179 | + $imgfonction = 'imagecreatefromwbmp'; |
|
180 | + break; |
|
181 | + } |
|
182 | + if ($imgfonction) |
|
183 | + { |
|
184 | + if (! function_exists($imgfonction)) |
|
185 | + { |
|
186 | + // Fonctions de conversion non presente dans ce PHP |
|
187 | + return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + // Initialisation des variables selon l'extension de l'image |
|
192 | + switch($infoImg[2]) |
|
193 | + { |
|
194 | + case 1: // Gif |
|
195 | + $img = imagecreatefromgif($filetoread); |
|
196 | + $extImg = '.gif'; // File name extension of image |
|
197 | + $newquality='NU'; // Quality is not used for this format |
|
198 | + break; |
|
199 | + case 2: // Jpg |
|
200 | + $img = imagecreatefromjpeg($filetoread); |
|
201 | + $extImg = '.jpg'; |
|
202 | + $newquality=100; // % quality maximum |
|
203 | + break; |
|
204 | + case 3: // Png |
|
205 | + $img = imagecreatefrompng($filetoread); |
|
206 | + $extImg = '.png'; |
|
207 | + $newquality=0; // No compression (0-9) |
|
208 | + break; |
|
209 | + case 4: // Bmp |
|
210 | + $img = imagecreatefromwbmp($filetoread); |
|
211 | + $extImg = '.bmp'; |
|
212 | + $newquality='NU'; // Quality is not used for this format |
|
213 | + break; |
|
214 | + } |
|
215 | + |
|
216 | + // Create empty image |
|
217 | + if ($infoImg[2] == 1) |
|
218 | + { |
|
219 | + // Compatibilite image GIF |
|
220 | + $imgThumb = imagecreate($newWidth, $newHeight); |
|
221 | + } |
|
222 | + else |
|
223 | + { |
|
224 | + $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
|
225 | + } |
|
226 | + |
|
227 | + // Activate antialiasing for better quality |
|
228 | + if (function_exists('imageantialias')) |
|
229 | + { |
|
230 | + imageantialias($imgThumb, true); |
|
231 | + } |
|
232 | + |
|
233 | + // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
234 | + if (function_exists('imagesavealpha')) |
|
235 | + { |
|
236 | + imagesavealpha($imgThumb, true); |
|
237 | + } |
|
238 | + |
|
239 | + // Initialisation des variables selon l'extension de l'image |
|
240 | + switch($infoImg[2]) |
|
241 | + { |
|
242 | + case 1: // Gif |
|
243 | + $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
244 | + imagecolortransparent($imgThumb,$trans_colour); |
|
245 | + break; |
|
246 | + case 2: // Jpg |
|
247 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
248 | + break; |
|
249 | + case 3: // Png |
|
250 | + imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | + break; |
|
253 | + case 4: // Bmp |
|
254 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
255 | + break; |
|
256 | + } |
|
257 | + if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
258 | + |
|
259 | + dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
|
260 | + //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
261 | + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
262 | + |
|
263 | + $imgThumbName = $file; |
|
264 | + |
|
265 | + // Check if permission are ok |
|
266 | + //$fp = fopen($imgThumbName, "w"); |
|
267 | + //fclose($fp); |
|
268 | + |
|
269 | + // Create image on disk |
|
270 | + switch($infoImg[2]) |
|
271 | + { |
|
272 | + case 1: // Gif |
|
273 | + imagegif($imgThumb, $imgThumbName); |
|
274 | + break; |
|
275 | + case 2: // Jpg |
|
276 | + imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
277 | + break; |
|
278 | + case 3: // Png |
|
279 | + imagepng($imgThumb, $imgThumbName, $newquality); |
|
280 | + break; |
|
281 | + case 4: // Bmp |
|
282 | + image2wbmp($imgThumb, $imgThumbName); |
|
283 | + break; |
|
284 | + } |
|
285 | + |
|
286 | + // Set permissions on file |
|
287 | + if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | + |
|
289 | + // Free memory. This does not delete image. |
|
290 | 290 | imagedestroy($img); |
291 | - imagedestroy($imgThumb); |
|
291 | + imagedestroy($imgThumb); |
|
292 | 292 | |
293 | - clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
293 | + clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
294 | 294 | |
295 | - return $imgThumbName; |
|
295 | + return $imgThumbName; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -351,247 +351,247 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) |
353 | 353 | { |
354 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
354 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
355 | 355 | |
356 | - global $conf,$langs; |
|
356 | + global $conf,$langs; |
|
357 | 357 | |
358 | - dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
|
358 | + dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
|
359 | 359 | |
360 | - // Clean parameters |
|
361 | - $file=trim($file); |
|
360 | + // Clean parameters |
|
361 | + $file=trim($file); |
|
362 | 362 | |
363 | - // Check parameters |
|
364 | - if (! $file) |
|
365 | - { |
|
366 | - // Si le fichier n'a pas ete indique |
|
367 | - return 'ErrorBadParameters'; |
|
368 | - } |
|
369 | - elseif (! file_exists($file)) |
|
370 | - { |
|
371 | - // Si le fichier passe en parametre n'existe pas |
|
363 | + // Check parameters |
|
364 | + if (! $file) |
|
365 | + { |
|
366 | + // Si le fichier n'a pas ete indique |
|
367 | + return 'ErrorBadParameters'; |
|
368 | + } |
|
369 | + elseif (! file_exists($file)) |
|
370 | + { |
|
371 | + // Si le fichier passe en parametre n'existe pas |
|
372 | 372 | dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
373 | - return $langs->trans("ErrorFileNotFound",$file); |
|
374 | - } |
|
375 | - elseif(image_format_supported($file) < 0) |
|
376 | - { |
|
373 | + return $langs->trans("ErrorFileNotFound",$file); |
|
374 | + } |
|
375 | + elseif(image_format_supported($file) < 0) |
|
376 | + { |
|
377 | 377 | dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
378 | - return 'ErrorBadImageFormat'; |
|
379 | - } |
|
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | - // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
378 | + return 'ErrorBadImageFormat'; |
|
379 | + } |
|
380 | + elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | + // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
382 | 382 | dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
383 | - return 'Error: Wrong value for parameter maxWidth'; |
|
384 | - } |
|
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | - // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
383 | + return 'Error: Wrong value for parameter maxWidth'; |
|
384 | + } |
|
385 | + elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | + // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
387 | 387 | dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
388 | - return 'Error: Wrong value for parameter maxHeight'; |
|
389 | - } |
|
390 | - |
|
391 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | - |
|
393 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
394 | - $imgWidth = $infoImg[0]; // Largeur de l'image |
|
395 | - $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
396 | - |
|
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
399 | - |
|
400 | - // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
|
401 | - if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
|
402 | - { |
|
403 | - // On cree toujours les vignettes |
|
404 | - dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
405 | - //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
|
406 | - } |
|
407 | - |
|
408 | - $imgfonction=''; |
|
409 | - switch($infoImg[2]) |
|
410 | - { |
|
411 | - case IMAGETYPE_GIF: // 1 |
|
412 | - $imgfonction = 'imagecreatefromgif'; |
|
413 | - break; |
|
414 | - case IMAGETYPE_JPEG: // 2 |
|
415 | - $imgfonction = 'imagecreatefromjpeg'; |
|
416 | - break; |
|
417 | - case IMAGETYPE_PNG: // 3 |
|
418 | - $imgfonction = 'imagecreatefrompng'; |
|
419 | - break; |
|
420 | - case IMAGETYPE_BMP: // 6 |
|
388 | + return 'Error: Wrong value for parameter maxHeight'; |
|
389 | + } |
|
390 | + |
|
391 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | + |
|
393 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
394 | + $imgWidth = $infoImg[0]; // Largeur de l'image |
|
395 | + $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
396 | + |
|
397 | + if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | + if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
399 | + |
|
400 | + // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
|
401 | + if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
|
402 | + { |
|
403 | + // On cree toujours les vignettes |
|
404 | + dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
405 | + //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
|
406 | + } |
|
407 | + |
|
408 | + $imgfonction=''; |
|
409 | + switch($infoImg[2]) |
|
410 | + { |
|
411 | + case IMAGETYPE_GIF: // 1 |
|
412 | + $imgfonction = 'imagecreatefromgif'; |
|
413 | + break; |
|
414 | + case IMAGETYPE_JPEG: // 2 |
|
415 | + $imgfonction = 'imagecreatefromjpeg'; |
|
416 | + break; |
|
417 | + case IMAGETYPE_PNG: // 3 |
|
418 | + $imgfonction = 'imagecreatefrompng'; |
|
419 | + break; |
|
420 | + case IMAGETYPE_BMP: // 6 |
|
421 | 421 | // Not supported by PHP GD |
422 | - break; |
|
423 | - case IMAGETYPE_WBMP: // 15 |
|
424 | - $imgfonction = 'imagecreatefromwbmp'; |
|
425 | - break; |
|
426 | - } |
|
427 | - if ($imgfonction) |
|
428 | - { |
|
429 | - if (! function_exists($imgfonction)) |
|
430 | - { |
|
431 | - // Fonctions de conversion non presente dans ce PHP |
|
432 | - return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - // On cree le repertoire contenant les vignettes |
|
437 | - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
438 | - dol_mkdir($dirthumb); |
|
439 | - |
|
440 | - // Initialisation des variables selon l'extension de l'image |
|
441 | - $img=null; |
|
442 | - switch($infoImg[2]) |
|
443 | - { |
|
444 | - case IMAGETYPE_GIF: // 1 |
|
445 | - $img = imagecreatefromgif($filetoread); |
|
446 | - $extImg = '.gif'; // Extension de l'image |
|
447 | - break; |
|
448 | - case IMAGETYPE_JPEG: // 2 |
|
449 | - $img = imagecreatefromjpeg($filetoread); |
|
450 | - $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
451 | - break; |
|
452 | - case IMAGETYPE_PNG: // 3 |
|
453 | - $img = imagecreatefrompng($filetoread); |
|
454 | - $extImg = '.png'; |
|
455 | - break; |
|
456 | - case IMAGETYPE_BMP: // 6 |
|
422 | + break; |
|
423 | + case IMAGETYPE_WBMP: // 15 |
|
424 | + $imgfonction = 'imagecreatefromwbmp'; |
|
425 | + break; |
|
426 | + } |
|
427 | + if ($imgfonction) |
|
428 | + { |
|
429 | + if (! function_exists($imgfonction)) |
|
430 | + { |
|
431 | + // Fonctions de conversion non presente dans ce PHP |
|
432 | + return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + // On cree le repertoire contenant les vignettes |
|
437 | + $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
438 | + dol_mkdir($dirthumb); |
|
439 | + |
|
440 | + // Initialisation des variables selon l'extension de l'image |
|
441 | + $img=null; |
|
442 | + switch($infoImg[2]) |
|
443 | + { |
|
444 | + case IMAGETYPE_GIF: // 1 |
|
445 | + $img = imagecreatefromgif($filetoread); |
|
446 | + $extImg = '.gif'; // Extension de l'image |
|
447 | + break; |
|
448 | + case IMAGETYPE_JPEG: // 2 |
|
449 | + $img = imagecreatefromjpeg($filetoread); |
|
450 | + $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
451 | + break; |
|
452 | + case IMAGETYPE_PNG: // 3 |
|
453 | + $img = imagecreatefrompng($filetoread); |
|
454 | + $extImg = '.png'; |
|
455 | + break; |
|
456 | + case IMAGETYPE_BMP: // 6 |
|
457 | 457 | // Not supported by PHP GD |
458 | - $extImg = '.bmp'; |
|
459 | - break; |
|
460 | - case IMAGETYPE_WBMP: // 15 |
|
461 | - $img = imagecreatefromwbmp($filetoread); |
|
462 | - $extImg = '.bmp'; |
|
463 | - break; |
|
464 | - } |
|
458 | + $extImg = '.bmp'; |
|
459 | + break; |
|
460 | + case IMAGETYPE_WBMP: // 15 |
|
461 | + $img = imagecreatefromwbmp($filetoread); |
|
462 | + $extImg = '.bmp'; |
|
463 | + break; |
|
464 | + } |
|
465 | 465 | if (! is_resource($img)) |
466 | 466 | { |
467 | 467 | dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); |
468 | 468 | return 0; |
469 | 469 | } |
470 | 470 | |
471 | - // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
|
472 | - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
474 | - |
|
475 | - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | - |
|
478 | - // Fixe les dimensions de la vignette |
|
479 | - if($whFact < $imgWhFact) |
|
480 | - { |
|
481 | - // Si largeur determinante |
|
482 | - $thumbWidth = $maxWidth; |
|
483 | - $thumbHeight = $thumbWidth / $imgWhFact; |
|
484 | - } |
|
485 | - else |
|
486 | - { |
|
487 | - // Si hauteur determinante |
|
488 | - $thumbHeight = $maxHeight; |
|
489 | - $thumbWidth = $thumbHeight * $imgWhFact; |
|
490 | - } |
|
491 | - $thumbHeight=round($thumbHeight); |
|
492 | - $thumbWidth=round($thumbWidth); |
|
471 | + // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
|
472 | + if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | + if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
474 | + |
|
475 | + $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | + $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | + |
|
478 | + // Fixe les dimensions de la vignette |
|
479 | + if($whFact < $imgWhFact) |
|
480 | + { |
|
481 | + // Si largeur determinante |
|
482 | + $thumbWidth = $maxWidth; |
|
483 | + $thumbHeight = $thumbWidth / $imgWhFact; |
|
484 | + } |
|
485 | + else |
|
486 | + { |
|
487 | + // Si hauteur determinante |
|
488 | + $thumbHeight = $maxHeight; |
|
489 | + $thumbWidth = $thumbHeight * $imgWhFact; |
|
490 | + } |
|
491 | + $thumbHeight=round($thumbHeight); |
|
492 | + $thumbWidth=round($thumbWidth); |
|
493 | 493 | |
494 | 494 | // Define target format |
495 | 495 | if (empty($targetformat)) $targetformat=$infoImg[2]; |
496 | 496 | |
497 | - // Create empty image |
|
498 | - if ($targetformat == IMAGETYPE_GIF) |
|
499 | - { |
|
500 | - // Compatibilite image GIF |
|
501 | - $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
|
502 | - } |
|
503 | - else |
|
504 | - { |
|
505 | - $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
|
506 | - } |
|
507 | - |
|
508 | - // Activate antialiasing for better quality |
|
509 | - if (function_exists('imageantialias')) |
|
510 | - { |
|
511 | - imageantialias($imgThumb, true); |
|
512 | - } |
|
513 | - |
|
514 | - // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
515 | - if (function_exists('imagesavealpha')) |
|
516 | - { |
|
517 | - imagesavealpha($imgThumb, true); |
|
518 | - } |
|
519 | - |
|
520 | - // Initialisation des variables selon l'extension de l'image |
|
521 | - // $targetformat is 0 by default, in such case, we keep original extension |
|
522 | - switch($targetformat) |
|
523 | - { |
|
524 | - case IMAGETYPE_GIF: // 1 |
|
525 | - $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
526 | - imagecolortransparent($imgThumb,$trans_colour); |
|
497 | + // Create empty image |
|
498 | + if ($targetformat == IMAGETYPE_GIF) |
|
499 | + { |
|
500 | + // Compatibilite image GIF |
|
501 | + $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
|
502 | + } |
|
503 | + else |
|
504 | + { |
|
505 | + $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
|
506 | + } |
|
507 | + |
|
508 | + // Activate antialiasing for better quality |
|
509 | + if (function_exists('imageantialias')) |
|
510 | + { |
|
511 | + imageantialias($imgThumb, true); |
|
512 | + } |
|
513 | + |
|
514 | + // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
515 | + if (function_exists('imagesavealpha')) |
|
516 | + { |
|
517 | + imagesavealpha($imgThumb, true); |
|
518 | + } |
|
519 | + |
|
520 | + // Initialisation des variables selon l'extension de l'image |
|
521 | + // $targetformat is 0 by default, in such case, we keep original extension |
|
522 | + switch($targetformat) |
|
523 | + { |
|
524 | + case IMAGETYPE_GIF: // 1 |
|
525 | + $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
526 | + imagecolortransparent($imgThumb,$trans_colour); |
|
527 | 527 | $extImgTarget = '.gif'; |
528 | 528 | $newquality='NU'; |
529 | 529 | break; |
530 | - case IMAGETYPE_JPEG: // 2 |
|
530 | + case IMAGETYPE_JPEG: // 2 |
|
531 | 531 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
532 | 532 | $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg'); |
533 | 533 | $newquality=$quality; |
534 | 534 | break; |
535 | - case IMAGETYPE_PNG: // 3 |
|
536 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
535 | + case IMAGETYPE_PNG: // 3 |
|
536 | + imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
538 | 538 | $extImgTarget = '.png'; |
539 | 539 | $newquality=$quality-100; |
540 | 540 | $newquality=round(abs($quality-100)*9/100); |
541 | 541 | break; |
542 | - case IMAGETYPE_BMP: // 6 |
|
542 | + case IMAGETYPE_BMP: // 6 |
|
543 | 543 | // Not supported by PHP GD |
544 | 544 | $extImgTarget = '.bmp'; |
545 | 545 | $newquality='NU'; |
546 | 546 | break; |
547 | - case IMAGETYPE_WBMP: // 15 |
|
548 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
547 | + case IMAGETYPE_WBMP: // 15 |
|
548 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
549 | 549 | $extImgTarget = '.bmp'; |
550 | 550 | $newquality='NU'; |
551 | 551 | break; |
552 | - } |
|
553 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
554 | - |
|
555 | - dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
|
556 | - //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
557 | - imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
558 | - |
|
559 | - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
560 | - $fileName = basename($fileName); |
|
561 | - //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
|
562 | - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | - |
|
564 | - |
|
565 | - // Check if permission are ok |
|
566 | - //$fp = fopen($imgThumbName, "w"); |
|
567 | - //fclose($fp); |
|
568 | - |
|
569 | - // Create image on disk |
|
570 | - switch($targetformat) |
|
571 | - { |
|
572 | - case IMAGETYPE_GIF: // 1 |
|
573 | - imagegif($imgThumb, $imgThumbName); |
|
574 | - break; |
|
575 | - case IMAGETYPE_JPEG: // 2 |
|
576 | - imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
577 | - break; |
|
578 | - case IMAGETYPE_PNG: // 3 |
|
579 | - imagepng($imgThumb, $imgThumbName, $newquality); |
|
580 | - break; |
|
581 | - case IMAGETYPE_BMP: // 6 |
|
552 | + } |
|
553 | + if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
554 | + |
|
555 | + dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
|
556 | + //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
557 | + imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
558 | + |
|
559 | + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
560 | + $fileName = basename($fileName); |
|
561 | + //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
|
562 | + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | + |
|
564 | + |
|
565 | + // Check if permission are ok |
|
566 | + //$fp = fopen($imgThumbName, "w"); |
|
567 | + //fclose($fp); |
|
568 | + |
|
569 | + // Create image on disk |
|
570 | + switch($targetformat) |
|
571 | + { |
|
572 | + case IMAGETYPE_GIF: // 1 |
|
573 | + imagegif($imgThumb, $imgThumbName); |
|
574 | + break; |
|
575 | + case IMAGETYPE_JPEG: // 2 |
|
576 | + imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
577 | + break; |
|
578 | + case IMAGETYPE_PNG: // 3 |
|
579 | + imagepng($imgThumb, $imgThumbName, $newquality); |
|
580 | + break; |
|
581 | + case IMAGETYPE_BMP: // 6 |
|
582 | 582 | // Not supported by PHP GD |
583 | - break; |
|
584 | - case IMAGETYPE_WBMP: // 15 |
|
585 | - image2wbmp($imgThumb, $imgThumbName); |
|
586 | - break; |
|
587 | - } |
|
583 | + break; |
|
584 | + case IMAGETYPE_WBMP: // 15 |
|
585 | + image2wbmp($imgThumb, $imgThumbName); |
|
586 | + break; |
|
587 | + } |
|
588 | 588 | |
589 | - // Set permissions on file |
|
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
589 | + // Set permissions on file |
|
590 | + if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
591 | 591 | |
592 | 592 | // Free memory. This does not delete image. |
593 | 593 | imagedestroy($img); |
594 | 594 | imagedestroy($imgThumb); |
595 | 595 | |
596 | - return $imgThumbName; |
|
596 | + return $imgThumbName; |
|
597 | 597 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Define size of logo small and mini |
26 | -$maxwidthsmall=270;$maxheightsmall=150; |
|
27 | -$maxwidthmini=128;$maxheightmini=72; |
|
26 | +$maxwidthsmall = 270; $maxheightsmall = 150; |
|
27 | +$maxwidthmini = 128; $maxheightmini = 72; |
|
28 | 28 | $quality = 80; |
29 | 29 | |
30 | 30 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function image_format_supported($file) |
39 | 39 | { |
40 | - $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
|
40 | + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
|
41 | 41 | |
42 | 42 | // Case filename is not a format image |
43 | - if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; |
|
43 | + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; |
|
44 | 44 | |
45 | 45 | // Case filename is a format image but not supported by this PHP |
46 | - $imgfonction=''; |
|
46 | + $imgfonction = ''; |
|
47 | 47 | if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; |
48 | 48 | if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; |
49 | 49 | if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; |
54 | 54 | if ($imgfonction) |
55 | 55 | { |
56 | - if (! function_exists($imgfonction)) |
|
56 | + if (!function_exists($imgfonction)) |
|
57 | 57 | { |
58 | 58 | // Fonctions de conversion non presente dans ce PHP |
59 | 59 | return 0; |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function dol_getImageSize($file, $url = false) |
76 | 76 | { |
77 | - $ret=array(); |
|
77 | + $ret = array(); |
|
78 | 78 | |
79 | 79 | if (image_format_supported($file) < 0) return $ret; |
80 | 80 | |
81 | 81 | $filetoread = $file; |
82 | 82 | if (!$url) |
83 | 83 | { |
84 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
84 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | if ($filetoread) |
88 | 88 | { |
89 | 89 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
90 | - $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | - $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
90 | + $ret['width'] = $infoImg[0]; // Largeur de l'image |
|
91 | + $ret['height'] = $infoImg[1]; // Hauteur de l'image |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return $ret; |
@@ -106,33 +106,33 @@ discard block |
||
106 | 106 | * @param int $src_y Position of croping image in source image (not use if mode=0) |
107 | 107 | * @return int File name if OK, error message if KO |
108 | 108 | */ |
109 | -function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0) |
|
109 | +function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) |
|
110 | 110 | { |
111 | 111 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
112 | 112 | |
113 | - global $conf,$langs; |
|
113 | + global $conf, $langs; |
|
114 | 114 | |
115 | 115 | dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
116 | 116 | |
117 | 117 | // Clean parameters |
118 | - $file=trim($file); |
|
118 | + $file = trim($file); |
|
119 | 119 | |
120 | 120 | // Check parameters |
121 | - if (! $file) |
|
121 | + if (!$file) |
|
122 | 122 | { |
123 | 123 | // Si le fichier n'a pas ete indique |
124 | 124 | return 'Bad parameter file'; |
125 | 125 | } |
126 | - elseif (! file_exists($file)) |
|
126 | + elseif (!file_exists($file)) |
|
127 | 127 | { |
128 | 128 | // Si le fichier passe en parametre n'existe pas |
129 | - return $langs->trans("ErrorFileNotFound",$file); |
|
129 | + return $langs->trans("ErrorFileNotFound", $file); |
|
130 | 130 | } |
131 | - elseif(image_format_supported($file) < 0) |
|
131 | + elseif (image_format_supported($file) < 0) |
|
132 | 132 | { |
133 | 133 | return 'This filename '.$file.' does not seem to be an image filename.'; |
134 | 134 | } |
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
135 | + elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | 136 | { |
137 | 137 | return 'Wrong value for parameter newWidth or newHeight'; |
138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return 'Both newHeight or newWidth must be defined for croping'; |
146 | 146 | } |
147 | 147 | |
148 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
148 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | 149 | |
150 | 150 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
151 | 151 | $imgWidth = $infoImg[0]; // Largeur de l'image |
@@ -153,18 +153,18 @@ discard block |
||
153 | 153 | |
154 | 154 | if ($mode == 0) // If resize, we check parameters |
155 | 155 | { |
156 | - if ($newWidth <= 0) |
|
156 | + if ($newWidth <= 0) |
|
157 | 157 | { |
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
158 | + $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | 159 | } |
160 | 160 | if ($newHeight <= 0) |
161 | 161 | { |
162 | - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
162 | + $newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $imgfonction=''; |
|
167 | - switch($infoImg[2]) |
|
166 | + $imgfonction = ''; |
|
167 | + switch ($infoImg[2]) |
|
168 | 168 | { |
169 | 169 | case 1: // IMG_GIF |
170 | 170 | $imgfonction = 'imagecreatefromgif'; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | if ($imgfonction) |
183 | 183 | { |
184 | - if (! function_exists($imgfonction)) |
|
184 | + if (!function_exists($imgfonction)) |
|
185 | 185 | { |
186 | 186 | // Fonctions de conversion non presente dans ce PHP |
187 | 187 | return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
@@ -189,27 +189,27 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | // Initialisation des variables selon l'extension de l'image |
192 | - switch($infoImg[2]) |
|
192 | + switch ($infoImg[2]) |
|
193 | 193 | { |
194 | 194 | case 1: // Gif |
195 | 195 | $img = imagecreatefromgif($filetoread); |
196 | - $extImg = '.gif'; // File name extension of image |
|
197 | - $newquality='NU'; // Quality is not used for this format |
|
196 | + $extImg = '.gif'; // File name extension of image |
|
197 | + $newquality = 'NU'; // Quality is not used for this format |
|
198 | 198 | break; |
199 | 199 | case 2: // Jpg |
200 | 200 | $img = imagecreatefromjpeg($filetoread); |
201 | 201 | $extImg = '.jpg'; |
202 | - $newquality=100; // % quality maximum |
|
202 | + $newquality = 100; // % quality maximum |
|
203 | 203 | break; |
204 | 204 | case 3: // Png |
205 | 205 | $img = imagecreatefrompng($filetoread); |
206 | 206 | $extImg = '.png'; |
207 | - $newquality=0; // No compression (0-9) |
|
207 | + $newquality = 0; // No compression (0-9) |
|
208 | 208 | break; |
209 | 209 | case 4: // Bmp |
210 | 210 | $img = imagecreatefromwbmp($filetoread); |
211 | 211 | $extImg = '.bmp'; |
212 | - $newquality='NU'; // Quality is not used for this format |
|
212 | + $newquality = 'NU'; // Quality is not used for this format |
|
213 | 213 | break; |
214 | 214 | } |
215 | 215 | |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | // Initialisation des variables selon l'extension de l'image |
240 | - switch($infoImg[2]) |
|
240 | + switch ($infoImg[2]) |
|
241 | 241 | { |
242 | 242 | case 1: // Gif |
243 | 243 | $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
244 | - imagecolortransparent($imgThumb,$trans_colour); |
|
244 | + imagecolortransparent($imgThumb, $trans_colour); |
|
245 | 245 | break; |
246 | 246 | case 2: // Jpg |
247 | 247 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
248 | 248 | break; |
249 | 249 | case 3: // Png |
250 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
250 | + imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme |
|
251 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | 252 | break; |
253 | 253 | case 4: // Bmp |
254 | 254 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
260 | 260 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
261 | - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
261 | + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee |
|
262 | 262 | |
263 | 263 | $imgThumbName = $file; |
264 | 264 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | //fclose($fp); |
268 | 268 | |
269 | 269 | // Create image on disk |
270 | - switch($infoImg[2]) |
|
270 | + switch ($infoImg[2]) |
|
271 | 271 | { |
272 | 272 | case 1: // Gif |
273 | 273 | imagegif($imgThumb, $imgThumbName); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // Set permissions on file |
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
287 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | 288 | |
289 | 289 | // Free memory. This does not delete image. |
290 | 290 | imagedestroy($img); |
291 | 291 | imagedestroy($imgThumb); |
292 | 292 | |
293 | - clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
293 | + clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
294 | 294 | |
295 | 295 | return $imgThumbName; |
296 | 296 | } |
@@ -349,64 +349,64 @@ discard block |
||
349 | 349 | * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) |
350 | 350 | * @return string Full path of thumb or '' if it fails or 'Error...' if it fails |
351 | 351 | */ |
352 | -function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) |
|
352 | +function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0) |
|
353 | 353 | { |
354 | 354 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
355 | 355 | |
356 | - global $conf,$langs; |
|
356 | + global $conf, $langs; |
|
357 | 357 | |
358 | 358 | dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
359 | 359 | |
360 | 360 | // Clean parameters |
361 | - $file=trim($file); |
|
361 | + $file = trim($file); |
|
362 | 362 | |
363 | 363 | // Check parameters |
364 | - if (! $file) |
|
364 | + if (!$file) |
|
365 | 365 | { |
366 | 366 | // Si le fichier n'a pas ete indique |
367 | 367 | return 'ErrorBadParameters'; |
368 | 368 | } |
369 | - elseif (! file_exists($file)) |
|
369 | + elseif (!file_exists($file)) |
|
370 | 370 | { |
371 | 371 | // Si le fichier passe en parametre n'existe pas |
372 | - dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
|
373 | - return $langs->trans("ErrorFileNotFound",$file); |
|
372 | + dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); |
|
373 | + return $langs->trans("ErrorFileNotFound", $file); |
|
374 | 374 | } |
375 | - elseif(image_format_supported($file) < 0) |
|
375 | + elseif (image_format_supported($file) < 0) |
|
376 | 376 | { |
377 | - dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
|
377 | + dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); |
|
378 | 378 | return 'ErrorBadImageFormat'; |
379 | 379 | } |
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
380 | + elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { |
|
381 | 381 | // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
382 | - dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
|
382 | + dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); |
|
383 | 383 | return 'Error: Wrong value for parameter maxWidth'; |
384 | 384 | } |
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
385 | + elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { |
|
386 | 386 | // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
387 | - dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
|
387 | + dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); |
|
388 | 388 | return 'Error: Wrong value for parameter maxHeight'; |
389 | 389 | } |
390 | 390 | |
391 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
391 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | 392 | |
393 | 393 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
394 | 394 | $imgWidth = $infoImg[0]; // Largeur de l'image |
395 | 395 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
396 | 396 | |
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
397 | + if ($maxWidth == -1) $maxWidth = $infoImg[0]; // If size is -1, we keep unchanged |
|
398 | + if ($maxHeight == -1) $maxHeight = $infoImg[1]; // If size is -1, we keep unchanged |
|
399 | 399 | |
400 | 400 | // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
401 | 401 | if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
402 | 402 | { |
403 | 403 | // On cree toujours les vignettes |
404 | - dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
404 | + dol_syslog("File size is smaller than thumb size", LOG_DEBUG); |
|
405 | 405 | //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
406 | 406 | } |
407 | 407 | |
408 | - $imgfonction=''; |
|
409 | - switch($infoImg[2]) |
|
408 | + $imgfonction = ''; |
|
409 | + switch ($infoImg[2]) |
|
410 | 410 | { |
411 | 411 | case IMAGETYPE_GIF: // 1 |
412 | 412 | $imgfonction = 'imagecreatefromgif'; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | if ($imgfonction) |
428 | 428 | { |
429 | - if (! function_exists($imgfonction)) |
|
429 | + if (!function_exists($imgfonction)) |
|
430 | 430 | { |
431 | 431 | // Fonctions de conversion non presente dans ce PHP |
432 | 432 | return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
@@ -434,12 +434,12 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | // On cree le repertoire contenant les vignettes |
437 | - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
437 | + $dirthumb = dirname($file).($outdir ? '/'.$outdir : ''); // Chemin du dossier contenant les vignettes |
|
438 | 438 | dol_mkdir($dirthumb); |
439 | 439 | |
440 | 440 | // Initialisation des variables selon l'extension de l'image |
441 | - $img=null; |
|
442 | - switch($infoImg[2]) |
|
441 | + $img = null; |
|
442 | + switch ($infoImg[2]) |
|
443 | 443 | { |
444 | 444 | case IMAGETYPE_GIF: // 1 |
445 | 445 | $img = imagecreatefromgif($filetoread); |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | break; |
448 | 448 | case IMAGETYPE_JPEG: // 2 |
449 | 449 | $img = imagecreatefromjpeg($filetoread); |
450 | - $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
450 | + $extImg = (preg_match('/\.jpeg$/', $file) ? '.jpeg' : '.jpg'); // Extension de l'image |
|
451 | 451 | break; |
452 | 452 | case IMAGETYPE_PNG: // 3 |
453 | 453 | $img = imagecreatefrompng($filetoread); |
@@ -462,21 +462,21 @@ discard block |
||
462 | 462 | $extImg = '.bmp'; |
463 | 463 | break; |
464 | 464 | } |
465 | - if (! is_resource($img)) |
|
465 | + if (!is_resource($img)) |
|
466 | 466 | { |
467 | 467 | dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); |
468 | 468 | return 0; |
469 | 469 | } |
470 | 470 | |
471 | 471 | // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
472 | - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
472 | + if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; } |
|
473 | + if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; } |
|
474 | 474 | |
475 | - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
475 | + $whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | + $imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | 477 | |
478 | 478 | // Fixe les dimensions de la vignette |
479 | - if($whFact < $imgWhFact) |
|
479 | + if ($whFact < $imgWhFact) |
|
480 | 480 | { |
481 | 481 | // Si largeur determinante |
482 | 482 | $thumbWidth = $maxWidth; |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $thumbHeight = $maxHeight; |
489 | 489 | $thumbWidth = $thumbHeight * $imgWhFact; |
490 | 490 | } |
491 | - $thumbHeight=round($thumbHeight); |
|
492 | - $thumbWidth=round($thumbWidth); |
|
491 | + $thumbHeight = round($thumbHeight); |
|
492 | + $thumbWidth = round($thumbWidth); |
|
493 | 493 | |
494 | 494 | // Define target format |
495 | - if (empty($targetformat)) $targetformat=$infoImg[2]; |
|
495 | + if (empty($targetformat)) $targetformat = $infoImg[2]; |
|
496 | 496 | |
497 | 497 | // Create empty image |
498 | 498 | if ($targetformat == IMAGETYPE_GIF) |
@@ -519,35 +519,35 @@ discard block |
||
519 | 519 | |
520 | 520 | // Initialisation des variables selon l'extension de l'image |
521 | 521 | // $targetformat is 0 by default, in such case, we keep original extension |
522 | - switch($targetformat) |
|
522 | + switch ($targetformat) |
|
523 | 523 | { |
524 | 524 | case IMAGETYPE_GIF: // 1 |
525 | 525 | $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
526 | - imagecolortransparent($imgThumb,$trans_colour); |
|
526 | + imagecolortransparent($imgThumb, $trans_colour); |
|
527 | 527 | $extImgTarget = '.gif'; |
528 | - $newquality='NU'; |
|
528 | + $newquality = 'NU'; |
|
529 | 529 | break; |
530 | 530 | case IMAGETYPE_JPEG: // 2 |
531 | 531 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
532 | - $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg'); |
|
533 | - $newquality=$quality; |
|
532 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); |
|
533 | + $newquality = $quality; |
|
534 | 534 | break; |
535 | 535 | case IMAGETYPE_PNG: // 3 |
536 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
536 | + imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme |
|
537 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
538 | 538 | $extImgTarget = '.png'; |
539 | - $newquality=$quality-100; |
|
540 | - $newquality=round(abs($quality-100)*9/100); |
|
539 | + $newquality = $quality - 100; |
|
540 | + $newquality = round(abs($quality - 100) * 9 / 100); |
|
541 | 541 | break; |
542 | 542 | case IMAGETYPE_BMP: // 6 |
543 | 543 | // Not supported by PHP GD |
544 | 544 | $extImgTarget = '.bmp'; |
545 | - $newquality='NU'; |
|
545 | + $newquality = 'NU'; |
|
546 | 546 | break; |
547 | 547 | case IMAGETYPE_WBMP: // 15 |
548 | 548 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
549 | 549 | $extImgTarget = '.bmp'; |
550 | - $newquality='NU'; |
|
550 | + $newquality = 'NU'; |
|
551 | 551 | break; |
552 | 552 | } |
553 | 553 | if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
557 | 557 | imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
558 | 558 | |
559 | - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
559 | + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse |
|
560 | 560 | $fileName = basename($fileName); |
561 | 561 | //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
562 | - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
562 | + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | 563 | |
564 | 564 | |
565 | 565 | // Check if permission are ok |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | //fclose($fp); |
568 | 568 | |
569 | 569 | // Create image on disk |
570 | - switch($targetformat) |
|
570 | + switch ($targetformat) |
|
571 | 571 | { |
572 | 572 | case IMAGETYPE_GIF: // 1 |
573 | 573 | imagegif($imgThumb, $imgThumbName); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | // Set permissions on file |
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
590 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
591 | 591 | |
592 | 592 | // Free memory. This does not delete image. |
593 | 593 | imagedestroy($img); |
@@ -40,17 +40,33 @@ discard block |
||
40 | 40 | $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
41 | 41 | |
42 | 42 | // Case filename is not a format image |
43 | - if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; |
|
43 | + if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) { |
|
44 | + return -1; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | // Case filename is a format image but not supported by this PHP |
46 | 48 | $imgfonction=''; |
47 | - if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; |
|
48 | - if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; |
|
49 | - if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; |
|
50 | - if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; |
|
51 | - if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; |
|
52 | - if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; |
|
53 | - if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; |
|
49 | + if (strtolower($reg[1]) == '.gif') { |
|
50 | + $imgfonction = 'imagecreatefromgif'; |
|
51 | + } |
|
52 | + if (strtolower($reg[1]) == '.png') { |
|
53 | + $imgfonction = 'imagecreatefrompng'; |
|
54 | + } |
|
55 | + if (strtolower($reg[1]) == '.jpg') { |
|
56 | + $imgfonction = 'imagecreatefromjpeg'; |
|
57 | + } |
|
58 | + if (strtolower($reg[1]) == '.jpeg') { |
|
59 | + $imgfonction = 'imagecreatefromjpeg'; |
|
60 | + } |
|
61 | + if (strtolower($reg[1]) == '.bmp') { |
|
62 | + $imgfonction = 'imagecreatefromwbmp'; |
|
63 | + } |
|
64 | + if (strtolower($reg[1]) == '.xpm') { |
|
65 | + $imgfonction = 'imagecreatefromxpm'; |
|
66 | + } |
|
67 | + if (strtolower($reg[1]) == '.xbm') { |
|
68 | + $imgfonction = 'imagecreatefromxbm'; |
|
69 | + } |
|
54 | 70 | if ($imgfonction) |
55 | 71 | { |
56 | 72 | if (! function_exists($imgfonction)) |
@@ -76,7 +92,9 @@ discard block |
||
76 | 92 | { |
77 | 93 | $ret=array(); |
78 | 94 | |
79 | - if (image_format_supported($file) < 0) return $ret; |
|
95 | + if (image_format_supported($file) < 0) { |
|
96 | + return $ret; |
|
97 | + } |
|
80 | 98 | |
81 | 99 | $filetoread = $file; |
82 | 100 | if (!$url) |
@@ -122,25 +140,20 @@ discard block |
||
122 | 140 | { |
123 | 141 | // Si le fichier n'a pas ete indique |
124 | 142 | return 'Bad parameter file'; |
125 | - } |
|
126 | - elseif (! file_exists($file)) |
|
143 | + } elseif (! file_exists($file)) |
|
127 | 144 | { |
128 | 145 | // Si le fichier passe en parametre n'existe pas |
129 | 146 | return $langs->trans("ErrorFileNotFound",$file); |
130 | - } |
|
131 | - elseif(image_format_supported($file) < 0) |
|
147 | + } elseif(image_format_supported($file) < 0) |
|
132 | 148 | { |
133 | 149 | return 'This filename '.$file.' does not seem to be an image filename.'; |
134 | - } |
|
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
150 | + } elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | 151 | { |
137 | 152 | return 'Wrong value for parameter newWidth or newHeight'; |
138 | - } |
|
139 | - elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
153 | + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | 154 | { |
141 | 155 | return 'At least newHeight or newWidth must be defined for resizing'; |
142 | - } |
|
143 | - elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
156 | + } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | 157 | { |
145 | 158 | return 'Both newHeight or newWidth must be defined for croping'; |
146 | 159 | } |
@@ -151,11 +164,14 @@ discard block |
||
151 | 164 | $imgWidth = $infoImg[0]; // Largeur de l'image |
152 | 165 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
153 | 166 | |
154 | - if ($mode == 0) // If resize, we check parameters |
|
167 | + if ($mode == 0) { |
|
168 | + // If resize, we check parameters |
|
155 | 169 | { |
156 | 170 | if ($newWidth <= 0) |
157 | 171 | { |
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
172 | + $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); |
|
173 | + } |
|
174 | + // Keep ratio |
|
159 | 175 | } |
160 | 176 | if ($newHeight <= 0) |
161 | 177 | { |
@@ -218,8 +234,7 @@ discard block |
||
218 | 234 | { |
219 | 235 | // Compatibilite image GIF |
220 | 236 | $imgThumb = imagecreate($newWidth, $newHeight); |
221 | - } |
|
222 | - else |
|
237 | + } else |
|
223 | 238 | { |
224 | 239 | $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
225 | 240 | } |
@@ -254,7 +269,9 @@ discard block |
||
254 | 269 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
255 | 270 | break; |
256 | 271 | } |
257 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
272 | + if (function_exists("imagefill")) { |
|
273 | + imagefill($imgThumb, 0, 0, $trans_colour); |
|
274 | + } |
|
258 | 275 | |
259 | 276 | dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
260 | 277 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
@@ -284,7 +301,9 @@ discard block |
||
284 | 301 | } |
285 | 302 | |
286 | 303 | // Set permissions on file |
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
304 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
305 | + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
306 | + } |
|
288 | 307 | |
289 | 308 | // Free memory. This does not delete image. |
290 | 309 | imagedestroy($img); |
@@ -365,24 +384,20 @@ discard block |
||
365 | 384 | { |
366 | 385 | // Si le fichier n'a pas ete indique |
367 | 386 | return 'ErrorBadParameters'; |
368 | - } |
|
369 | - elseif (! file_exists($file)) |
|
387 | + } elseif (! file_exists($file)) |
|
370 | 388 | { |
371 | 389 | // Si le fichier passe en parametre n'existe pas |
372 | 390 | dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
373 | 391 | return $langs->trans("ErrorFileNotFound",$file); |
374 | - } |
|
375 | - elseif(image_format_supported($file) < 0) |
|
392 | + } elseif(image_format_supported($file) < 0) |
|
376 | 393 | { |
377 | 394 | dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
378 | 395 | return 'ErrorBadImageFormat'; |
379 | - } |
|
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
396 | + } elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | 397 | // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
382 | 398 | dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
383 | 399 | return 'Error: Wrong value for parameter maxWidth'; |
384 | - } |
|
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
400 | + } elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | 401 | // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
387 | 402 | dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
388 | 403 | return 'Error: Wrong value for parameter maxHeight'; |
@@ -394,8 +409,14 @@ discard block |
||
394 | 409 | $imgWidth = $infoImg[0]; // Largeur de l'image |
395 | 410 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
396 | 411 | |
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
412 | + if ($maxWidth == -1) { |
|
413 | + $maxWidth=$infoImg[0]; |
|
414 | + } |
|
415 | + // If size is -1, we keep unchanged |
|
416 | + if ($maxHeight == -1) { |
|
417 | + $maxHeight=$infoImg[1]; |
|
418 | + } |
|
419 | + // If size is -1, we keep unchanged |
|
399 | 420 | |
400 | 421 | // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
401 | 422 | if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
@@ -481,8 +502,7 @@ discard block |
||
481 | 502 | // Si largeur determinante |
482 | 503 | $thumbWidth = $maxWidth; |
483 | 504 | $thumbHeight = $thumbWidth / $imgWhFact; |
484 | - } |
|
485 | - else |
|
505 | + } else |
|
486 | 506 | { |
487 | 507 | // Si hauteur determinante |
488 | 508 | $thumbHeight = $maxHeight; |
@@ -492,15 +512,16 @@ discard block |
||
492 | 512 | $thumbWidth=round($thumbWidth); |
493 | 513 | |
494 | 514 | // Define target format |
495 | - if (empty($targetformat)) $targetformat=$infoImg[2]; |
|
515 | + if (empty($targetformat)) { |
|
516 | + $targetformat=$infoImg[2]; |
|
517 | + } |
|
496 | 518 | |
497 | 519 | // Create empty image |
498 | 520 | if ($targetformat == IMAGETYPE_GIF) |
499 | 521 | { |
500 | 522 | // Compatibilite image GIF |
501 | 523 | $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
502 | - } |
|
503 | - else |
|
524 | + } else |
|
504 | 525 | { |
505 | 526 | $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
506 | 527 | } |
@@ -550,7 +571,9 @@ discard block |
||
550 | 571 | $newquality='NU'; |
551 | 572 | break; |
552 | 573 | } |
553 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
574 | + if (function_exists("imagefill")) { |
|
575 | + imagefill($imgThumb, 0, 0, $trans_colour); |
|
576 | + } |
|
554 | 577 | |
555 | 578 | dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
556 | 579 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
@@ -587,7 +610,9 @@ discard block |
||
587 | 610 | } |
588 | 611 | |
589 | 612 | // Set permissions on file |
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
613 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
614 | + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
615 | + } |
|
591 | 616 | |
592 | 617 | // Free memory. This does not delete image. |
593 | 618 | imagedestroy($img); |
@@ -34,80 +34,80 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function shipping_prepare_head($object) |
36 | 36 | { |
37 | - global $db, $langs, $conf, $user; |
|
37 | + global $db, $langs, $conf, $user; |
|
38 | 38 | |
39 | - // Load translation files required by the page |
|
39 | + // Load translation files required by the page |
|
40 | 40 | $langs->loadLangs(array("sendings","deliveries")); |
41 | 41 | |
42 | - $h = 0; |
|
43 | - $head = array(); |
|
44 | - |
|
45 | - $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id; |
|
46 | - $head[$h][1] = $langs->trans("SendingCard"); |
|
47 | - $head[$h][2] = 'shipping'; |
|
48 | - $h++; |
|
49 | - |
|
50 | - if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
|
51 | - { |
|
52 | - // delivery link |
|
53 | - $object->fetchObjectLinked($object->id,$object->element); |
|
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | - { |
|
56 | - // Take first one element of array |
|
57 | - $tmp = reset($object->linkedObjectsIds['delivery']); |
|
58 | - |
|
59 | - $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
|
60 | - $head[$h][1] = $langs->trans("DeliveryCard"); |
|
61 | - $head[$h][2] = 'delivery'; |
|
62 | - $h++; |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
67 | - { |
|
68 | - $objectsrc = $object; |
|
69 | - if ($object->origin == 'commande' && $object->origin_id > 0) |
|
70 | - { |
|
71 | - $objectsrc = new Commande($db); |
|
72 | - $objectsrc->fetch($object->origin_id); |
|
73 | - } |
|
74 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
75 | - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
|
76 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | - $head[$h][2] = 'contact'; |
|
79 | - $h++; |
|
80 | - } |
|
81 | - |
|
82 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
42 | + $h = 0; |
|
43 | + $head = array(); |
|
44 | + |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id; |
|
46 | + $head[$h][1] = $langs->trans("SendingCard"); |
|
47 | + $head[$h][2] = 'shipping'; |
|
48 | + $h++; |
|
49 | + |
|
50 | + if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
|
51 | + { |
|
52 | + // delivery link |
|
53 | + $object->fetchObjectLinked($object->id,$object->element); |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | + { |
|
56 | + // Take first one element of array |
|
57 | + $tmp = reset($object->linkedObjectsIds['delivery']); |
|
58 | + |
|
59 | + $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
|
60 | + $head[$h][1] = $langs->trans("DeliveryCard"); |
|
61 | + $head[$h][2] = 'delivery'; |
|
62 | + $h++; |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
67 | + { |
|
68 | + $objectsrc = $object; |
|
69 | + if ($object->origin == 'commande' && $object->origin_id > 0) |
|
70 | + { |
|
71 | + $objectsrc = new Commande($db); |
|
72 | + $objectsrc->fetch($object->origin_id); |
|
73 | + } |
|
74 | + $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
75 | + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
|
76 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
77 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | + $head[$h][2] = 'contact'; |
|
79 | + $h++; |
|
80 | + } |
|
81 | + |
|
82 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
84 | - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
84 | + $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
86 | 86 | $nbLinks=Link::count($db, $object->element, $object->id); |
87 | - $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
|
88 | - $head[$h][1] = $langs->trans('Documents'); |
|
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
90 | - $head[$h][2] = 'documents'; |
|
91 | - $h++; |
|
87 | + $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
|
88 | + $head[$h][1] = $langs->trans('Documents'); |
|
89 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
90 | + $head[$h][2] = 'documents'; |
|
91 | + $h++; |
|
92 | 92 | |
93 | 93 | $nbNote = 0; |
94 | 94 | if (!empty($object->note_private)) $nbNote++; |
95 | 95 | if (!empty($object->note_public)) $nbNote++; |
96 | - $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
|
97 | - $head[$h][1] = $langs->trans("Notes"); |
|
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | - $head[$h][2] = 'note'; |
|
100 | - $h++; |
|
101 | - |
|
102 | - // Show more tabs from modules |
|
103 | - // Entries must be declared in modules descriptor with line |
|
96 | + $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
|
97 | + $head[$h][1] = $langs->trans("Notes"); |
|
98 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | + $head[$h][2] = 'note'; |
|
100 | + $h++; |
|
101 | + |
|
102 | + // Show more tabs from modules |
|
103 | + // Entries must be declared in modules descriptor with line |
|
104 | 104 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
105 | 105 | // $this->tabs = array('entity:-tabname); to remove a tab |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
106 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
107 | 107 | |
108 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
108 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
109 | 109 | |
110 | - return $head; |
|
110 | + return $head; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -119,39 +119,39 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function delivery_prepare_head($object) |
121 | 121 | { |
122 | - global $langs, $conf, $user; |
|
122 | + global $langs, $conf, $user; |
|
123 | 123 | |
124 | - // Load translation files required by the page |
|
124 | + // Load translation files required by the page |
|
125 | 125 | $langs->loadLangs(array("sendings","deliveries")); |
126 | 126 | |
127 | - $h = 0; |
|
128 | - $head = array(); |
|
129 | - |
|
130 | - if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
131 | - { |
|
132 | - $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; |
|
133 | - $head[$h][1] = $langs->trans("SendingCard"); |
|
134 | - $head[$h][2] = 'shipping'; |
|
135 | - $h++; |
|
136 | - } |
|
137 | - |
|
138 | - $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id; |
|
139 | - $head[$h][1] = $langs->trans("DeliveryCard"); |
|
140 | - $head[$h][2] = 'delivery'; |
|
141 | - $h++; |
|
142 | - |
|
143 | - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id; |
|
144 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
145 | - $head[$h][2] = 'contact'; |
|
146 | - $h++; |
|
147 | - |
|
148 | - $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id; |
|
149 | - $head[$h][1] = $langs->trans("Notes"); |
|
150 | - $head[$h][2] = 'note'; |
|
151 | - $h++; |
|
152 | - |
|
153 | - // Show more tabs from modules |
|
154 | - // Entries must be declared in modules descriptor with line |
|
127 | + $h = 0; |
|
128 | + $head = array(); |
|
129 | + |
|
130 | + if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
131 | + { |
|
132 | + $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; |
|
133 | + $head[$h][1] = $langs->trans("SendingCard"); |
|
134 | + $head[$h][2] = 'shipping'; |
|
135 | + $h++; |
|
136 | + } |
|
137 | + |
|
138 | + $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id; |
|
139 | + $head[$h][1] = $langs->trans("DeliveryCard"); |
|
140 | + $head[$h][2] = 'delivery'; |
|
141 | + $h++; |
|
142 | + |
|
143 | + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id; |
|
144 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
145 | + $head[$h][2] = 'contact'; |
|
146 | + $h++; |
|
147 | + |
|
148 | + $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id; |
|
149 | + $head[$h][1] = $langs->trans("Notes"); |
|
150 | + $head[$h][2] = 'note'; |
|
151 | + $h++; |
|
152 | + |
|
153 | + // Show more tabs from modules |
|
154 | + // Entries must be declared in modules descriptor with line |
|
155 | 155 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
156 | 156 | // $this->tabs = array('entity:-tabname); to remove a tab |
157 | 157 | // complete_head_from_modules use $object->id for this link so we temporary change it |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | |
161 | 161 | complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
162 | 162 | |
163 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
163 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
164 | 164 | |
165 | - $object->id = $tmpObjectId; |
|
166 | - return $head; |
|
165 | + $object->id = $tmpObjectId; |
|
166 | + return $head; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -176,179 +176,179 @@ discard block |
||
176 | 176 | */ |
177 | 177 | function show_list_sending_receive($origin,$origin_id,$filter='') |
178 | 178 | { |
179 | - global $db, $conf, $langs, $bc; |
|
180 | - global $form; |
|
181 | - |
|
182 | - $product_static=new Product($db); |
|
183 | - $expedition=new Expedition($db); |
|
184 | - $warehousestatic=new Entrepot($db); |
|
185 | - |
|
186 | - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
|
187 | - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | - //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
|
190 | - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | - $sql.= ' p.description as product_desc'; |
|
192 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | - //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
|
196 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | - //TODO Add link to expeditiondet_batch |
|
198 | - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | - $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | - $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | - $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | - if ($filter) $sql.= $filter; |
|
203 | - |
|
204 | - $sql.= " ORDER BY obj.fk_product"; |
|
205 | - |
|
206 | - dol_syslog("show_list_sending_receive", LOG_DEBUG); |
|
207 | - $resql = $db->query($sql); |
|
208 | - if ($resql) |
|
209 | - { |
|
210 | - $num = $db->num_rows($resql); |
|
211 | - $i = 0; |
|
212 | - |
|
213 | - if ($num) |
|
214 | - { |
|
215 | - if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | - else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
217 | - |
|
218 | - print '<table class="liste" width="100%">'; |
|
219 | - print '<tr class="liste_titre">'; |
|
220 | - //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>'; |
|
221 | - print '<td align="left">'.$langs->trans("SendingSheet").'</td>'; |
|
222 | - print '<td align="left">'.$langs->trans("Description").'</td>'; |
|
223 | - print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
|
224 | - print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
|
225 | - print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
|
226 | - if (! empty($conf->stock->enabled)) |
|
227 | - { |
|
179 | + global $db, $conf, $langs, $bc; |
|
180 | + global $form; |
|
181 | + |
|
182 | + $product_static=new Product($db); |
|
183 | + $expedition=new Expedition($db); |
|
184 | + $warehousestatic=new Entrepot($db); |
|
185 | + |
|
186 | + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
|
187 | + $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | + $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | + //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
|
190 | + $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | + $sql.= ' p.description as product_desc'; |
|
192 | + $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | + $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | + $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | + //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
|
196 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | + //TODO Add link to expeditiondet_batch |
|
198 | + $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | + $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | + $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | + $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | + if ($filter) $sql.= $filter; |
|
203 | + |
|
204 | + $sql.= " ORDER BY obj.fk_product"; |
|
205 | + |
|
206 | + dol_syslog("show_list_sending_receive", LOG_DEBUG); |
|
207 | + $resql = $db->query($sql); |
|
208 | + if ($resql) |
|
209 | + { |
|
210 | + $num = $db->num_rows($resql); |
|
211 | + $i = 0; |
|
212 | + |
|
213 | + if ($num) |
|
214 | + { |
|
215 | + if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | + else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
217 | + |
|
218 | + print '<table class="liste" width="100%">'; |
|
219 | + print '<tr class="liste_titre">'; |
|
220 | + //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>'; |
|
221 | + print '<td align="left">'.$langs->trans("SendingSheet").'</td>'; |
|
222 | + print '<td align="left">'.$langs->trans("Description").'</td>'; |
|
223 | + print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
|
224 | + print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
|
225 | + print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
|
226 | + if (! empty($conf->stock->enabled)) |
|
227 | + { |
|
228 | 228 | print '<td>'.$langs->trans("Warehouse").'</td>'; |
229 | - } |
|
230 | - /*TODO Add link to expeditiondet_batch |
|
229 | + } |
|
230 | + /*TODO Add link to expeditiondet_batch |
|
231 | 231 | if (! empty($conf->productbatch->enabled)) |
232 | 232 | { |
233 | 233 | print '<td>'; |
234 | 234 | print '</td>'; |
235 | 235 | }*/ |
236 | - if (! empty($conf->livraison_bon->enabled)) |
|
237 | - { |
|
238 | - print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
|
239 | - //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
|
240 | - print '<td align="right">'.$langs->trans("DeliveryDate").'</td>'; |
|
241 | - } |
|
242 | - print "</tr>\n"; |
|
243 | - |
|
244 | - while ($i < $num) |
|
245 | - { |
|
246 | - $objp = $db->fetch_object($resql); |
|
247 | - |
|
248 | - print '<tr class="oddeven">'; |
|
249 | - |
|
250 | - // Sending id |
|
251 | - print '<td align="left" class="nowrap">'; |
|
252 | - print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | - print '</td>'; |
|
254 | - |
|
255 | - // Description |
|
256 | - if ($objp->fk_product > 0) |
|
257 | - { |
|
258 | - // Define output language |
|
259 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | - { |
|
261 | - $object = new $origin($db); |
|
262 | - $object->fetch($origin_id); |
|
263 | - $object->fetch_thirdparty(); |
|
264 | - |
|
265 | - $prod = new Product($db); |
|
266 | - $prod->id=$objp->fk_product; |
|
267 | - $prod->getMultiLangs(); |
|
268 | - |
|
269 | - $outputlangs = $langs; |
|
270 | - $newlang=''; |
|
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | - if (! empty($newlang)) |
|
274 | - { |
|
275 | - $outputlangs = new Translate("",$conf); |
|
276 | - $outputlangs->setDefaultLang($newlang); |
|
277 | - } |
|
278 | - |
|
279 | - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | - } |
|
281 | - else |
|
282 | - { |
|
283 | - $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
284 | - } |
|
285 | - |
|
286 | - print '<td>'; |
|
287 | - |
|
288 | - // Show product and description |
|
289 | - $product_static->type=$objp->fk_product_type; |
|
290 | - $product_static->id=$objp->fk_product; |
|
291 | - $product_static->ref=$objp->ref; |
|
292 | - $product_static->status_batch=$objp->product_tobatch; |
|
293 | - $text=$product_static->getNomUrl(1); |
|
294 | - $text.= ' - '.$label; |
|
295 | - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | - print $form->textwithtooltip($text,$description,3,'','',$i); |
|
297 | - |
|
298 | - // Show range |
|
299 | - print_date_range($objp->date_start,$objp->date_end); |
|
300 | - |
|
301 | - // Add description in form |
|
302 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | - { |
|
304 | - print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
305 | - } |
|
306 | - |
|
307 | - print '</td>'; |
|
308 | - } |
|
309 | - else |
|
310 | - { |
|
311 | - print "<td>"; |
|
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
314 | - |
|
315 | - if (! empty($objp->label)) { |
|
316 | - $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | - print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
318 | - } else { |
|
319 | - print $text.' '.nl2br($objp->description); |
|
320 | - } |
|
321 | - |
|
322 | - // Show range |
|
323 | - print_date_range($objp->date_start,$objp->date_end); |
|
324 | - print "</td>\n"; |
|
325 | - } |
|
326 | - |
|
327 | - //print '<td align="center">'.$objp->qty_asked.'</td>'; |
|
328 | - |
|
329 | - // Date creation |
|
330 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
331 | - |
|
332 | - // Date shipping creation |
|
333 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
334 | - |
|
335 | - // Qty shipped |
|
336 | - print '<td align="center">'.$objp->qty_shipped.'</td>'; |
|
337 | - |
|
338 | - // Warehouse |
|
339 | - if (! empty($conf->stock->enabled)) |
|
340 | - { |
|
341 | - print '<td>'; |
|
342 | - if ($objp->warehouse_id > 0) |
|
343 | - { |
|
344 | - $warehousestatic->fetch($objp->warehouse_id); |
|
345 | - print $warehousestatic->getNomUrl(1); |
|
346 | - } |
|
347 | - print '</td>'; |
|
348 | - } |
|
349 | - |
|
350 | - // Batch number managment |
|
351 | - /*TODO Add link to expeditiondet_batch |
|
236 | + if (! empty($conf->livraison_bon->enabled)) |
|
237 | + { |
|
238 | + print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
|
239 | + //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
|
240 | + print '<td align="right">'.$langs->trans("DeliveryDate").'</td>'; |
|
241 | + } |
|
242 | + print "</tr>\n"; |
|
243 | + |
|
244 | + while ($i < $num) |
|
245 | + { |
|
246 | + $objp = $db->fetch_object($resql); |
|
247 | + |
|
248 | + print '<tr class="oddeven">'; |
|
249 | + |
|
250 | + // Sending id |
|
251 | + print '<td align="left" class="nowrap">'; |
|
252 | + print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | + print '</td>'; |
|
254 | + |
|
255 | + // Description |
|
256 | + if ($objp->fk_product > 0) |
|
257 | + { |
|
258 | + // Define output language |
|
259 | + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | + { |
|
261 | + $object = new $origin($db); |
|
262 | + $object->fetch($origin_id); |
|
263 | + $object->fetch_thirdparty(); |
|
264 | + |
|
265 | + $prod = new Product($db); |
|
266 | + $prod->id=$objp->fk_product; |
|
267 | + $prod->getMultiLangs(); |
|
268 | + |
|
269 | + $outputlangs = $langs; |
|
270 | + $newlang=''; |
|
271 | + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | + if (! empty($newlang)) |
|
274 | + { |
|
275 | + $outputlangs = new Translate("",$conf); |
|
276 | + $outputlangs->setDefaultLang($newlang); |
|
277 | + } |
|
278 | + |
|
279 | + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | + } |
|
281 | + else |
|
282 | + { |
|
283 | + $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
284 | + } |
|
285 | + |
|
286 | + print '<td>'; |
|
287 | + |
|
288 | + // Show product and description |
|
289 | + $product_static->type=$objp->fk_product_type; |
|
290 | + $product_static->id=$objp->fk_product; |
|
291 | + $product_static->ref=$objp->ref; |
|
292 | + $product_static->status_batch=$objp->product_tobatch; |
|
293 | + $text=$product_static->getNomUrl(1); |
|
294 | + $text.= ' - '.$label; |
|
295 | + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | + print $form->textwithtooltip($text,$description,3,'','',$i); |
|
297 | + |
|
298 | + // Show range |
|
299 | + print_date_range($objp->date_start,$objp->date_end); |
|
300 | + |
|
301 | + // Add description in form |
|
302 | + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | + { |
|
304 | + print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
305 | + } |
|
306 | + |
|
307 | + print '</td>'; |
|
308 | + } |
|
309 | + else |
|
310 | + { |
|
311 | + print "<td>"; |
|
312 | + if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | + else $text = img_object($langs->trans('Product'),'product'); |
|
314 | + |
|
315 | + if (! empty($objp->label)) { |
|
316 | + $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | + print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
318 | + } else { |
|
319 | + print $text.' '.nl2br($objp->description); |
|
320 | + } |
|
321 | + |
|
322 | + // Show range |
|
323 | + print_date_range($objp->date_start,$objp->date_end); |
|
324 | + print "</td>\n"; |
|
325 | + } |
|
326 | + |
|
327 | + //print '<td align="center">'.$objp->qty_asked.'</td>'; |
|
328 | + |
|
329 | + // Date creation |
|
330 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
331 | + |
|
332 | + // Date shipping creation |
|
333 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
334 | + |
|
335 | + // Qty shipped |
|
336 | + print '<td align="center">'.$objp->qty_shipped.'</td>'; |
|
337 | + |
|
338 | + // Warehouse |
|
339 | + if (! empty($conf->stock->enabled)) |
|
340 | + { |
|
341 | + print '<td>'; |
|
342 | + if ($objp->warehouse_id > 0) |
|
343 | + { |
|
344 | + $warehousestatic->fetch($objp->warehouse_id); |
|
345 | + print $warehousestatic->getNomUrl(1); |
|
346 | + } |
|
347 | + print '</td>'; |
|
348 | + } |
|
349 | + |
|
350 | + // Batch number managment |
|
351 | + /*TODO Add link to expeditiondet_batch |
|
352 | 352 | if (! empty($conf->productbatch->enabled)) |
353 | 353 | { |
354 | 354 | var_dump($objp->edrowid); |
@@ -379,60 +379,60 @@ discard block |
||
379 | 379 | } |
380 | 380 | }*/ |
381 | 381 | |
382 | - // Informations on receipt |
|
383 | - if (! empty($conf->livraison_bon->enabled)) |
|
384 | - { |
|
385 | - include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
|
386 | - $expedition->id=$objp->sendingid; |
|
387 | - $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
388 | - //var_dump($expedition->linkedObjects); |
|
389 | - |
|
390 | - $receiving=''; |
|
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | - |
|
393 | - if (! empty($receiving)) |
|
394 | - { |
|
395 | - // $expedition->fk_origin_line = id of det line of order |
|
396 | - // $receiving->fk_origin_line = id of det line of order |
|
397 | - // $receiving->origin may be 'shipping' |
|
398 | - // $receiving->origin_id may be id of shipping |
|
399 | - |
|
400 | - // Ref |
|
401 | - print '<td>'; |
|
402 | - print $receiving->getNomUrl($db); |
|
403 | - //print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>'; |
|
404 | - print '</td>'; |
|
405 | - // Qty received |
|
406 | - //print '<td align="center">'; |
|
407 | - // TODO No solution for the moment to link a line det of receipt with a line det of shipping, |
|
408 | - // so no way to know the qty received for this line of shipping. |
|
409 | - //print $langs->trans("FeatureNotYetAvailable"); |
|
410 | - //print '</td>'; |
|
411 | - // Date shipping real |
|
412 | - print '<td align="right">'; |
|
413 | - print dol_print_date($receiving->date_delivery,'day'); |
|
414 | - print '</td>'; |
|
415 | - } |
|
416 | - else |
|
417 | - { |
|
418 | - //print '<td> </td>'; |
|
419 | - print '<td> </td>'; |
|
420 | - print '<td> </td>'; |
|
421 | - } |
|
422 | - } |
|
423 | - print '</tr>'; |
|
424 | - $i++; |
|
425 | - } |
|
426 | - |
|
427 | - print '</table>'; |
|
428 | - } |
|
429 | - $db->free($resql); |
|
430 | - } |
|
431 | - else |
|
432 | - { |
|
433 | - dol_print_error($db); |
|
434 | - } |
|
435 | - |
|
436 | - return 1; |
|
382 | + // Informations on receipt |
|
383 | + if (! empty($conf->livraison_bon->enabled)) |
|
384 | + { |
|
385 | + include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
|
386 | + $expedition->id=$objp->sendingid; |
|
387 | + $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
388 | + //var_dump($expedition->linkedObjects); |
|
389 | + |
|
390 | + $receiving=''; |
|
391 | + if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | + |
|
393 | + if (! empty($receiving)) |
|
394 | + { |
|
395 | + // $expedition->fk_origin_line = id of det line of order |
|
396 | + // $receiving->fk_origin_line = id of det line of order |
|
397 | + // $receiving->origin may be 'shipping' |
|
398 | + // $receiving->origin_id may be id of shipping |
|
399 | + |
|
400 | + // Ref |
|
401 | + print '<td>'; |
|
402 | + print $receiving->getNomUrl($db); |
|
403 | + //print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>'; |
|
404 | + print '</td>'; |
|
405 | + // Qty received |
|
406 | + //print '<td align="center">'; |
|
407 | + // TODO No solution for the moment to link a line det of receipt with a line det of shipping, |
|
408 | + // so no way to know the qty received for this line of shipping. |
|
409 | + //print $langs->trans("FeatureNotYetAvailable"); |
|
410 | + //print '</td>'; |
|
411 | + // Date shipping real |
|
412 | + print '<td align="right">'; |
|
413 | + print dol_print_date($receiving->date_delivery,'day'); |
|
414 | + print '</td>'; |
|
415 | + } |
|
416 | + else |
|
417 | + { |
|
418 | + //print '<td> </td>'; |
|
419 | + print '<td> </td>'; |
|
420 | + print '<td> </td>'; |
|
421 | + } |
|
422 | + } |
|
423 | + print '</tr>'; |
|
424 | + $i++; |
|
425 | + } |
|
426 | + |
|
427 | + print '</table>'; |
|
428 | + } |
|
429 | + $db->free($resql); |
|
430 | + } |
|
431 | + else |
|
432 | + { |
|
433 | + dol_print_error($db); |
|
434 | + } |
|
435 | + |
|
436 | + return 1; |
|
437 | 437 | } |
438 | 438 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | global $db, $langs, $conf, $user; |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
40 | - $langs->loadLangs(array("sendings","deliveries")); |
|
40 | + $langs->loadLangs(array("sendings", "deliveries")); |
|
41 | 41 | |
42 | 42 | $h = 0; |
43 | 43 | $head = array(); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
51 | 51 | { |
52 | 52 | // delivery link |
53 | - $object->fetchObjectLinked($object->id,$object->element); |
|
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
53 | + $object->fetchObjectLinked($object->id, $object->element); |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | 55 | { |
56 | 56 | // Take first one element of array |
57 | 57 | $tmp = reset($object->linkedObjectsIds['delivery']); |
@@ -71,22 +71,22 @@ discard block |
||
71 | 71 | $objectsrc = new Commande($db); |
72 | 72 | $objectsrc->fetch($object->origin_id); |
73 | 73 | } |
74 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
74 | + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); |
|
75 | 75 | $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
76 | 76 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
77 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | 78 | $head[$h][2] = 'contact'; |
79 | 79 | $h++; |
80 | 80 | } |
81 | 81 | |
82 | 82 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
84 | - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
86 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
84 | + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); |
|
85 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
86 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
87 | 87 | $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
88 | 88 | $head[$h][1] = $langs->trans('Documents'); |
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
89 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
90 | 90 | $head[$h][2] = 'documents'; |
91 | 91 | $h++; |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | if (!empty($object->note_public)) $nbNote++; |
96 | 96 | $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
97 | 97 | $head[$h][1] = $langs->trans("Notes"); |
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | 99 | $head[$h][2] = 'note'; |
100 | 100 | $h++; |
101 | 101 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | // Entries must be declared in modules descriptor with line |
104 | 104 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
105 | 105 | // $this->tabs = array('entity:-tabname); to remove a tab |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
106 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); |
|
107 | 107 | |
108 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
108 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); |
|
109 | 109 | |
110 | 110 | return $head; |
111 | 111 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | global $langs, $conf, $user; |
123 | 123 | |
124 | 124 | // Load translation files required by the page |
125 | - $langs->loadLangs(array("sendings","deliveries")); |
|
125 | + $langs->loadLangs(array("sendings", "deliveries")); |
|
126 | 126 | |
127 | 127 | $h = 0; |
128 | 128 | $head = array(); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | $tmpObjectId = $object->id; |
159 | 159 | $object->id = $object->origin_id; |
160 | 160 | |
161 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
161 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); |
|
162 | 162 | |
163 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
163 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); |
|
164 | 164 | |
165 | 165 | $object->id = $tmpObjectId; |
166 | 166 | return $head; |
@@ -174,34 +174,34 @@ discard block |
||
174 | 174 | * @param string $filter Filter |
175 | 175 | * @return int <0 if KO, >0 if OK |
176 | 176 | */ |
177 | -function show_list_sending_receive($origin,$origin_id,$filter='') |
|
177 | +function show_list_sending_receive($origin, $origin_id, $filter = '') |
|
178 | 178 | { |
179 | 179 | global $db, $conf, $langs, $bc; |
180 | 180 | global $form; |
181 | 181 | |
182 | - $product_static=new Product($db); |
|
183 | - $expedition=new Expedition($db); |
|
184 | - $warehousestatic=new Entrepot($db); |
|
182 | + $product_static = new Product($db); |
|
183 | + $expedition = new Expedition($db); |
|
184 | + $warehousestatic = new Entrepot($db); |
|
185 | 185 | |
186 | 186 | $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
187 | - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
187 | + $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | + $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | 189 | //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
190 | - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | - $sql.= ' p.description as product_desc'; |
|
192 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
190 | + $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | + $sql .= ' p.description as product_desc'; |
|
192 | + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | 195 | //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
196 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
196 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | 197 | //TODO Add link to expeditiondet_batch |
198 | - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | - $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | - $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | - $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | - if ($filter) $sql.= $filter; |
|
198 | + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | + $sql .= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | + $sql .= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | + $sql .= " AND ed.fk_expedition = e.rowid"; |
|
202 | + if ($filter) $sql .= $filter; |
|
203 | 203 | |
204 | - $sql.= " ORDER BY obj.fk_product"; |
|
204 | + $sql .= " ORDER BY obj.fk_product"; |
|
205 | 205 | |
206 | 206 | dol_syslog("show_list_sending_receive", LOG_DEBUG); |
207 | 207 | $resql = $db->query($sql); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
224 | 224 | print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
225 | 225 | print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
226 | - if (! empty($conf->stock->enabled)) |
|
226 | + if (!empty($conf->stock->enabled)) |
|
227 | 227 | { |
228 | 228 | print '<td>'.$langs->trans("Warehouse").'</td>'; |
229 | 229 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | print '<td>'; |
234 | 234 | print '</td>'; |
235 | 235 | }*/ |
236 | - if (! empty($conf->livraison_bon->enabled)) |
|
236 | + if (!empty($conf->livraison_bon->enabled)) |
|
237 | 237 | { |
238 | 238 | print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
239 | 239 | //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
@@ -249,59 +249,59 @@ discard block |
||
249 | 249 | |
250 | 250 | // Sending id |
251 | 251 | print '<td align="left" class="nowrap">'; |
252 | - print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
252 | + print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | 253 | print '</td>'; |
254 | 254 | |
255 | 255 | // Description |
256 | 256 | if ($objp->fk_product > 0) |
257 | 257 | { |
258 | 258 | // Define output language |
259 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
259 | + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | 260 | { |
261 | 261 | $object = new $origin($db); |
262 | 262 | $object->fetch($origin_id); |
263 | 263 | $object->fetch_thirdparty(); |
264 | 264 | |
265 | 265 | $prod = new Product($db); |
266 | - $prod->id=$objp->fk_product; |
|
266 | + $prod->id = $objp->fk_product; |
|
267 | 267 | $prod->getMultiLangs(); |
268 | 268 | |
269 | 269 | $outputlangs = $langs; |
270 | - $newlang=''; |
|
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | - if (! empty($newlang)) |
|
270 | + $newlang = ''; |
|
271 | + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; |
|
272 | + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
273 | + if (!empty($newlang)) |
|
274 | 274 | { |
275 | - $outputlangs = new Translate("",$conf); |
|
275 | + $outputlangs = new Translate("", $conf); |
|
276 | 276 | $outputlangs->setDefaultLang($newlang); |
277 | 277 | } |
278 | 278 | |
279 | - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
279 | + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | 280 | } |
281 | 281 | else |
282 | 282 | { |
283 | - $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
283 | + $label = (!empty($objp->label) ? $objp->label : $objp->product_label); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | print '<td>'; |
287 | 287 | |
288 | 288 | // Show product and description |
289 | - $product_static->type=$objp->fk_product_type; |
|
290 | - $product_static->id=$objp->fk_product; |
|
291 | - $product_static->ref=$objp->ref; |
|
292 | - $product_static->status_batch=$objp->product_tobatch; |
|
293 | - $text=$product_static->getNomUrl(1); |
|
294 | - $text.= ' - '.$label; |
|
295 | - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | - print $form->textwithtooltip($text,$description,3,'','',$i); |
|
289 | + $product_static->type = $objp->fk_product_type; |
|
290 | + $product_static->id = $objp->fk_product; |
|
291 | + $product_static->ref = $objp->ref; |
|
292 | + $product_static->status_batch = $objp->product_tobatch; |
|
293 | + $text = $product_static->getNomUrl(1); |
|
294 | + $text .= ' - '.$label; |
|
295 | + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); |
|
296 | + print $form->textwithtooltip($text, $description, 3, '', '', $i); |
|
297 | 297 | |
298 | 298 | // Show range |
299 | - print_date_range($objp->date_start,$objp->date_end); |
|
299 | + print_date_range($objp->date_start, $objp->date_end); |
|
300 | 300 | |
301 | 301 | // Add description in form |
302 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
302 | + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | 303 | { |
304 | - print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
304 | + print (!empty($objp->description) && $objp->description != $objp->product) ? '<br>'.dol_htmlentitiesbr($objp->description) : ''; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | print '</td>'; |
@@ -309,34 +309,34 @@ discard block |
||
309 | 309 | else |
310 | 310 | { |
311 | 311 | print "<td>"; |
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
312 | + if ($objp->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); |
|
313 | + else $text = img_object($langs->trans('Product'), 'product'); |
|
314 | 314 | |
315 | - if (! empty($objp->label)) { |
|
316 | - $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | - print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
315 | + if (!empty($objp->label)) { |
|
316 | + $text .= ' <strong>'.$objp->label.'</strong>'; |
|
317 | + print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); |
|
318 | 318 | } else { |
319 | 319 | print $text.' '.nl2br($objp->description); |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Show range |
323 | - print_date_range($objp->date_start,$objp->date_end); |
|
323 | + print_date_range($objp->date_start, $objp->date_end); |
|
324 | 324 | print "</td>\n"; |
325 | 325 | } |
326 | 326 | |
327 | 327 | //print '<td align="center">'.$objp->qty_asked.'</td>'; |
328 | 328 | |
329 | 329 | // Date creation |
330 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
330 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>'; |
|
331 | 331 | |
332 | 332 | // Date shipping creation |
333 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
333 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery), 'day').'</td>'; |
|
334 | 334 | |
335 | 335 | // Qty shipped |
336 | 336 | print '<td align="center">'.$objp->qty_shipped.'</td>'; |
337 | 337 | |
338 | 338 | // Warehouse |
339 | - if (! empty($conf->stock->enabled)) |
|
339 | + if (!empty($conf->stock->enabled)) |
|
340 | 340 | { |
341 | 341 | print '<td>'; |
342 | 342 | if ($objp->warehouse_id > 0) |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | }*/ |
381 | 381 | |
382 | 382 | // Informations on receipt |
383 | - if (! empty($conf->livraison_bon->enabled)) |
|
383 | + if (!empty($conf->livraison_bon->enabled)) |
|
384 | 384 | { |
385 | 385 | include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
386 | - $expedition->id=$objp->sendingid; |
|
387 | - $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
386 | + $expedition->id = $objp->sendingid; |
|
387 | + $expedition->fetchObjectLinked($expedition->id, $expedition->element); |
|
388 | 388 | //var_dump($expedition->linkedObjects); |
389 | 389 | |
390 | - $receiving=''; |
|
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
390 | + $receiving = ''; |
|
391 | + if (count($expedition->linkedObjects['delivery']) > 0) $receiving = reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | 392 | |
393 | - if (! empty($receiving)) |
|
393 | + if (!empty($receiving)) |
|
394 | 394 | { |
395 | 395 | // $expedition->fk_origin_line = id of det line of order |
396 | 396 | // $receiving->fk_origin_line = id of det line of order |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | //print '</td>'; |
411 | 411 | // Date shipping real |
412 | 412 | print '<td align="right">'; |
413 | - print dol_print_date($receiving->date_delivery,'day'); |
|
413 | + print dol_print_date($receiving->date_delivery, 'day'); |
|
414 | 414 | print '</td>'; |
415 | 415 | } |
416 | 416 | else |
@@ -51,10 +51,12 @@ discard block |
||
51 | 51 | { |
52 | 52 | // delivery link |
53 | 53 | $object->fetchObjectLinked($object->id,$object->element); |
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) { |
|
55 | + // If there is a delivery |
|
55 | 56 | { |
56 | 57 | // Take first one element of array |
57 | 58 | $tmp = reset($object->linkedObjectsIds['delivery']); |
59 | + } |
|
58 | 60 | |
59 | 61 | $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
60 | 62 | $head[$h][1] = $langs->trans("DeliveryCard"); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
75 | 77 | $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
76 | 78 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
79 | + if ($nbContact > 0) { |
|
80 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
81 | + } |
|
78 | 82 | $head[$h][2] = 'contact'; |
79 | 83 | $h++; |
80 | 84 | } |
@@ -86,16 +90,24 @@ discard block |
||
86 | 90 | $nbLinks=Link::count($db, $object->element, $object->id); |
87 | 91 | $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
88 | 92 | $head[$h][1] = $langs->trans('Documents'); |
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
93 | + if (($nbFiles+$nbLinks) > 0) { |
|
94 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
95 | + } |
|
90 | 96 | $head[$h][2] = 'documents'; |
91 | 97 | $h++; |
92 | 98 | |
93 | 99 | $nbNote = 0; |
94 | - if (!empty($object->note_private)) $nbNote++; |
|
95 | - if (!empty($object->note_public)) $nbNote++; |
|
100 | + if (!empty($object->note_private)) { |
|
101 | + $nbNote++; |
|
102 | + } |
|
103 | + if (!empty($object->note_public)) { |
|
104 | + $nbNote++; |
|
105 | + } |
|
96 | 106 | $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
97 | 107 | $head[$h][1] = $langs->trans("Notes"); |
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
108 | + if ($nbNote > 0) { |
|
109 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
110 | + } |
|
99 | 111 | $head[$h][2] = 'note'; |
100 | 112 | $h++; |
101 | 113 | |
@@ -199,7 +211,9 @@ discard block |
||
199 | 211 | $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
200 | 212 | $sql.= " AND obj.rowid = ed.fk_origin_line"; |
201 | 213 | $sql.= " AND ed.fk_expedition = e.rowid"; |
202 | - if ($filter) $sql.= $filter; |
|
214 | + if ($filter) { |
|
215 | + $sql.= $filter; |
|
216 | + } |
|
203 | 217 | |
204 | 218 | $sql.= " ORDER BY obj.fk_product"; |
205 | 219 | |
@@ -212,8 +226,11 @@ discard block |
||
212 | 226 | |
213 | 227 | if ($num) |
214 | 228 | { |
215 | - if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | - else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
229 | + if ($filter) { |
|
230 | + print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
231 | + } else { |
|
232 | + print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
233 | + } |
|
217 | 234 | |
218 | 235 | print '<table class="liste" width="100%">'; |
219 | 236 | print '<tr class="liste_titre">'; |
@@ -268,8 +285,12 @@ discard block |
||
268 | 285 | |
269 | 286 | $outputlangs = $langs; |
270 | 287 | $newlang=''; |
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
288 | + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) { |
|
289 | + $newlang=$_REQUEST['lang_id']; |
|
290 | + } |
|
291 | + if (empty($newlang)) { |
|
292 | + $newlang=$object->thirdparty->default_lang; |
|
293 | + } |
|
273 | 294 | if (! empty($newlang)) |
274 | 295 | { |
275 | 296 | $outputlangs = new Translate("",$conf); |
@@ -277,8 +298,7 @@ discard block |
||
277 | 298 | } |
278 | 299 | |
279 | 300 | $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
280 | - } |
|
281 | - else |
|
301 | + } else |
|
282 | 302 | { |
283 | 303 | $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
284 | 304 | } |
@@ -305,12 +325,14 @@ discard block |
||
305 | 325 | } |
306 | 326 | |
307 | 327 | print '</td>'; |
308 | - } |
|
309 | - else |
|
328 | + } else |
|
310 | 329 | { |
311 | 330 | print "<td>"; |
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
331 | + if ($objp->fk_product_type==1) { |
|
332 | + $text = img_object($langs->trans('Service'),'service'); |
|
333 | + } else { |
|
334 | + $text = img_object($langs->trans('Product'),'product'); |
|
335 | + } |
|
314 | 336 | |
315 | 337 | if (! empty($objp->label)) { |
316 | 338 | $text.= ' <strong>'.$objp->label.'</strong>'; |
@@ -388,7 +410,10 @@ discard block |
||
388 | 410 | //var_dump($expedition->linkedObjects); |
389 | 411 | |
390 | 412 | $receiving=''; |
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
413 | + if (count($expedition->linkedObjects['delivery']) > 0) { |
|
414 | + $receiving=reset($expedition->linkedObjects['delivery']); |
|
415 | + } |
|
416 | + // Take first link |
|
392 | 417 | |
393 | 418 | if (! empty($receiving)) |
394 | 419 | { |
@@ -412,8 +437,7 @@ discard block |
||
412 | 437 | print '<td align="right">'; |
413 | 438 | print dol_print_date($receiving->date_delivery,'day'); |
414 | 439 | print '</td>'; |
415 | - } |
|
416 | - else |
|
440 | + } else |
|
417 | 441 | { |
418 | 442 | //print '<td> </td>'; |
419 | 443 | print '<td> </td>'; |
@@ -427,8 +451,7 @@ discard block |
||
427 | 451 | print '</table>'; |
428 | 452 | } |
429 | 453 | $db->free($resql); |
430 | - } |
|
431 | - else |
|
454 | + } else |
|
432 | 455 | { |
433 | 456 | dol_print_error($db); |
434 | 457 | } |
@@ -34,45 +34,45 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function reception_prepare_head(Reception $object) |
36 | 36 | { |
37 | - global $db, $langs, $conf, $user; |
|
37 | + global $db, $langs, $conf, $user; |
|
38 | 38 | |
39 | - $langs->load("sendings"); |
|
40 | - $langs->load("deliveries"); |
|
39 | + $langs->load("sendings"); |
|
40 | + $langs->load("deliveries"); |
|
41 | 41 | |
42 | - $h = 0; |
|
43 | - $head = array(); |
|
42 | + $h = 0; |
|
43 | + $head = array(); |
|
44 | 44 | |
45 | - $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id; |
|
46 | - $head[$h][1] = $langs->trans("ReceptionCard"); |
|
47 | - $head[$h][2] = 'reception'; |
|
48 | - $h++; |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id; |
|
46 | + $head[$h][1] = $langs->trans("ReceptionCard"); |
|
47 | + $head[$h][2] = 'reception'; |
|
48 | + $h++; |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
53 | - { |
|
54 | - $objectsrc = $object; |
|
55 | - if ($object->origin == 'commande' && $object->origin_id > 0) |
|
56 | - { |
|
57 | - $objectsrc = new Commande($db); |
|
58 | - $objectsrc->fetch($object->origin_id); |
|
59 | - } |
|
60 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
61 | - $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
|
62 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | - $head[$h][2] = 'contact'; |
|
65 | - $h++; |
|
66 | - } |
|
52 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
53 | + { |
|
54 | + $objectsrc = $object; |
|
55 | + if ($object->origin == 'commande' && $object->origin_id > 0) |
|
56 | + { |
|
57 | + $objectsrc = new Commande($db); |
|
58 | + $objectsrc->fetch($object->origin_id); |
|
59 | + } |
|
60 | + $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
61 | + $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
|
62 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
63 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | + $head[$h][2] = 'contact'; |
|
65 | + $h++; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | $nbNote = 0; |
69 | 69 | if (!empty($object->note_private)) $nbNote++; |
70 | 70 | if (!empty($object->note_public)) $nbNote++; |
71 | - $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
|
72 | - $head[$h][1] = $langs->trans("Notes"); |
|
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | - $head[$h][2] = 'note'; |
|
75 | - $h++; |
|
71 | + $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
|
72 | + $head[$h][1] = $langs->trans("Notes"); |
|
73 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + $head[$h][2] = 'note'; |
|
75 | + $h++; |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
@@ -91,39 +91,39 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function reception_admin_prepare_head() |
93 | 93 | { |
94 | - global $langs, $conf, $user; |
|
95 | - $langs->load("receptions"); |
|
94 | + global $langs, $conf, $user; |
|
95 | + $langs->load("receptions"); |
|
96 | 96 | |
97 | - $h = 0; |
|
98 | - $head = array(); |
|
97 | + $h = 0; |
|
98 | + $head = array(); |
|
99 | 99 | |
100 | - $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php"; |
|
101 | - $head[$h][1] = $langs->trans("Reception"); |
|
102 | - $head[$h][2] = 'reception'; |
|
103 | - $h++; |
|
100 | + $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php"; |
|
101 | + $head[$h][1] = $langs->trans("Reception"); |
|
102 | + $head[$h][2] = 'reception'; |
|
103 | + $h++; |
|
104 | 104 | |
105 | 105 | |
106 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | - { |
|
108 | - $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
|
109 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
110 | - $head[$h][2] = 'attributes_reception'; |
|
111 | - $h++; |
|
112 | - } |
|
106 | + if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | + { |
|
108 | + $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
|
109 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
110 | + $head[$h][2] = 'attributes_reception'; |
|
111 | + $h++; |
|
112 | + } |
|
113 | 113 | |
114 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | - { |
|
116 | - $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
|
117 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
118 | - $head[$h][2] = 'attributeslines_reception'; |
|
119 | - $h++; |
|
120 | - } |
|
114 | + if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | + { |
|
116 | + $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
|
117 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
118 | + $head[$h][2] = 'attributeslines_reception'; |
|
119 | + $h++; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | 123 | |
124 | - complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
124 | + complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
125 | 125 | |
126 | - return $head; |
|
126 | + return $head; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | $objectsrc = new Commande($db); |
58 | 58 | $objectsrc->fetch($object->origin_id); |
59 | 59 | } |
60 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
60 | + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); |
|
61 | 61 | $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
62 | 62 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
63 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | 64 | $head[$h][2] = 'contact'; |
65 | 65 | $h++; |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (!empty($object->note_public)) $nbNote++; |
71 | 71 | $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
72 | 72 | $head[$h][1] = $langs->trans("Notes"); |
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
73 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | 74 | $head[$h][2] = 'note'; |
75 | 75 | $h++; |
76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove'); |
|
82 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); |
|
83 | 83 | |
84 | 84 | return $head; |
85 | 85 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $h++; |
104 | 104 | |
105 | 105 | |
106 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
106 | + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | 107 | { |
108 | 108 | $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
109 | 109 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $h++; |
112 | 112 | } |
113 | 113 | |
114 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
114 | + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | 115 | { |
116 | 116 | $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
117 | 117 | $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | |
124 | - complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
124 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove'); |
|
125 | 125 | |
126 | 126 | return $head; |
127 | 127 | } |
@@ -60,17 +60,25 @@ |
||
60 | 60 | $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
61 | 61 | $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
62 | 62 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
63 | + if ($nbContact > 0) { |
|
64 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
65 | + } |
|
64 | 66 | $head[$h][2] = 'contact'; |
65 | 67 | $h++; |
66 | 68 | } |
67 | 69 | |
68 | 70 | $nbNote = 0; |
69 | - if (!empty($object->note_private)) $nbNote++; |
|
70 | - if (!empty($object->note_public)) $nbNote++; |
|
71 | + if (!empty($object->note_private)) { |
|
72 | + $nbNote++; |
|
73 | + } |
|
74 | + if (!empty($object->note_public)) { |
|
75 | + $nbNote++; |
|
76 | + } |
|
71 | 77 | $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
72 | 78 | $head[$h][1] = $langs->trans("Notes"); |
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
79 | + if ($nbNote > 0) { |
|
80 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
81 | + } |
|
74 | 82 | $head[$h][2] = 'note'; |
75 | 83 | $h++; |
76 | 84 |
@@ -29,53 +29,53 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function expensereport_prepare_head($object) |
31 | 31 | { |
32 | - global $db, $langs, $conf; |
|
32 | + global $db, $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - // Show more tabs from modules |
|
43 | - // Entries must be declared in modules descriptor with line |
|
42 | + // Show more tabs from modules |
|
43 | + // Entries must be declared in modules descriptor with line |
|
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
46 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
47 | 47 | |
48 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
48 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
50 | - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
50 | + $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
52 | 52 | $nbLinks=Link::count($db, $object->element, $object->id); |
53 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
|
54 | - $head[$h][1] = $langs->trans('Documents'); |
|
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
56 | - $head[$h][2] = 'documents'; |
|
57 | - $h++; |
|
58 | - |
|
59 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
60 | - { |
|
61 | - $nbNote = 0; |
|
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
|
65 | - $head[$h][1] = $langs->trans('Notes'); |
|
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | - $head[$h][2] = 'note'; |
|
68 | - $h++; |
|
69 | - } |
|
70 | - |
|
71 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
72 | - $head[$h][1] = $langs->trans("Info"); |
|
73 | - $head[$h][2] = 'info'; |
|
74 | - $h++; |
|
75 | - |
|
76 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
77 | - |
|
78 | - return $head; |
|
53 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
|
54 | + $head[$h][1] = $langs->trans('Documents'); |
|
55 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
56 | + $head[$h][2] = 'documents'; |
|
57 | + $h++; |
|
58 | + |
|
59 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
60 | + { |
|
61 | + $nbNote = 0; |
|
62 | + if(!empty($object->note_private)) $nbNote++; |
|
63 | + if(!empty($object->note_public)) $nbNote++; |
|
64 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
|
65 | + $head[$h][1] = $langs->trans('Notes'); |
|
66 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | + $head[$h][2] = 'note'; |
|
68 | + $h++; |
|
69 | + } |
|
70 | + |
|
71 | + $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
72 | + $head[$h][1] = $langs->trans("Info"); |
|
73 | + $head[$h][2] = 'info'; |
|
74 | + $h++; |
|
75 | + |
|
76 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
77 | + |
|
78 | + return $head; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | function payment_expensereport_prepare_head(PaymentExpenseReport $object) |
89 | 89 | { |
90 | 90 | |
91 | - global $langs, $conf; |
|
91 | + global $langs, $conf; |
|
92 | 92 | |
93 | - $h = 0; |
|
94 | - $head = array(); |
|
93 | + $h = 0; |
|
94 | + $head = array(); |
|
95 | 95 | |
96 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id; |
|
97 | - $head[$h][1] = $langs->trans("Card"); |
|
98 | - $head[$h][2] = 'payment'; |
|
99 | - $h++; |
|
96 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id; |
|
97 | + $head[$h][1] = $langs->trans("Card"); |
|
98 | + $head[$h][2] = 'payment'; |
|
99 | + $h++; |
|
100 | 100 | |
101 | 101 | // Show more tabs from modules |
102 | 102 | // Entries must be declared in modules descriptor with line |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | // $this->tabs = array('entity:-tabname); to remove a tab |
105 | 105 | complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport'); |
106 | 106 | |
107 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
|
108 | - $head[$h][1] = $langs->trans("Info"); |
|
109 | - $head[$h][2] = 'info'; |
|
110 | - $h++; |
|
107 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
|
108 | + $head[$h][1] = $langs->trans("Info"); |
|
109 | + $head[$h][2] = 'info'; |
|
110 | + $h++; |
|
111 | 111 | |
112 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
112 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
113 | 113 | |
114 | - return $head; |
|
114 | + return $head; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,42 +121,42 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function expensereport_admin_prepare_head() |
123 | 123 | { |
124 | - global $langs, $conf, $user; |
|
125 | - |
|
126 | - $h = 0; |
|
127 | - $head = array(); |
|
128 | - |
|
129 | - $h = 0; |
|
130 | - |
|
131 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php"; |
|
132 | - $head[$h][1] = $langs->trans("ExpenseReports"); |
|
133 | - $head[$h][2] = 'expensereport'; |
|
134 | - $h++; |
|
135 | - |
|
136 | - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) |
|
137 | - { |
|
138 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; |
|
139 | - $head[$h][1] = $langs->trans("ExpenseReportsIk"); |
|
140 | - $head[$h][2] = 'expenseik'; |
|
141 | - $h++; |
|
142 | - } |
|
143 | - |
|
144 | - if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) |
|
145 | - { |
|
146 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; |
|
147 | - $head[$h][1] = $langs->trans("ExpenseReportsRules"); |
|
148 | - $head[$h][2] = 'expenserules'; |
|
149 | - $h++; |
|
150 | - } |
|
151 | - |
|
152 | - // Show more tabs from modules |
|
153 | - // Entries must be declared in modules descriptor with line |
|
154 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
155 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
156 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
157 | - |
|
158 | - $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
|
159 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
124 | + global $langs, $conf, $user; |
|
125 | + |
|
126 | + $h = 0; |
|
127 | + $head = array(); |
|
128 | + |
|
129 | + $h = 0; |
|
130 | + |
|
131 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php"; |
|
132 | + $head[$h][1] = $langs->trans("ExpenseReports"); |
|
133 | + $head[$h][2] = 'expensereport'; |
|
134 | + $h++; |
|
135 | + |
|
136 | + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) |
|
137 | + { |
|
138 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; |
|
139 | + $head[$h][1] = $langs->trans("ExpenseReportsIk"); |
|
140 | + $head[$h][2] = 'expenseik'; |
|
141 | + $h++; |
|
142 | + } |
|
143 | + |
|
144 | + if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) |
|
145 | + { |
|
146 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; |
|
147 | + $head[$h][1] = $langs->trans("ExpenseReportsRules"); |
|
148 | + $head[$h][2] = 'expenserules'; |
|
149 | + $h++; |
|
150 | + } |
|
151 | + |
|
152 | + // Show more tabs from modules |
|
153 | + // Entries must be declared in modules descriptor with line |
|
154 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
155 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
156 | + complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
157 | + |
|
158 | + $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
|
159 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
160 | 160 | $head[$h][2] = 'attributes'; |
161 | 161 | $h++; |
162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $h++; |
168 | 168 | */ |
169 | 169 | |
170 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
170 | + complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
171 | 171 | |
172 | 172 | return $head; |
173 | 173 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $h = 0; |
35 | 35 | $head = array(); |
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id; |
|
38 | 38 | $head[$h][1] = $langs->trans("Card"); |
39 | 39 | $head[$h][2] = 'card'; |
40 | 40 | $h++; |
@@ -43,37 +43,37 @@ discard block |
||
43 | 43 | // Entries must be declared in modules descriptor with line |
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
46 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport'); |
|
47 | 47 | |
48 | 48 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
50 | - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
52 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
50 | + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); |
|
51 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
52 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
53 | 53 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
54 | 54 | $head[$h][1] = $langs->trans('Documents'); |
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
55 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
56 | 56 | $head[$h][2] = 'documents'; |
57 | 57 | $h++; |
58 | 58 | |
59 | 59 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 60 | { |
61 | 61 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
62 | + if (!empty($object->note_private)) $nbNote++; |
|
63 | + if (!empty($object->note_public)) $nbNote++; |
|
64 | 64 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
65 | 65 | $head[$h][1] = $langs->trans('Notes'); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
66 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | 67 | $head[$h][2] = 'note'; |
68 | 68 | $h++; |
69 | 69 | } |
70 | 70 | |
71 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
71 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id; |
|
72 | 72 | $head[$h][1] = $langs->trans("Info"); |
73 | 73 | $head[$h][2] = 'info'; |
74 | 74 | $h++; |
75 | 75 | |
76 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
76 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove'); |
|
77 | 77 | |
78 | 78 | return $head; |
79 | 79 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | // Entries must be declared in modules descriptor with line |
103 | 103 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
104 | 104 | // $this->tabs = array('entity:-tabname); to remove a tab |
105 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport'); |
|
105 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport'); |
|
106 | 106 | |
107 | 107 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
108 | 108 | $head[$h][1] = $langs->trans("Info"); |
109 | 109 | $head[$h][2] = 'info'; |
110 | 110 | $h++; |
111 | 111 | |
112 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
112 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove'); |
|
113 | 113 | |
114 | 114 | return $head; |
115 | 115 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | // Entries must be declared in modules descriptor with line |
154 | 154 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
155 | 155 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
156 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
156 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin'); |
|
157 | 157 | |
158 | 158 | $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
159 | 159 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $h++; |
168 | 168 | */ |
169 | 169 | |
170 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
170 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove'); |
|
171 | 171 | |
172 | 172 | return $head; |
173 | 173 | } |
@@ -52,18 +52,26 @@ |
||
52 | 52 | $nbLinks=Link::count($db, $object->element, $object->id); |
53 | 53 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
54 | 54 | $head[$h][1] = $langs->trans('Documents'); |
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
55 | + if (($nbFiles+$nbLinks) > 0) { |
|
56 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
57 | + } |
|
56 | 58 | $head[$h][2] = 'documents'; |
57 | 59 | $h++; |
58 | 60 | |
59 | 61 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 62 | { |
61 | 63 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | + if(!empty($object->note_private)) { |
|
65 | + $nbNote++; |
|
66 | + } |
|
67 | + if(!empty($object->note_public)) { |
|
68 | + $nbNote++; |
|
69 | + } |
|
64 | 70 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
65 | 71 | $head[$h][1] = $langs->trans('Notes'); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + if ($nbNote > 0) { |
|
73 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + } |
|
67 | 75 | $head[$h][2] = 'note'; |
68 | 76 | $h++; |
69 | 77 | } |
@@ -35,61 +35,61 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function tree_showpad(&$fulltree,$key,$silent=0) |
37 | 37 | { |
38 | - $pos=1; |
|
39 | - |
|
40 | - // Loop on each pos, because we will output an img for each pos |
|
41 | - while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
|
42 | - { |
|
43 | - // Process for column $pos |
|
44 | - |
|
45 | - $atleastoneofthislevelafter=0; |
|
46 | - $nbofdirinsub=0; |
|
47 | - $nbofdocinsub=0; |
|
48 | - $found=0; |
|
49 | - //print 'x'.$key; |
|
50 | - foreach($fulltree as $key2 => $val2) |
|
51 | - { |
|
38 | + $pos=1; |
|
39 | + |
|
40 | + // Loop on each pos, because we will output an img for each pos |
|
41 | + while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
|
42 | + { |
|
43 | + // Process for column $pos |
|
44 | + |
|
45 | + $atleastoneofthislevelafter=0; |
|
46 | + $nbofdirinsub=0; |
|
47 | + $nbofdocinsub=0; |
|
48 | + $found=0; |
|
49 | + //print 'x'.$key; |
|
50 | + foreach($fulltree as $key2 => $val2) |
|
51 | + { |
|
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | - if ($found == 1) // We are after the entry to show |
|
54 | - { |
|
55 | - if ($fulltree[$key2]['level'] > $pos) |
|
56 | - { |
|
57 | - $nbofdirinsub++; |
|
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | - } |
|
60 | - if ($fulltree[$key2]['level'] == $pos) |
|
61 | - { |
|
62 | - $atleastoneofthislevelafter=1; |
|
63 | - } |
|
64 | - if ($fulltree[$key2]['level'] <= $pos) |
|
65 | - { |
|
66 | - break; |
|
67 | - } |
|
68 | - } |
|
69 | - if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
70 | - { |
|
71 | - $found=1; |
|
72 | - } |
|
73 | - } |
|
74 | - //print $atleastoneofthislevelafter; |
|
75 | - |
|
76 | - if (! $silent) |
|
77 | - { |
|
78 | - if ($atleastoneofthislevelafter) |
|
79 | - { |
|
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
82 | - } |
|
83 | - else |
|
84 | - { |
|
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
87 | - } |
|
88 | - } |
|
89 | - $pos++; |
|
90 | - } |
|
91 | - |
|
92 | - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
53 | + if ($found == 1) // We are after the entry to show |
|
54 | + { |
|
55 | + if ($fulltree[$key2]['level'] > $pos) |
|
56 | + { |
|
57 | + $nbofdirinsub++; |
|
58 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | + } |
|
60 | + if ($fulltree[$key2]['level'] == $pos) |
|
61 | + { |
|
62 | + $atleastoneofthislevelafter=1; |
|
63 | + } |
|
64 | + if ($fulltree[$key2]['level'] <= $pos) |
|
65 | + { |
|
66 | + break; |
|
67 | + } |
|
68 | + } |
|
69 | + if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
70 | + { |
|
71 | + $found=1; |
|
72 | + } |
|
73 | + } |
|
74 | + //print $atleastoneofthislevelafter; |
|
75 | + |
|
76 | + if (! $silent) |
|
77 | + { |
|
78 | + if ($atleastoneofthislevelafter) |
|
79 | + { |
|
80 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | + else print img_picto_common('','treemenu/line.gif'); |
|
82 | + } |
|
83 | + else |
|
84 | + { |
|
85 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | + else print img_picto_common('','treemenu/linebottom.gif'); |
|
87 | + } |
|
88 | + } |
|
89 | + $pos++; |
|
90 | + } |
|
91 | + |
|
92 | + return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
121 | 121 | |
122 | 122 | if ($rang == 0) |
123 | - { |
|
124 | - // Test also done with jstree and dynatree (not able to have <a> inside label) |
|
125 | - print '<script type="text/javascript" language="javascript"> |
|
123 | + { |
|
124 | + // Test also done with jstree and dynatree (not able to have <a> inside label) |
|
125 | + print '<script type="text/javascript" language="javascript"> |
|
126 | 126 | $(document).ready(function(){ |
127 | 127 | $("#'.$iddivjstree.'").treeview({ |
128 | 128 | collapsed: true, |
@@ -136,94 +136,94 @@ discard block |
||
136 | 136 | }) |
137 | 137 | </script>'; |
138 | 138 | |
139 | - print '<ul id="'.$iddivjstree.'">'; |
|
140 | - } |
|
141 | - |
|
142 | - if ($rang > 50) |
|
143 | - { |
|
144 | - return; // Protect against infinite loop. Max 50 depth |
|
145 | - } |
|
146 | - |
|
147 | - //ballayage du tableau |
|
148 | - $sizeoftab=count($tab); |
|
149 | - $ulprinted=0; |
|
150 | - for ($x=0; $x < $sizeoftab; $x++) |
|
151 | - { |
|
152 | - //var_dump($tab[$x]);exit; |
|
153 | - // If an element has $pere for parent |
|
154 | - if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
|
155 | - { |
|
156 | - //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
157 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
158 | - { |
|
159 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | - { |
|
161 | - dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
162 | - continue; |
|
163 | - } |
|
139 | + print '<ul id="'.$iddivjstree.'">'; |
|
140 | + } |
|
141 | + |
|
142 | + if ($rang > 50) |
|
143 | + { |
|
144 | + return; // Protect against infinite loop. Max 50 depth |
|
145 | + } |
|
146 | + |
|
147 | + //ballayage du tableau |
|
148 | + $sizeoftab=count($tab); |
|
149 | + $ulprinted=0; |
|
150 | + for ($x=0; $x < $sizeoftab; $x++) |
|
151 | + { |
|
152 | + //var_dump($tab[$x]);exit; |
|
153 | + // If an element has $pere for parent |
|
154 | + if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
|
155 | + { |
|
156 | + //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
157 | + if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
158 | + { |
|
159 | + if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | + { |
|
161 | + dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
162 | + continue; |
|
163 | + } |
|
164 | 164 | |
165 | 165 | print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
166 | - } |
|
167 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
168 | - if ($showfk) |
|
169 | - { |
|
170 | - print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
171 | - print '<strong> '; |
|
172 | - print $tab[$x]['title']; |
|
173 | - print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
174 | - print '</td><td align="right">'; |
|
175 | - print $tab[$x]['buttons']; |
|
176 | - print '</td></tr></table>'; |
|
177 | - } |
|
178 | - else |
|
179 | - { |
|
180 | - print $tab[$x]['entry']; |
|
181 | - } |
|
182 | - //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
183 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
184 | - // And now we search all its sons of lower level |
|
185 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
186 | - print '</li>'; |
|
187 | - } |
|
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | - { |
|
190 | - //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
191 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
192 | - { |
|
193 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | - { |
|
195 | - dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
196 | - //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
|
166 | + } |
|
167 | + print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
168 | + if ($showfk) |
|
169 | + { |
|
170 | + print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
171 | + print '<strong> '; |
|
172 | + print $tab[$x]['title']; |
|
173 | + print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
174 | + print '</td><td align="right">'; |
|
175 | + print $tab[$x]['buttons']; |
|
176 | + print '</td></tr></table>'; |
|
177 | + } |
|
178 | + else |
|
179 | + { |
|
180 | + print $tab[$x]['entry']; |
|
181 | + } |
|
182 | + //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
183 | + $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
184 | + // And now we search all its sons of lower level |
|
185 | + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
186 | + print '</li>'; |
|
187 | + } |
|
188 | + elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | + { |
|
190 | + //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
191 | + if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
192 | + { |
|
193 | + if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | + { |
|
195 | + dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
196 | + //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
|
197 | 197 | continue; |
198 | - } |
|
199 | - |
|
200 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
201 | - } |
|
202 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
203 | - if ($showfk) |
|
204 | - { |
|
205 | - print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
206 | - print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; |
|
207 | - print $tab[$x]['title']; |
|
208 | - print '</a></strong>'; |
|
209 | - print ' (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
210 | - print '</td><td align="right">'; |
|
211 | - print $tab[$x]['buttons']; |
|
212 | - print '</td></tr></table>'; |
|
213 | - } |
|
214 | - else |
|
215 | - { |
|
216 | - print $tab[$x]['entry']; |
|
217 | - } |
|
218 | - //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
219 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
220 | - // And now we search all its sons of lower level |
|
221 | - //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
|
222 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
223 | - print '</li>'; |
|
224 | - } |
|
225 | - } |
|
226 | - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
198 | + } |
|
199 | + |
|
200 | + print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
201 | + } |
|
202 | + print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
203 | + if ($showfk) |
|
204 | + { |
|
205 | + print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
206 | + print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; |
|
207 | + print $tab[$x]['title']; |
|
208 | + print '</a></strong>'; |
|
209 | + print ' (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
210 | + print '</td><td align="right">'; |
|
211 | + print $tab[$x]['buttons']; |
|
212 | + print '</td></tr></table>'; |
|
213 | + } |
|
214 | + else |
|
215 | + { |
|
216 | + print $tab[$x]['entry']; |
|
217 | + } |
|
218 | + //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
219 | + $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
220 | + // And now we search all its sons of lower level |
|
221 | + //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
|
222 | + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
223 | + print '</li>'; |
|
224 | + } |
|
225 | + } |
|
226 | + if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
227 | 227 | |
228 | 228 | if ($rang == 0) print '</ul>'; |
229 | 229 | } |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | * @param int $silent Do not output indent and picto, returns only value |
34 | 34 | * @return integer[] array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub) |
35 | 35 | */ |
36 | -function tree_showpad(&$fulltree,$key,$silent=0) |
|
36 | +function tree_showpad(&$fulltree, $key, $silent = 0) |
|
37 | 37 | { |
38 | - $pos=1; |
|
38 | + $pos = 1; |
|
39 | 39 | |
40 | 40 | // Loop on each pos, because we will output an img for each pos |
41 | 41 | while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
42 | 42 | { |
43 | 43 | // Process for column $pos |
44 | 44 | |
45 | - $atleastoneofthislevelafter=0; |
|
46 | - $nbofdirinsub=0; |
|
47 | - $nbofdocinsub=0; |
|
48 | - $found=0; |
|
45 | + $atleastoneofthislevelafter = 0; |
|
46 | + $nbofdirinsub = 0; |
|
47 | + $nbofdocinsub = 0; |
|
48 | + $found = 0; |
|
49 | 49 | //print 'x'.$key; |
50 | - foreach($fulltree as $key2 => $val2) |
|
50 | + foreach ($fulltree as $key2 => $val2) |
|
51 | 51 | { |
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | 53 | if ($found == 1) // We are after the entry to show |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | if ($fulltree[$key2]['level'] > $pos) |
56 | 56 | { |
57 | 57 | $nbofdirinsub++; |
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
58 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub += $fulltree[$key2]['cachenbofdoc']; |
|
59 | 59 | } |
60 | 60 | if ($fulltree[$key2]['level'] == $pos) |
61 | 61 | { |
62 | - $atleastoneofthislevelafter=1; |
|
62 | + $atleastoneofthislevelafter = 1; |
|
63 | 63 | } |
64 | 64 | if ($fulltree[$key2]['level'] <= $pos) |
65 | 65 | { |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | } |
69 | 69 | if ($key2 == $key) // We found ourself, so now every lower level will be counted |
70 | 70 | { |
71 | - $found=1; |
|
71 | + $found = 1; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | //print $atleastoneofthislevelafter; |
75 | 75 | |
76 | - if (! $silent) |
|
76 | + if (!$silent) |
|
77 | 77 | { |
78 | 78 | if ($atleastoneofthislevelafter) |
79 | 79 | { |
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
80 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branch.gif'); |
|
81 | + else print img_picto_common('', 'treemenu/line.gif'); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
85 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branchbottom.gif'); |
|
86 | + else print img_picto_common('', 'treemenu/linebottom.gif'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | $pos++; |
90 | 90 | } |
91 | 91 | |
92 | - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
92 | + return array($atleastoneofthislevelafter, $nbofdirinsub, $nbofdocinsub); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @param int $showfk 1=show fk_links to parent into label (used by menu editor only) |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0) |
|
116 | +function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0) |
|
117 | 117 | { |
118 | 118 | global $tree_recur_alreadyadded; |
119 | 119 | |
120 | - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
|
120 | + if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded = array(); |
|
121 | 121 | |
122 | 122 | if ($rang == 0) |
123 | 123 | { |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | |
142 | 142 | if ($rang > 50) |
143 | 143 | { |
144 | - return; // Protect against infinite loop. Max 50 depth |
|
144 | + return; // Protect against infinite loop. Max 50 depth |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | //ballayage du tableau |
148 | - $sizeoftab=count($tab); |
|
149 | - $ulprinted=0; |
|
150 | - for ($x=0; $x < $sizeoftab; $x++) |
|
148 | + $sizeoftab = count($tab); |
|
149 | + $ulprinted = 0; |
|
150 | + for ($x = 0; $x < $sizeoftab; $x++) |
|
151 | 151 | { |
152 | 152 | //var_dump($tab[$x]);exit; |
153 | 153 | // If an element has $pere for parent |
154 | 154 | if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
155 | 155 | { |
156 | 156 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
157 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
157 | + if (empty($ulprinted) && !empty($pere['rowid'])) |
|
158 | 158 | { |
159 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
159 | + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | 160 | { |
161 | 161 | dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | |
165 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
165 | + print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++; |
|
166 | 166 | } |
167 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
167 | + print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>'; |
|
168 | 168 | if ($showfk) |
169 | 169 | { |
170 | 170 | print '<table class="nobordernopadding centpercent"><tr><td>'; |
@@ -180,26 +180,26 @@ discard block |
||
180 | 180 | print $tab[$x]['entry']; |
181 | 181 | } |
182 | 182 | //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
183 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
183 | + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); |
|
184 | 184 | // And now we search all its sons of lower level |
185 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
185 | + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); |
|
186 | 186 | print '</li>'; |
187 | 187 | } |
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
188 | + elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | 189 | { |
190 | 190 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
191 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
191 | + if (empty($ulprinted) && !empty($pere['rowid'])) |
|
192 | 192 | { |
193 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
193 | + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | 194 | { |
195 | 195 | dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
196 | 196 | //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
197 | 197 | continue; |
198 | 198 | } |
199 | 199 | |
200 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
200 | + print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++; |
|
201 | 201 | } |
202 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
202 | + print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>'; |
|
203 | 203 | if ($showfk) |
204 | 204 | { |
205 | 205 | print '<table class="nobordernopadding centpercent"><tr><td>'; |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | print $tab[$x]['entry']; |
217 | 217 | } |
218 | 218 | //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
219 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
219 | + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); |
|
220 | 220 | // And now we search all its sons of lower level |
221 | 221 | //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
222 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
222 | + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); |
|
223 | 223 | print '</li>'; |
224 | 224 | } |
225 | 225 | } |
226 | - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
226 | + if (!empty($ulprinted) && !empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
227 | 227 | |
228 | 228 | if ($rang == 0) print '</ul>'; |
229 | 229 | } |
@@ -50,12 +50,16 @@ discard block |
||
50 | 50 | foreach($fulltree as $key2 => $val2) |
51 | 51 | { |
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | - if ($found == 1) // We are after the entry to show |
|
53 | + if ($found == 1) { |
|
54 | + // We are after the entry to show |
|
54 | 55 | { |
55 | 56 | if ($fulltree[$key2]['level'] > $pos) |
56 | 57 | { |
57 | 58 | $nbofdirinsub++; |
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | + } |
|
60 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) { |
|
61 | + $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
62 | + } |
|
59 | 63 | } |
60 | 64 | if ($fulltree[$key2]['level'] == $pos) |
61 | 65 | { |
@@ -66,10 +70,12 @@ discard block |
||
66 | 70 | break; |
67 | 71 | } |
68 | 72 | } |
69 | - if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
73 | + if ($key2 == $key) { |
|
74 | + // We found ourself, so now every lower level will be counted |
|
70 | 75 | { |
71 | 76 | $found=1; |
72 | 77 | } |
78 | + } |
|
73 | 79 | } |
74 | 80 | //print $atleastoneofthislevelafter; |
75 | 81 | |
@@ -77,13 +83,18 @@ discard block |
||
77 | 83 | { |
78 | 84 | if ($atleastoneofthislevelafter) |
79 | 85 | { |
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
82 | - } |
|
83 | - else |
|
86 | + if ($fulltree[$key]['level'] == $pos) { |
|
87 | + print img_picto_common('','treemenu/branch.gif'); |
|
88 | + } else { |
|
89 | + print img_picto_common('','treemenu/line.gif'); |
|
90 | + } |
|
91 | + } else |
|
84 | 92 | { |
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
93 | + if ($fulltree[$key]['level'] == $pos) { |
|
94 | + print img_picto_common('','treemenu/branchbottom.gif'); |
|
95 | + } else { |
|
96 | + print img_picto_common('','treemenu/linebottom.gif'); |
|
97 | + } |
|
87 | 98 | } |
88 | 99 | } |
89 | 100 | $pos++; |
@@ -117,7 +128,9 @@ discard block |
||
117 | 128 | { |
118 | 129 | global $tree_recur_alreadyadded; |
119 | 130 | |
120 | - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
|
131 | + if ($rang == 0 && empty($donoresetalreadyloaded)) { |
|
132 | + $tree_recur_alreadyadded=array(); |
|
133 | + } |
|
121 | 134 | |
122 | 135 | if ($rang == 0) |
123 | 136 | { |
@@ -174,8 +187,7 @@ discard block |
||
174 | 187 | print '</td><td align="right">'; |
175 | 188 | print $tab[$x]['buttons']; |
176 | 189 | print '</td></tr></table>'; |
177 | - } |
|
178 | - else |
|
190 | + } else |
|
179 | 191 | { |
180 | 192 | print $tab[$x]['entry']; |
181 | 193 | } |
@@ -184,8 +196,7 @@ discard block |
||
184 | 196 | // And now we search all its sons of lower level |
185 | 197 | tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
186 | 198 | print '</li>'; |
187 | - } |
|
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
199 | + } elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | 200 | { |
190 | 201 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
191 | 202 | if (empty($ulprinted) && ! empty($pere['rowid'])) |
@@ -210,8 +221,7 @@ discard block |
||
210 | 221 | print '</td><td align="right">'; |
211 | 222 | print $tab[$x]['buttons']; |
212 | 223 | print '</td></tr></table>'; |
213 | - } |
|
214 | - else |
|
224 | + } else |
|
215 | 225 | { |
216 | 226 | print $tab[$x]['entry']; |
217 | 227 | } |
@@ -225,6 +235,8 @@ discard block |
||
225 | 235 | } |
226 | 236 | if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
227 | 237 | |
228 | - if ($rang == 0) print '</ul>'; |
|
229 | -} |
|
238 | + if ($rang == 0) { |
|
239 | + print '</ul>'; |
|
240 | + } |
|
241 | + } |
|
230 | 242 |