@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | // $cancel must be defined |
29 | 29 | // $id or $ref must be defined (object is loaded in this file with fetch) |
30 | 30 | |
31 | -if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) |
|
31 | +if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) |
|
32 | 32 | { |
33 | - if (($id > 0 && is_numeric($id)) || ! empty($ref)) // To discard case when id is list of ids like '1,2,3...' |
|
33 | + if (($id > 0 && is_numeric($id)) || !empty($ref)) // To discard case when id is list of ids like '1,2,3...' |
|
34 | 34 | { |
35 | 35 | $ret = $object->fetch($id, $ref); |
36 | 36 | if ($ret > 0) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | else |
42 | 42 | { |
43 | - if (empty($object->error) && ! count($object->errors)) |
|
43 | + if (empty($object->error) && !count($object->errors)) |
|
44 | 44 | { |
45 | 45 | if ($ret < 0) // if $ret == 0, it means not found. |
46 | 46 | { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | } |
50 | 50 | else setEventMessages($object->error, $object->errors, 'errors'); |
51 | - $action=''; |
|
51 | + $action = ''; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | // This script is called with a POST method. |
27 | 27 | // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax |
28 | 28 | |
29 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
30 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
31 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
32 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
29 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
30 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
31 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
32 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
33 | 33 | |
34 | 34 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
35 | +if (!isset($mode) || $mode != 'noajax') // For ajax call |
|
36 | 36 | { |
37 | - $res=@include '../../main.inc.php'; |
|
37 | + $res = @include '../../main.inc.php'; |
|
38 | 38 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 39 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
40 | 40 | include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
@@ -44,58 +44,58 @@ discard block |
||
44 | 44 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } |
45 | 45 | |
46 | 46 | $openeddir = GETPOST('openeddir'); |
47 | - $modulepart= GETPOST('modulepart'); |
|
48 | - $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
47 | + $modulepart = GETPOST('modulepart'); |
|
48 | + $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
49 | 49 | |
50 | 50 | $preopened = GETPOST('preopened'); |
51 | 51 | |
52 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
52 | + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' |
|
53 | 53 | } |
54 | 54 | else // For no ajax call |
55 | 55 | { |
56 | 56 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
57 | 57 | |
58 | 58 | $openeddir = GETPOST('openeddir'); |
59 | - $modulepart= GETPOST('modulepart'); |
|
59 | + $modulepart = GETPOST('modulepart'); |
|
60 | 60 | $selecteddir = GETPOST('dir'); |
61 | 61 | |
62 | 62 | $preopened = GETPOST('preopened'); |
63 | 63 | |
64 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
65 | - if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
64 | + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' |
|
65 | + if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Load translation files required by the page |
69 | 69 | $langs->load("ecm"); |
70 | 70 | |
71 | 71 | // Define fullpathselecteddir. |
72 | -$fullpathselecteddir='<none>'; |
|
72 | +$fullpathselecteddir = '<none>'; |
|
73 | 73 | if ($modulepart == 'ecm') |
74 | 74 | { |
75 | - $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | - $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
75 | + $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | + $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
77 | 77 | } |
78 | 78 | elseif ($modulepart == 'medias') |
79 | 79 | { |
80 | - $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | - $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
80 | + $fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | + $fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | // Security: |
86 | 86 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. |
87 | -if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpathselecteddir)) |
|
87 | +if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) |
|
88 | 88 | { |
89 | 89 | dol_syslog("Refused to deliver file ".$original_file); |
90 | 90 | // Do no show plain path in shown error message |
91 | - dol_print_error(0,$langs->trans("ErrorFileNameInvalid",GETPOST("file"))); |
|
91 | + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); |
|
92 | 92 | exit; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Check permissions |
96 | 96 | if ($modulepart == 'ecm') |
97 | 97 | { |
98 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
98 | + if (!$user->rights->ecm->read) accessforbidden(); |
|
99 | 99 | } |
100 | 100 | elseif ($modulepart == 'medias') |
101 | 101 | { |
@@ -107,22 +107,22 @@ discard block |
||
107 | 107 | * View |
108 | 108 | */ |
109 | 109 | |
110 | -if (! isset($mode) || $mode != 'noajax') // if ajax mode |
|
110 | +if (!isset($mode) || $mode != 'noajax') // if ajax mode |
|
111 | 111 | { |
112 | 112 | top_httphead(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n"; |
116 | -$userstatic=new User($db); |
|
117 | -$form=new Form($db); |
|
116 | +$userstatic = new User($db); |
|
117 | +$form = new Form($db); |
|
118 | 118 | $ecmdirstatic = new EcmDirectory($db); |
119 | 119 | |
120 | 120 | // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir |
121 | -if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); |
|
121 | +if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); |
|
122 | 122 | |
123 | 123 | // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id |
124 | -$current_ecmdir_id=-1; |
|
125 | -foreach($sqltree as $keycursor => $val) |
|
124 | +$current_ecmdir_id = -1; |
|
125 | +foreach ($sqltree as $keycursor => $val) |
|
126 | 126 | { |
127 | 127 | //print $val['fullrelativename']." == ".$selecteddir; |
128 | 128 | if ($val['fullrelativename'] == $selecteddir) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | -if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
134 | +if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
135 | 135 | { |
136 | 136 | treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); |
137 | 137 | |
@@ -159,115 +159,115 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | -if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
162 | +if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
163 | 163 | { |
164 | 164 | print '<ul class="ecmjqft">'; |
165 | 165 | |
166 | 166 | // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir |
167 | - if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow |
|
167 | + if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow |
|
168 | 168 | |
169 | 169 | // ----- This section will show a tree from a fulltree array ----- |
170 | 170 | // $section must also be defined |
171 | 171 | // ---------------------------------------------------------------- |
172 | 172 | |
173 | 173 | // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree) |
174 | - $fullpathselected=''; |
|
175 | - foreach($sqltree as $key => $val) |
|
174 | + $fullpathselected = ''; |
|
175 | + foreach ($sqltree as $key => $val) |
|
176 | 176 | { |
177 | 177 | //print $val['id']."-".$section."<br>"; |
178 | 178 | if ($val['id'] == $section) |
179 | 179 | { |
180 | - $fullpathselected=$val['fullpath']; |
|
180 | + $fullpathselected = $val['fullpath']; |
|
181 | 181 | break; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | //print "fullpathselected=".$fullpathselected."<br>"; |
185 | 185 | |
186 | 186 | // Update expandedsectionarray in session |
187 | - $expandedsectionarray=array(); |
|
188 | - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
187 | + $expandedsectionarray = array(); |
|
188 | + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']); |
|
189 | 189 | |
190 | 190 | if ($section && GETPOST('sectionexpand') == 'true') |
191 | 191 | { |
192 | 192 | // We add all sections that are parent of opened section |
193 | - $pathtosection=explode('_',$fullpathselected); |
|
194 | - foreach($pathtosection as $idcursor) |
|
193 | + $pathtosection = explode('_', $fullpathselected); |
|
194 | + foreach ($pathtosection as $idcursor) |
|
195 | 195 | { |
196 | - if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array |
|
196 | + if ($idcursor && !in_array($idcursor, $expandedsectionarray)) // Not already in array |
|
197 | 197 | { |
198 | - $expandedsectionarray[]=$idcursor; |
|
198 | + $expandedsectionarray[] = $idcursor; |
|
199 | 199 | } |
200 | 200 | } |
201 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
201 | + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); |
|
202 | 202 | } |
203 | 203 | if ($section && GETPOST('sectionexpand') == 'false') |
204 | 204 | { |
205 | 205 | // We removed all expanded sections that are child of the closed section |
206 | - $oldexpandedsectionarray=$expandedsectionarray; |
|
207 | - $expandedsectionarray=array(); // Reset |
|
208 | - foreach($oldexpandedsectionarray as $sectioncursor) |
|
206 | + $oldexpandedsectionarray = $expandedsectionarray; |
|
207 | + $expandedsectionarray = array(); // Reset |
|
208 | + foreach ($oldexpandedsectionarray as $sectioncursor) |
|
209 | 209 | { |
210 | 210 | // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this... |
211 | 211 | //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; |
212 | 212 | } |
213 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
213 | + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); |
|
214 | 214 | } |
215 | 215 | //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>'; |
216 | 216 | |
217 | - $nbofentries=0; |
|
218 | - $oldvallevel=0; |
|
219 | - foreach($sqltree as $key => $val) |
|
217 | + $nbofentries = 0; |
|
218 | + $oldvallevel = 0; |
|
219 | + foreach ($sqltree as $key => $val) |
|
220 | 220 | { |
221 | 221 | |
222 | - $ecmdirstatic->id=$val['id']; |
|
223 | - $ecmdirstatic->ref=$val['label']; |
|
222 | + $ecmdirstatic->id = $val['id']; |
|
223 | + $ecmdirstatic->ref = $val['label']; |
|
224 | 224 | |
225 | 225 | // Refresh cache |
226 | - if (preg_match('/refresh/i',$action)) |
|
226 | + if (preg_match('/refresh/i', $action)) |
|
227 | 227 | { |
228 | - $result=$ecmdirstatic->fetch($val['id']); |
|
229 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
228 | + $result = $ecmdirstatic->fetch($val['id']); |
|
229 | + $ecmdirstatic->ref = $ecmdirstatic->label; |
|
230 | 230 | |
231 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
232 | - $val['cachenbofdoc']=$result; |
|
231 | + $result = $ecmdirstatic->refreshcachenboffile(0); |
|
232 | + $val['cachenbofdoc'] = $result; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); |
236 | 236 | |
237 | 237 | // Define showline |
238 | - $showline=0; |
|
238 | + $showline = 0; |
|
239 | 239 | |
240 | 240 | // If directory is son of expanded directory, we show line |
241 | - if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; |
|
241 | + if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4; |
|
242 | 242 | // If directory is brother of selected directory, we show line |
243 | - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; |
|
243 | + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3; |
|
244 | 244 | // If directory is parent of selected directory or is selected directory, we show line |
245 | - elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; |
|
245 | + elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2; |
|
246 | 246 | // If we are level one we show line |
247 | - elseif ($val['level'] < 2) $showline=1; |
|
247 | + elseif ($val['level'] < 2) $showline = 1; |
|
248 | 248 | |
249 | 249 | if ($showline) |
250 | 250 | { |
251 | - if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; |
|
252 | - else $option='indexnotexpanded'; |
|
251 | + if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded'; |
|
252 | + else $option = 'indexnotexpanded'; |
|
253 | 253 | //print $option; |
254 | 254 | |
255 | 255 | print '<li class="directory collapsed">'; |
256 | 256 | |
257 | 257 | // Show tree graph pictos |
258 | - $cpt=1; |
|
258 | + $cpt = 1; |
|
259 | 259 | while ($cpt < $sqltree[$key]['level']) |
260 | 260 | { |
261 | 261 | print ' '; |
262 | 262 | $cpt++; |
263 | 263 | } |
264 | - $resarray=tree_showpad($sqltree,$key,1); |
|
265 | - $a=$resarray[0]; |
|
266 | - $nbofsubdir=$resarray[1]; |
|
267 | - $nboffilesinsubdir=$resarray[2]; |
|
264 | + $resarray = tree_showpad($sqltree, $key, 1); |
|
265 | + $a = $resarray[0]; |
|
266 | + $nbofsubdir = $resarray[1]; |
|
267 | + $nboffilesinsubdir = $resarray[2]; |
|
268 | 268 | |
269 | 269 | // Show link |
270 | - print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"'); |
|
270 | + print $ecmdirstatic->getNomUrl(0, $option, 32, 'class="fmdirlia jqft ecmjqft"'); |
|
271 | 271 | |
272 | 272 | print '<div class="ecmjqft">'; |
273 | 273 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | |
282 | 282 | // Info |
283 | 283 | print '<td align="center">'; |
284 | - $userstatic->id=$val['fk_user_c']; |
|
285 | - $userstatic->lastname=$val['login_c']; |
|
286 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; |
|
290 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | - $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>'; |
|
292 | - if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
293 | - else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
284 | + $userstatic->id = $val['fk_user_c']; |
|
285 | + $userstatic->lastname = $val['login_c']; |
|
286 | + $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | + $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>'; |
|
290 | + $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>'; |
|
292 | + if ($nbofsubdir) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
293 | + else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
294 | 294 | print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
295 | 295 | print "</td>"; |
296 | 296 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | print "</li>\n"; |
302 | 302 | } |
303 | 303 | |
304 | - $oldvallevel=$val['level']; |
|
304 | + $oldvallevel = $val['level']; |
|
305 | 305 | $nbofentries++; |
306 | 306 | } |
307 | 307 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | |
322 | 322 | // Close db if mode is not noajax |
323 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
323 | +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
324 | 324 | |
325 | 325 | |
326 | 326 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param int $depth Depth |
339 | 339 | * @return void |
340 | 340 | */ |
341 | -function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0) |
|
341 | +function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0) |
|
342 | 342 | { |
343 | 343 | global $conf, $db, $langs, $form; |
344 | 344 | global $dolibarr_main_data_root; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | { |
351 | 351 | $files = @scandir($fullpathselecteddir); |
352 | 352 | |
353 | - if (! empty($files)) |
|
353 | + if (!empty($files)) |
|
354 | 354 | { |
355 | 355 | natcasesort($files); |
356 | 356 | if (count($files) > 2) /* The 2 accounts for . and .. */ |
@@ -362,56 +362,56 @@ discard block |
||
362 | 362 | { |
363 | 363 | if ($file == 'temp') continue; |
364 | 364 | |
365 | - $nbofsubdir=0; |
|
366 | - $nboffilesinsubdir=0; |
|
365 | + $nbofsubdir = 0; |
|
366 | + $nboffilesinsubdir = 0; |
|
367 | 367 | |
368 | - $val=array(); |
|
368 | + $val = array(); |
|
369 | 369 | |
370 | 370 | // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan |
371 | - foreach($sqltree as $key => $tmpval) |
|
371 | + foreach ($sqltree as $key => $tmpval) |
|
372 | 372 | { |
373 | 373 | //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
374 | - if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database |
|
374 | + if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) // We found equivalent record into database |
|
375 | 375 | { |
376 | - $val=$tmpval; |
|
377 | - $resarray=tree_showpad($sqltree,$key,1); |
|
376 | + $val = $tmpval; |
|
377 | + $resarray = tree_showpad($sqltree, $key, 1); |
|
378 | 378 | |
379 | 379 | // Refresh cache for this subdir |
380 | 380 | if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t |
381 | 381 | { |
382 | - $result=$ecmdirstatic->fetch($val['id']); |
|
383 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
382 | + $result = $ecmdirstatic->fetch($val['id']); |
|
383 | + $ecmdirstatic->ref = $ecmdirstatic->label; |
|
384 | 384 | |
385 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
386 | - $val['cachenbofdoc']=$result; |
|
385 | + $result = $ecmdirstatic->refreshcachenboffile(0); |
|
386 | + $val['cachenbofdoc'] = $result; |
|
387 | 387 | } |
388 | 388 | |
389 | - $a=$resarray[0]; |
|
390 | - $nbofsubdir=$resarray[1]; |
|
391 | - $nboffilesinsubdir=$resarray[2]; |
|
389 | + $a = $resarray[0]; |
|
390 | + $nbofsubdir = $resarray[1]; |
|
391 | + $nboffilesinsubdir = $resarray[2]; |
|
392 | 392 | break; |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; |
397 | - if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file))) |
|
397 | + if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) |
|
398 | 398 | { |
399 | 399 | if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) |
400 | 400 | { |
401 | - $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; |
|
402 | - $val['id']=0; |
|
403 | - $val['label']=$file; |
|
404 | - $val['description']=''; |
|
405 | - $nboffilesinsubdir=$langs->trans("Unknown"); |
|
401 | + $val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file; |
|
402 | + $val['id'] = 0; |
|
403 | + $val['label'] = $file; |
|
404 | + $val['description'] = ''; |
|
405 | + $nboffilesinsubdir = $langs->trans("Unknown"); |
|
406 | 406 | } |
407 | 407 | |
408 | - $collapsedorexpanded='collapsed'; |
|
409 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; |
|
410 | - print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
408 | + $collapsedorexpanded = 'collapsed'; |
|
409 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded'; |
|
410 | + print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
411 | 411 | |
412 | 412 | print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
413 | 413 | print "#"; |
414 | - print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\""; |
|
414 | + print "\" rel=\"".dol_escape_htmltag($val['fullrelativename'].'/')."\" id=\"fmdirlia_id_".$val['id']."\""; |
|
415 | 415 | print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")"; |
416 | 416 | print "\">"; |
417 | 417 | print dol_escape_htmltag($file); |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | |
428 | 428 | // Nb of docs |
429 | 429 | print '<td align="right">'; |
430 | - print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; |
|
430 | + print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : ' '; |
|
431 | 431 | print '</td>'; |
432 | 432 | print '<td align="left">'; |
433 | - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
433 | + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
434 | 434 | print '</td>'; |
435 | 435 | |
436 | 436 | // Edit link |
@@ -447,17 +447,17 @@ discard block |
||
447 | 447 | if ($modulepart == 'ecm') |
448 | 448 | { |
449 | 449 | print '<td align="right" width="18">'; |
450 | - $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; |
|
451 | - $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; |
|
452 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>'; |
|
456 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | - $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>'; |
|
458 | - if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
459 | - else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
460 | - print $form->textwithpicto('',$htmltooltip,1,"info"); |
|
450 | + $userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0; |
|
451 | + $userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0; |
|
452 | + $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | + $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>'; |
|
456 | + $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'<br>'; |
|
458 | + if ($nboffilesinsubdir > 0) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
459 | + else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
460 | + print $form->textwithpicto('', $htmltooltip, 1, "info"); |
|
461 | 461 | print "</td>"; |
462 | 462 | } |
463 | 463 | |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | { |
470 | 470 | //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; |
471 | 471 | $newselecteddir = $val['fullrelativename']; |
472 | - $newfullpathselecteddir=''; |
|
472 | + $newfullpathselecteddir = ''; |
|
473 | 473 | if ($modulepart == 'ecm') |
474 | 474 | { |
475 | - $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
475 | + $newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
476 | 476 | } |
477 | 477 | elseif ($modulepart == 'medias') |
478 | 478 | { |
479 | - $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
479 | + $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
480 | 480 | } |
481 | 481 | |
482 | - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
482 | + if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | print "</li>\n"; |
@@ -27,42 +27,42 @@ discard block |
||
27 | 27 | * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx |
28 | 28 | */ |
29 | 29 | |
30 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
31 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
32 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
33 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
30 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
31 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
32 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
33 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
34 | 34 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
35 | +if (!isset($mode) || $mode != 'noajax') // For ajax call |
|
36 | 36 | { |
37 | 37 | require_once '../../main.inc.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; |
41 | 41 | |
42 | - $action=GETPOST('action','aZ09'); |
|
43 | - $file=urldecode(GETPOST('file','alpha')); |
|
44 | - $section=GETPOST("section",'alpha'); |
|
45 | - $module=GETPOST("module",'alpha'); |
|
46 | - $urlsource=GETPOST("urlsource",'alpha'); |
|
47 | - $search_doc_ref=GETPOST('search_doc_ref','alpha'); |
|
42 | + $action = GETPOST('action', 'aZ09'); |
|
43 | + $file = urldecode(GETPOST('file', 'alpha')); |
|
44 | + $section = GETPOST("section", 'alpha'); |
|
45 | + $module = GETPOST("module", 'alpha'); |
|
46 | + $urlsource = GETPOST("urlsource", 'alpha'); |
|
47 | + $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); |
|
48 | 48 | |
49 | - $sortfield = GETPOST("sortfield",'alpha'); |
|
50 | - $sortorder = GETPOST("sortorder",'alpha'); |
|
51 | - $page = GETPOST("page",'int'); |
|
49 | + $sortfield = GETPOST("sortfield", 'alpha'); |
|
50 | + $sortorder = GETPOST("sortorder", 'alpha'); |
|
51 | + $page = GETPOST("page", 'int'); |
|
52 | 52 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
53 | 53 | $offset = $conf->liste_limit * $page; |
54 | 54 | $pageprev = $page - 1; |
55 | 55 | $pagenext = $page + 1; |
56 | - if (! $sortorder) $sortorder="ASC"; |
|
57 | - if (! $sortfield) $sortfield="name"; |
|
56 | + if (!$sortorder) $sortorder = "ASC"; |
|
57 | + if (!$sortfield) $sortfield = "name"; |
|
58 | 58 | |
59 | 59 | $rootdirfordoc = $conf->ecm->dir_output; |
60 | 60 | |
61 | 61 | $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); |
62 | 62 | |
63 | 63 | $ecmdir = new EcmDirectory($db); |
64 | - $result=$ecmdir->fetch($section); |
|
65 | - if (! $result > 0) |
|
64 | + $result = $ecmdir->fetch($section); |
|
65 | + if (!$result > 0) |
|
66 | 66 | { |
67 | 67 | //dol_print_error($db,$ecmdir->error); |
68 | 68 | //exit; |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | $rootdirfordoc = $conf->ecm->dir_output; |
74 | 74 | |
75 | 75 | $ecmdir = new EcmDirectory($db); |
76 | - $relativepath=''; |
|
76 | + $relativepath = ''; |
|
77 | 77 | if ($section > 0) |
78 | 78 | { |
79 | - $result=$ecmdir->fetch($section); |
|
80 | - if (! $result > 0) |
|
79 | + $result = $ecmdir->fetch($section); |
|
80 | + if (!$result > 0) |
|
81 | 81 | { |
82 | - dol_print_error($db,$ecmdir->error); |
|
82 | + dol_print_error($db, $ecmdir->error); |
|
83 | 83 | exit; |
84 | 84 | } |
85 | 85 | |
86 | - $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' |
|
86 | + $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' |
|
87 | 87 | } |
88 | 88 | elseif (GETPOST('section_dir')) |
89 | 89 | { |
90 | - $relativepath=GETPOST('section_dir'); |
|
90 | + $relativepath = GETPOST('section_dir'); |
|
91 | 91 | } |
92 | 92 | //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); |
93 | 93 | |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | |
97 | 97 | if (empty($url)) |
98 | 98 | { |
99 | - if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; |
|
100 | - else $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
99 | + if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php'; |
|
100 | + else $url = DOL_URL_ROOT.'/ecm/index.php'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Load translation files required by the page |
104 | -$langs->loadLangs(array("ecm","companies","other")); |
|
104 | +$langs->loadLangs(array("ecm", "companies", "other")); |
|
105 | 105 | |
106 | 106 | // Security check |
107 | 107 | if ($user->societe_id > 0) $socid = $user->societe_id; |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | // Security: |
112 | 112 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. |
113 | -if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir)) |
|
113 | +if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) |
|
114 | 114 | { |
115 | 115 | dol_syslog("Refused to deliver file ".$upload_dir); |
116 | 116 | // Do no show plain path in shown error message |
117 | - dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$upload_dir)); |
|
117 | + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); |
|
118 | 118 | exit; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Check permissions |
122 | 122 | if ($modulepart == 'ecm') |
123 | 123 | { |
124 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
124 | + if (!$user->rights->ecm->read) accessforbidden(); |
|
125 | 125 | } |
126 | 126 | if ($modulepart == 'medias') |
127 | 127 | { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * View |
142 | 142 | */ |
143 | 143 | |
144 | -if (! isset($mode) || $mode != 'noajax') |
|
144 | +if (!isset($mode) || $mode != 'noajax') |
|
145 | 145 | { |
146 | 146 | // Ajout directives pour resoudre bug IE |
147 | 147 | header('Cache-Control: Public, must-revalidate'); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | top_httphead(); |
151 | 151 | } |
152 | 152 | |
153 | -$type='directory'; |
|
153 | +$type = 'directory'; |
|
154 | 154 | |
155 | 155 | // This test if file exists should be useless. We keep it to find bug more easily |
156 | -if (! dol_is_dir($upload_dir)) |
|
156 | +if (!dol_is_dir($upload_dir)) |
|
157 | 157 | { |
158 | 158 | // dol_mkdir($upload_dir); |
159 | 159 | /* $langs->load("install"); |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | print '<!-- ajaxdirpreview type='.$type.' -->'."\n"; |
165 | 165 | //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
166 | 166 | |
167 | -$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); |
|
168 | -if (! empty($websitekey)) $param.='&website='.$websitekey; |
|
169 | -if (! empty($pageid)) $param.='&pageid='.$pageid; |
|
167 | +$param = ($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : ''); |
|
168 | +if (!empty($websitekey)) $param .= '&website='.$websitekey; |
|
169 | +if (!empty($pageid)) $param .= '&pageid='.$pageid; |
|
170 | 170 | |
171 | 171 | |
172 | 172 | // Dir scan |
173 | 173 | if ($type == 'directory') |
174 | 174 | { |
175 | - $formfile=new FormFile($db); |
|
175 | + $formfile = new FormFile($db); |
|
176 | 176 | |
177 | - $maxlengthname=40; |
|
178 | - $excludefiles = array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview.*\.png)$','^temp$','^payments$','^CVS$','^thumbs$'); |
|
179 | - $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); |
|
177 | + $maxlengthname = 40; |
|
178 | + $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); |
|
179 | + $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); |
|
180 | 180 | |
181 | 181 | // Right area. If module is defined here, we are in automatic ecm. |
182 | 182 | $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday'); |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | // Automatic list |
217 | 217 | if (in_array($module, $automodules)) |
218 | 218 | { |
219 | - $param.='&module='.$module; |
|
220 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
219 | + $param .= '&module='.$module; |
|
220 | + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; |
|
221 | 221 | |
222 | - $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); |
|
222 | + $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); |
|
223 | 223 | |
224 | - if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
224 | + if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
225 | 225 | |
226 | - $filter=preg_quote($search_doc_ref, '/'); |
|
227 | - $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1); |
|
226 | + $filter = preg_quote($search_doc_ref, '/'); |
|
227 | + $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); |
|
228 | 228 | |
229 | - $perm=$user->rights->ecm->upload; |
|
229 | + $perm = $user->rights->ecm->upload; |
|
230 | 230 | |
231 | - $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$perm,1,$textifempty,$maxlengthname,$url,1); |
|
231 | + $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); |
|
232 | 232 | } |
233 | 233 | // Manual list |
234 | 234 | else |
@@ -246,60 +246,60 @@ discard block |
||
246 | 246 | 'max_file_size' => string '2097152' (length=7) |
247 | 247 | 'sendit' => string 'Envoyer fichier' (length=15) |
248 | 248 | */ |
249 | - $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); |
|
250 | - if ($relativepath && $relativepath!= '/') $relativepath.='/'; |
|
249 | + $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); |
|
250 | + if ($relativepath && $relativepath != '/') $relativepath .= '/'; |
|
251 | 251 | $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; |
252 | 252 | if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) |
253 | 253 | { |
254 | - $param.='&file_manager=1'; |
|
255 | - if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha')); |
|
256 | - if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int')); |
|
254 | + $param .= '&file_manager=1'; |
|
255 | + if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha')); |
|
256 | + if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int')); |
|
257 | 257 | //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | else |
261 | 261 | { |
262 | - $relativepath=$ecmdir->getRelativePath(); |
|
262 | + $relativepath = $ecmdir->getRelativePath(); |
|
263 | 263 | $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // If $section defined with value 0 |
267 | 267 | if (($section === '0' || empty($section)) && ($module != 'medias')) |
268 | 268 | { |
269 | - $filearray=array(); |
|
269 | + $filearray = array(); |
|
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); |
|
273 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($section) |
277 | 277 | { |
278 | - $param.='§ion='.$section; |
|
279 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
278 | + $param .= '§ion='.$section; |
|
279 | + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; |
|
280 | 280 | |
281 | 281 | $textifempty = $langs->trans('NoFileFound'); |
282 | 282 | } |
283 | 283 | else if ($section === '0') |
284 | 284 | { |
285 | - if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
285 | + if ($module == 'ecm') $textifempty = '<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
286 | 286 | else $textifempty = $langs->trans('NoFileFound'); |
287 | 287 | } |
288 | - else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); |
|
288 | + else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); |
|
289 | 289 | |
290 | 290 | if ($module == 'medias') |
291 | 291 | { |
292 | 292 | $useinecm = 2; |
293 | - $modulepart='medias'; |
|
294 | - $perm=($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | - $title='none'; |
|
293 | + $modulepart = 'medias'; |
|
294 | + $perm = ($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | + $title = 'none'; |
|
296 | 296 | } |
297 | 297 | else |
298 | 298 | { |
299 | 299 | $useinecm = 1; |
300 | - $modulepart='ecm'; |
|
301 | - $perm=$user->rights->ecm->upload; |
|
302 | - $title=''; // Use default |
|
300 | + $modulepart = 'ecm'; |
|
301 | + $perm = $user->rights->ecm->upload; |
|
302 | + $title = ''; // Use default |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param |
@@ -312,33 +312,33 @@ discard block |
||
312 | 312 | |
313 | 313 | |
314 | 314 | // Bottom of page |
315 | -$useajax=1; |
|
316 | -if (! empty($conf->dol_use_jmobile)) $useajax=0; |
|
317 | -if (empty($conf->use_javascript_ajax)) $useajax=0; |
|
318 | -if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; |
|
315 | +$useajax = 1; |
|
316 | +if (!empty($conf->dol_use_jmobile)) $useajax = 0; |
|
317 | +if (empty($conf->use_javascript_ajax)) $useajax = 0; |
|
318 | +if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; |
|
319 | 319 | |
320 | 320 | //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); |
321 | 321 | |
322 | 322 | if ($useajax || $action == 'delete') |
323 | 323 | { |
324 | - $urlfile=''; |
|
325 | - if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha'); |
|
324 | + $urlfile = ''; |
|
325 | + if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha'); |
|
326 | 326 | |
327 | - if (empty($section_dir)) $section_dir=GETPOST("file","alpha"); |
|
328 | - $section_id=$section; |
|
327 | + if (empty($section_dir)) $section_dir = GETPOST("file", "alpha"); |
|
328 | + $section_id = $section; |
|
329 | 329 | |
330 | 330 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
331 | - $useglobalvars=1; |
|
331 | + $useglobalvars = 1; |
|
332 | 332 | $form = new Form($db); |
333 | - $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | - $formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later |
|
335 | - $formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later |
|
336 | - $formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later |
|
337 | - if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager'); |
|
338 | - if (! empty($websitekey)) $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); |
|
339 | - if (! empty($pageid) && $pageid > 0) $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); |
|
340 | - |
|
341 | - print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); |
|
333 | + $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | + $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later |
|
335 | + $formquestion['section_id'] = array('type'=>'hidden', 'value'=>$section_id, 'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later |
|
336 | + $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later |
|
337 | + if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager'); |
|
338 | + if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website'); |
|
339 | + if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid'); |
|
340 | + |
|
341 | + print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0)); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if ($useajax) |
@@ -376,4 +376,4 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | // Close db if mode is not noajax |
379 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
379 | +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | |
25 | 25 | // This script is called with a POST method or as an include. |
26 | 26 | |
27 | -if (! isset($usedbyinclude) || empty($usedbyinclude)) |
|
27 | +if (!isset($usedbyinclude) || empty($usedbyinclude)) |
|
28 | 28 | { |
29 | - if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
30 | - if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
31 | - if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
32 | - if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
33 | - if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1'); |
|
29 | + if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
30 | + if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
31 | + if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
32 | + if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
33 | + if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); |
|
34 | 34 | |
35 | - $res=@include '../../main.inc.php'; |
|
35 | + $res = @include '../../main.inc.php'; |
|
36 | 36 | if ($res == 'ERROR_NOT_LOGGED') |
37 | 37 | { |
38 | 38 | $langs->load("other"); |
39 | - $arrayresult['jumptologin']=array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>'<span class="fa fa-sign-in"></span> '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); |
|
39 | + $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>'<span class="fa fa-sign-in"></span> '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); |
|
40 | 40 | print json_encode($arrayresult); |
41 | 41 | if (is_object($db)) $db->close(); |
42 | 42 | exit; |
@@ -48,93 +48,93 @@ discard block |
||
48 | 48 | //global $hookmanager; |
49 | 49 | $hookmanager->initHooks(array('searchform')); |
50 | 50 | |
51 | -$search_boxvalue=GETPOST('q', 'none'); |
|
51 | +$search_boxvalue = GETPOST('q', 'none'); |
|
52 | 52 | |
53 | -$arrayresult=array(); |
|
53 | +$arrayresult = array(); |
|
54 | 54 | |
55 | 55 | // Define $searchform |
56 | 56 | |
57 | -if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) |
|
57 | +if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) |
|
58 | 58 | { |
59 | - $arrayresult['searchintomember']=array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
59 | + $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
60 | 60 | } |
61 | 61 | |
62 | -if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) |
|
62 | +if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || !empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) |
|
63 | 63 | { |
64 | - $arrayresult['searchintothirdparty']=array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
64 | + $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
65 | 65 | } |
66 | 66 | |
67 | -if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) |
|
67 | +if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) |
|
68 | 68 | { |
69 | - $arrayresult['searchintocontact']=array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
69 | + $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
70 | 70 | } |
71 | 71 | |
72 | -if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) |
|
72 | +if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire)) |
|
73 | 73 | && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) |
74 | 74 | { |
75 | - $arrayresult['searchintoproduct']=array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
75 | + $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
76 | 76 | } |
77 | 77 | |
78 | -if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) |
|
78 | +if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) |
|
79 | 79 | { |
80 | - $arrayresult['searchintoprojects']=array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
80 | + $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
81 | 81 | } |
82 | -if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) |
|
82 | +if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) |
|
83 | 83 | { |
84 | - $arrayresult['searchintotasks']=array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
84 | + $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
85 | 85 | } |
86 | 86 | |
87 | -if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) |
|
87 | +if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) |
|
88 | 88 | { |
89 | - $arrayresult['searchintopropal']=array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
89 | + $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
90 | 90 | } |
91 | -if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) |
|
91 | +if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) |
|
92 | 92 | { |
93 | - $arrayresult['searchintoorder']=array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
93 | + $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
94 | 94 | } |
95 | -if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) |
|
95 | +if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) |
|
96 | 96 | { |
97 | - $arrayresult['searchintoshipment']=array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
97 | + $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
98 | 98 | } |
99 | -if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) |
|
99 | +if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) |
|
100 | 100 | { |
101 | - $arrayresult['searchintoinvoice']=array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
101 | + $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
102 | 102 | } |
103 | 103 | |
104 | -if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) |
|
104 | +if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) |
|
105 | 105 | { |
106 | - $arrayresult['searchintosupplierpropal']=array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
106 | + $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
107 | 107 | } |
108 | -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) |
|
108 | +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) |
|
109 | 109 | { |
110 | - $arrayresult['searchintosupplierorder']=array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
110 | + $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
111 | 111 | } |
112 | -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) |
|
112 | +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) |
|
113 | 113 | { |
114 | - $arrayresult['searchintosupplierinvoice']=array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
114 | + $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
115 | 115 | } |
116 | 116 | |
117 | -if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) |
|
117 | +if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) |
|
118 | 118 | { |
119 | - $arrayresult['searchintocontract']=array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
119 | + $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
120 | 120 | } |
121 | -if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) |
|
121 | +if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) |
|
122 | 122 | { |
123 | - $arrayresult['searchintointervention']=array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
123 | + $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // HR |
127 | -if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) |
|
127 | +if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) |
|
128 | 128 | { |
129 | - $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
129 | + $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
130 | 130 | } |
131 | -if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) |
|
131 | +if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) |
|
132 | 132 | { |
133 | - $arrayresult['searchintoexpensereport']=array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
133 | + $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); |
|
134 | 134 | } |
135 | -if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) |
|
135 | +if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) |
|
136 | 136 | { |
137 | - $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
137 | + $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,25 +147,25 @@ discard block |
||
147 | 147 | */ |
148 | 148 | |
149 | 149 | // Execute hook addSearchEntry |
150 | -$parameters=array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult); |
|
151 | -$reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); |
|
150 | +$parameters = array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult); |
|
151 | +$reshook = $hookmanager->executeHooks('addSearchEntry', $parameters); |
|
152 | 152 | if (empty($reshook)) |
153 | 153 | { |
154 | - $arrayresult=array_merge($arrayresult, $hookmanager->resArray); |
|
154 | + $arrayresult = array_merge($arrayresult, $hookmanager->resArray); |
|
155 | 155 | } |
156 | -else $arrayresult=$hookmanager->resArray; |
|
156 | +else $arrayresult = $hookmanager->resArray; |
|
157 | 157 | |
158 | 158 | // This allow to keep a search entry to the top |
159 | -if(! empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
|
159 | +if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
|
160 | 160 | $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; |
161 | - if(array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10; |
|
161 | + if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Sort on position |
165 | 165 | $arrayresult = dol_sort_array($arrayresult, 'position'); |
166 | 166 | |
167 | 167 | // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include |
168 | -if (! isset($usedbyinclude) || empty($usedbyinclude)) |
|
168 | +if (!isset($usedbyinclude) || empty($usedbyinclude)) |
|
169 | 169 | { |
170 | 170 | print json_encode($arrayresult); |
171 | 171 | if (is_object($db)) $db->close(); |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | * \brief File to return Ajax response on set extra parameters of elements |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | |
29 | 29 | include '../../main.inc.php'; |
30 | 30 | |
31 | -$id = GETPOST('id','int'); |
|
32 | -$element = GETPOST('element','alpha'); |
|
33 | -$htmlelement = GETPOST('htmlelement','alpha'); |
|
31 | +$id = GETPOST('id', 'int'); |
|
32 | +$element = GETPOST('element', 'alpha'); |
|
33 | +$htmlelement = GETPOST('htmlelement', 'alpha'); |
|
34 | 34 | $type = GETPOST('type', 'alpha'); |
35 | 35 | |
36 | 36 | /* |
@@ -41,37 +41,37 @@ discard block |
||
41 | 41 | |
42 | 42 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
43 | 43 | |
44 | -if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) |
|
44 | +if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) |
|
45 | 45 | { |
46 | - $value = GETPOST('value','alpha'); |
|
47 | - $params=array(); |
|
46 | + $value = GETPOST('value', 'alpha'); |
|
47 | + $params = array(); |
|
48 | 48 | |
49 | 49 | dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); |
50 | 50 | |
51 | 51 | $classpath = $subelement = $element; |
52 | 52 | |
53 | 53 | // For compatibility |
54 | - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | - else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | - else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
54 | + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | + else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | + else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | + else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | + else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | + else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | + else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | + else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
62 | 62 | |
63 | 63 | dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
64 | 64 | |
65 | - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | - else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
65 | + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | + else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | 67 | else $classname = ucfirst($subelement); |
68 | 68 | |
69 | - $object = new $classname($db); |
|
69 | + $object = new $classname($db); |
|
70 | 70 | $object->fetch($id); |
71 | 71 | |
72 | 72 | $params[$htmlelement] = array($type => $value); |
73 | 73 | $object->extraparams = array_merge($object->extraparams, $params); |
74 | 74 | |
75 | - $result=$object->setExtraParameters(); |
|
75 | + $result = $object->setExtraParameters(); |
|
76 | 76 | } |
77 | 77 |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | // Print file |
31 | 31 | if ($action == 'print_file' && $user->rights->printing->read) { |
32 | 32 | $langs->load("printing"); |
33 | - require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; |
|
33 | + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; |
|
34 | 34 | $objectprint = new PrintingDriver($db); |
35 | 35 | $list = $objectprint->listDrivers($db, 10); |
36 | - if (! empty($list)) { |
|
37 | - $errorprint=0; |
|
38 | - $printerfound=0; |
|
36 | + if (!empty($list)) { |
|
37 | + $errorprint = 0; |
|
38 | + $printerfound = 0; |
|
39 | 39 | foreach ($list as $driver) { |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; |
41 | 41 | $langs->load($driver); |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $printer = new $classname($db); |
44 | 44 | //print '<pre>'.print_r($printer, true).'</pre>'; |
45 | 45 | |
46 | - if (! empty($conf->global->{$printer->active})) |
|
46 | + if (!empty($conf->global->{$printer->active})) |
|
47 | 47 | { |
48 | 48 | $printerfound++; |
49 | 49 | |
50 | - $subdir=''; |
|
50 | + $subdir = ''; |
|
51 | 51 | $module = GETPOST('printer', 'alpha'); |
52 | - switch ($module ) |
|
52 | + switch ($module) |
|
53 | 53 | { |
54 | 54 | case 'livraison' : |
55 | 55 | $subdir = 'receipt'; |
@@ -69,21 +69,21 @@ discard block |
||
69 | 69 | //print '<pre>'.print_r($printer->errors, true).'</pre>'; |
70 | 70 | setEventMessages($printer->error, $printer->errors, 'errors'); |
71 | 71 | } |
72 | - if ($ret==0) |
|
72 | + if ($ret == 0) |
|
73 | 73 | { |
74 | 74 | //print '<pre>'.print_r($printer->errors, true).'</pre>'; |
75 | 75 | setEventMessages($printer->error, $printer->errors); |
76 | 76 | setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); |
77 | 77 | } |
78 | 78 | } |
79 | - catch(Exception $e) |
|
79 | + catch (Exception $e) |
|
80 | 80 | { |
81 | 81 | $ret = 1; |
82 | 82 | setEventMessages($e->getMessage(), null, 'errors'); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | - if ($printerfound==0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); |
|
86 | + if ($printerfound == 0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); |
|
87 | 87 | } else { |
88 | 88 | setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); |
89 | 89 | } |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * \brief Return antispam image |
22 | 22 | */ |
23 | 23 | |
24 | -define('NOLOGIN',1); |
|
24 | +define('NOLOGIN', 1); |
|
25 | 25 | |
26 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER',1); |
|
27 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB',1); |
|
28 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN',1); |
|
29 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
30 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC',1); |
|
31 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
26 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', 1); |
|
27 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', 1); |
|
28 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', 1); |
|
29 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); |
|
30 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', 1); |
|
31 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); |
|
32 | 32 | |
33 | 33 | require_once '../main.inc.php'; |
34 | 34 | |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | * View |
38 | 38 | */ |
39 | 39 | |
40 | -$length=5; |
|
40 | +$length = 5; |
|
41 | 41 | $letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679'; |
42 | 42 | $number = strlen($letters); |
43 | 43 | $string = ''; |
44 | -for($i = 0; $i < $length; $i++) |
|
44 | +for ($i = 0; $i < $length; $i++) |
|
45 | 45 | { |
46 | 46 | $string .= $letters{mt_rand(0, $number - 1)}; |
47 | 47 | } |
48 | 48 | //print $string; |
49 | 49 | |
50 | 50 | |
51 | -$sessionkey='dol_antispam_value'; |
|
52 | -$_SESSION[$sessionkey]=$string; |
|
51 | +$sessionkey = 'dol_antispam_value'; |
|
52 | +$_SESSION[$sessionkey] = $string; |
|
53 | 53 | |
54 | -$img = imagecreate(80,32); |
|
54 | +$img = imagecreate(80, 32); |
|
55 | 55 | if (empty($img)) |
56 | 56 | { |
57 | - dol_print_error('',"Problem with GD creation"); |
|
57 | + dol_print_error('', "Problem with GD creation"); |
|
58 | 58 | exit; |
59 | 59 | } |
60 | 60 |
@@ -8,58 +8,58 @@ |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | // Add extra fields |
11 | -$sql="SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.')'; |
|
11 | +$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.')'; |
|
12 | 12 | //print $sql; |
13 | -$resql=$this->db->query($sql); |
|
13 | +$resql = $this->db->query($sql); |
|
14 | 14 | if ($resql) // This can fail when class is used on old database (during migration for example) |
15 | 15 | { |
16 | - while ($obj=$this->db->fetch_object($resql)) |
|
16 | + while ($obj = $this->db->fetch_object($resql)) |
|
17 | 17 | { |
18 | - $fieldname=$keyforaliasextra.'.'.$obj->name; |
|
19 | - $fieldlabel=ucfirst($obj->label); |
|
20 | - $typeFilter="Text"; |
|
21 | - $typefield=preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double |
|
18 | + $fieldname = $keyforaliasextra.'.'.$obj->name; |
|
19 | + $fieldlabel = ucfirst($obj->label); |
|
20 | + $typeFilter = "Text"; |
|
21 | + $typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double |
|
22 | 22 | switch ($typefield) { |
23 | 23 | case 'int': |
24 | 24 | case 'integer': |
25 | 25 | case 'double': |
26 | 26 | case 'price': |
27 | - $typeFilter="Numeric"; |
|
27 | + $typeFilter = "Numeric"; |
|
28 | 28 | break; |
29 | 29 | case 'date': |
30 | 30 | case 'datetime': |
31 | 31 | case 'timestamp': |
32 | - $typeFilter="Date"; |
|
32 | + $typeFilter = "Date"; |
|
33 | 33 | break; |
34 | 34 | case 'boolean': |
35 | - $typeFilter="Boolean"; |
|
35 | + $typeFilter = "Boolean"; |
|
36 | 36 | break; |
37 | 37 | case 'sellist': |
38 | - $tmp=''; |
|
39 | - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
|
38 | + $tmp = ''; |
|
39 | + $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
|
40 | 40 | if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
41 | - $tmpkeys=array_keys($tmpparam['options']); |
|
42 | - $tmp=array_shift($tmpkeys); |
|
41 | + $tmpkeys = array_keys($tmpparam['options']); |
|
42 | + $tmp = array_shift($tmpkeys); |
|
43 | 43 | } |
44 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; |
|
44 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
45 | 45 | break; |
46 | 46 | } |
47 | - if ($obj->type!='separate') |
|
47 | + if ($obj->type != 'separate') |
|
48 | 48 | { |
49 | 49 | // If not a computed field |
50 | 50 | if (empty($obj->fieldcomputed)) |
51 | 51 | { |
52 | - $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
|
53 | - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; |
|
54 | - $this->export_entities_array[$r][$fieldname]=$keyforelement; |
|
52 | + $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
|
53 | + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; |
|
54 | + $this->export_entities_array[$r][$fieldname] = $keyforelement; |
|
55 | 55 | } |
56 | 56 | // If this is a computed field |
57 | 57 | else |
58 | 58 | { |
59 | - $this->export_fields_array[$r][$fieldname]=$fieldlabel; |
|
60 | - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter.'Compute'; |
|
61 | - $this->export_special_array[$r][$fieldname]=$obj->fieldcomputed; |
|
62 | - $this->export_entities_array[$r][$fieldname]=$keyforelement; |
|
59 | + $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
|
60 | + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute'; |
|
61 | + $this->export_special_array[$r][$fieldname] = $obj->fieldcomputed; |
|
62 | + $this->export_entities_array[$r][$fieldname] = $keyforelement; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | |
43 | 43 | |
44 | 44 | // Mass actions. Controls on number of lines checked. |
45 | -$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); |
|
46 | -if (! empty($massaction) && count($toselect) < 1) |
|
45 | +$maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); |
|
46 | +if (!empty($massaction) && count($toselect) < 1) |
|
47 | 47 | { |
48 | 48 | $error++; |
49 | 49 | setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); |
50 | 50 | } |
51 | -if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) |
|
51 | +if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) |
|
52 | 52 | { |
53 | - setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); |
|
53 | + setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); |
|
54 | 54 | $error++; |
55 | 55 | } |
56 | 56 | |
57 | -if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form |
|
57 | +if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form |
|
58 | 58 | { |
59 | - $massaction='presend'; |
|
59 | + $massaction = 'presend'; |
|
60 | 60 | } |
61 | -if (! $error && $massaction == 'confirm_presend') |
|
61 | +if (!$error && $massaction == 'confirm_presend') |
|
62 | 62 | { |
63 | 63 | $resaction = ''; |
64 | 64 | $nbsent = 0; |
@@ -66,64 +66,64 @@ discard block |
||
66 | 66 | $langs->load("mails"); |
67 | 67 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
68 | 68 | |
69 | - $listofobjectid=array(); |
|
70 | - $listofobjectthirdparties=array(); |
|
71 | - $listofobjectref=array(); |
|
69 | + $listofobjectid = array(); |
|
70 | + $listofobjectthirdparties = array(); |
|
71 | + $listofobjectref = array(); |
|
72 | 72 | |
73 | - if (! $error) |
|
73 | + if (!$error) |
|
74 | 74 | { |
75 | - $thirdparty=new Societe($db); |
|
76 | - if ($objecttmp->element == 'expensereport') $thirdparty=new User($db); |
|
77 | - if ($objecttmp->element == 'holiday') $thirdparty=new User($db); |
|
75 | + $thirdparty = new Societe($db); |
|
76 | + if ($objecttmp->element == 'expensereport') $thirdparty = new User($db); |
|
77 | + if ($objecttmp->element == 'holiday') $thirdparty = new User($db); |
|
78 | 78 | |
79 | - $objecttmp=new $objectclass($db); |
|
80 | - foreach($toselect as $toselectid) |
|
79 | + $objecttmp = new $objectclass($db); |
|
80 | + foreach ($toselect as $toselectid) |
|
81 | 81 | { |
82 | - $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use |
|
83 | - $result=$objecttmp->fetch($toselectid); |
|
82 | + $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use |
|
83 | + $result = $objecttmp->fetch($toselectid); |
|
84 | 84 | if ($result > 0) |
85 | 85 | { |
86 | - $listofobjectid[$toselectid]=$toselectid; |
|
87 | - $thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid); |
|
88 | - if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; |
|
89 | - if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author; |
|
90 | - if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user; |
|
91 | - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; |
|
92 | - $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; |
|
86 | + $listofobjectid[$toselectid] = $toselectid; |
|
87 | + $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); |
|
88 | + if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id; |
|
89 | + if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author; |
|
90 | + if ($objecttmp->element == 'holiday') $thirdpartyid = $objecttmp->fk_user; |
|
91 | + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; |
|
92 | + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | 97 | // Check mandatory parameters |
98 | - if (GETPOST('fromtype','alpha') === 'user' && empty($user->email)) |
|
98 | + if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) |
|
99 | 99 | { |
100 | 100 | $error++; |
101 | 101 | setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); |
102 | - $massaction='presend'; |
|
102 | + $massaction = 'presend'; |
|
103 | 103 | } |
104 | 104 | |
105 | - $receiver=$_POST['receiver']; |
|
106 | - if (! is_array($receiver)) |
|
105 | + $receiver = $_POST['receiver']; |
|
106 | + if (!is_array($receiver)) |
|
107 | 107 | { |
108 | - if (empty($receiver) || $receiver == '-1') $receiver=array(); |
|
109 | - else $receiver=array($receiver); |
|
108 | + if (empty($receiver) || $receiver == '-1') $receiver = array(); |
|
109 | + else $receiver = array($receiver); |
|
110 | 110 | } |
111 | - if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory |
|
111 | + if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory |
|
112 | 112 | { |
113 | 113 | $error++; |
114 | 114 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); |
115 | - $massaction='presend'; |
|
115 | + $massaction = 'presend'; |
|
116 | 116 | } |
117 | 117 | |
118 | - if (! GETPOST('subject','none')) |
|
118 | + if (!GETPOST('subject', 'none')) |
|
119 | 119 | { |
120 | 120 | $error++; |
121 | 121 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); |
122 | - $massaction='presend'; |
|
122 | + $massaction = 'presend'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Loop on each recipient/thirdparty |
126 | - if (! $error) |
|
126 | + if (!$error) |
|
127 | 127 | { |
128 | 128 | foreach ($listofobjectthirdparties as $thirdpartyid) |
129 | 129 | { |
@@ -134,21 +134,21 @@ discard block |
||
134 | 134 | exit; |
135 | 135 | } |
136 | 136 | |
137 | - $sendto=''; |
|
138 | - $sendtocc=''; |
|
139 | - $sendtobcc=''; |
|
137 | + $sendto = ''; |
|
138 | + $sendtocc = ''; |
|
139 | + $sendtobcc = ''; |
|
140 | 140 | $sendtoid = array(); |
141 | 141 | |
142 | 142 | // Define $sendto |
143 | - $tmparray=array(); |
|
143 | + $tmparray = array(); |
|
144 | 144 | if (trim($_POST['sendto'])) |
145 | 145 | { |
146 | 146 | // Recipients are provided into free text |
147 | 147 | $tmparray[] = trim($_POST['sendto']); |
148 | 148 | } |
149 | - if (count($receiver)>0) |
|
149 | + if (count($receiver) > 0) |
|
150 | 150 | { |
151 | - foreach($receiver as $key=>$val) |
|
151 | + foreach ($receiver as $key=>$val) |
|
152 | 152 | { |
153 | 153 | // Recipient was provided from combo list |
154 | 154 | if ($val == 'thirdparty') // Id of third party or user |
@@ -157,28 +157,28 @@ discard block |
||
157 | 157 | } |
158 | 158 | elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact |
159 | 159 | { |
160 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
160 | + $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); |
|
161 | 161 | $sendtoid[] = $val; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | - $sendto=implode(',',$tmparray); |
|
165 | + $sendto = implode(',', $tmparray); |
|
166 | 166 | |
167 | 167 | // Define $sendtocc |
168 | - $receivercc=$_POST['receivercc']; |
|
169 | - if (! is_array($receivercc)) |
|
168 | + $receivercc = $_POST['receivercc']; |
|
169 | + if (!is_array($receivercc)) |
|
170 | 170 | { |
171 | - if ($receivercc == '-1') $receivercc=array(); |
|
172 | - else $receivercc=array($receivercc); |
|
171 | + if ($receivercc == '-1') $receivercc = array(); |
|
172 | + else $receivercc = array($receivercc); |
|
173 | 173 | } |
174 | - $tmparray=array(); |
|
174 | + $tmparray = array(); |
|
175 | 175 | if (trim($_POST['sendtocc'])) |
176 | 176 | { |
177 | 177 | $tmparray[] = trim($_POST['sendtocc']); |
178 | 178 | } |
179 | 179 | if (count($receivercc) > 0) |
180 | 180 | { |
181 | - foreach($receivercc as $key=>$val) |
|
181 | + foreach ($receivercc as $key=>$val) |
|
182 | 182 | { |
183 | 183 | // Recipient was provided from combo list |
184 | 184 | if ($val == 'thirdparty') // Id of third party |
@@ -187,41 +187,41 @@ discard block |
||
187 | 187 | } |
188 | 188 | elseif ($val) // Id du contact |
189 | 189 | { |
190 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
190 | + $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); |
|
191 | 191 | //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | - $sendtocc=implode(',',$tmparray); |
|
195 | + $sendtocc = implode(',', $tmparray); |
|
196 | 196 | |
197 | 197 | //var_dump($listofobjectref);exit; |
198 | - $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); |
|
199 | - $listofqualifiedobj=array(); |
|
200 | - $listofqualifiedref=array(); |
|
201 | - $thirdpartywithoutemail=array(); |
|
198 | + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); |
|
199 | + $listofqualifiedobj = array(); |
|
200 | + $listofqualifiedref = array(); |
|
201 | + $thirdpartywithoutemail = array(); |
|
202 | 202 | |
203 | - foreach($listofobjectref[$thirdpartyid] as $objectid => $objectobj) |
|
203 | + foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) |
|
204 | 204 | { |
205 | 205 | //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut); |
206 | 206 | if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) |
207 | 207 | { |
208 | 208 | $langs->load("errors"); |
209 | 209 | $nbignored++; |
210 | - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>'; |
|
210 | + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; |
|
211 | 211 | continue; // Payment done or started or canceled |
212 | 212 | } |
213 | 213 | if ($objectclass == 'Commande' && $objectoj->statut == Commande::STATUS_DRAFT) |
214 | 214 | { |
215 | 215 | $langs->load("errors"); |
216 | 216 | $nbignored++; |
217 | - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$objectobj->ref).'</div><br>'; |
|
217 | + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'</div><br>'; |
|
218 | 218 | continue; |
219 | 219 | } |
220 | 220 | if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) |
221 | 221 | { |
222 | 222 | $langs->load("errors"); |
223 | 223 | $nbignored++; |
224 | - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction',$objectobj->ref).'</div><br>'; |
|
224 | + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'</div><br>'; |
|
225 | 225 | continue; // Payment done or started or canceled |
226 | 226 | } |
227 | 227 | |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | $nbignored++; |
248 | 248 | if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) |
249 | 249 | { |
250 | - $resaction.='<div class="error">'.$langs->trans('NoRecipientEmail',$objectobj->thirdparty->name).'</div><br>'; |
|
250 | + $resaction .= '<div class="error">'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'</div><br>'; |
|
251 | 251 | } |
252 | 252 | dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING); |
253 | - $thirdpartywithoutemail[$objectobj->thirdparty->id]=1; |
|
253 | + $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1; |
|
254 | 254 | continue; |
255 | 255 | } |
256 | 256 | |
@@ -258,33 +258,33 @@ discard block |
||
258 | 258 | { |
259 | 259 | // TODO Use future field $objectobj->fullpathdoc to know where is stored default file |
260 | 260 | // TODO If not defined, use $objectobj->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. |
261 | - $filename=dol_sanitizeFileName($objectobj->ref).'.pdf'; |
|
262 | - $filedir=$uploaddir . '/' . dol_sanitizeFileName($objectobj->ref); |
|
263 | - $file = $filedir . '/' . $filename; |
|
261 | + $filename = dol_sanitizeFileName($objectobj->ref).'.pdf'; |
|
262 | + $filedir = $uploaddir.'/'.dol_sanitizeFileName($objectobj->ref); |
|
263 | + $file = $filedir.'/'.$filename; |
|
264 | 264 | $mime = dol_mimetype($file); |
265 | 265 | |
266 | 266 | if (dol_is_file($file)) |
267 | 267 | { |
268 | 268 | // Create form object |
269 | - $attachedfiles=array( |
|
270 | - 'paths'=>array_merge($attachedfiles['paths'],array($file)), |
|
271 | - 'names'=>array_merge($attachedfiles['names'],array($filename)), |
|
272 | - 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) |
|
269 | + $attachedfiles = array( |
|
270 | + 'paths'=>array_merge($attachedfiles['paths'], array($file)), |
|
271 | + 'names'=>array_merge($attachedfiles['names'], array($filename)), |
|
272 | + 'mimes'=>array_merge($attachedfiles['mimes'], array($mime)) |
|
273 | 273 | ); |
274 | 274 | } |
275 | 275 | else |
276 | 276 | { |
277 | 277 | $nbignored++; |
278 | 278 | $langs->load("errors"); |
279 | - $resaction.='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div><br>'; |
|
279 | + $resaction .= '<div class="error">'.$langs->trans('ErrorCantReadFile', $file).'</div><br>'; |
|
280 | 280 | dol_syslog('Failed to read file: '.$file, LOG_WARNING); |
281 | 281 | continue; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Object of thirdparty qualified |
286 | - $listofqualifiedobj[$objectid]=$objectobj; |
|
287 | - $listofqualifiedref[$objectid]=$objectobj->ref; |
|
286 | + $listofqualifiedobj[$objectid] = $objectobj; |
|
287 | + $listofqualifiedref[$objectid] = $objectobj->ref; |
|
288 | 288 | |
289 | 289 | |
290 | 290 | //var_dump($listofqualifiedref); |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | |
298 | 298 | $fromtype = GETPOST('fromtype'); |
299 | 299 | if ($fromtype === 'user') { |
300 | - $from = $user->getFullName($langs) .' <'.$user->email.'>'; |
|
300 | + $from = $user->getFullName($langs).' <'.$user->email.'>'; |
|
301 | 301 | } |
302 | 302 | elseif ($fromtype === 'company') { |
303 | - $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
303 | + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
304 | 304 | } |
305 | 305 | elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
306 | - $tmp=explode(',', $user->email_aliases); |
|
306 | + $tmp = explode(',', $user->email_aliases); |
|
307 | 307 | $from = trim($tmp[($reg[1] - 1)]); |
308 | 308 | } |
309 | 309 | elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
310 | - $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
310 | + $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
311 | 311 | $from = trim($tmp[($reg[1] - 1)]); |
312 | 312 | } |
313 | 313 | elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
314 | - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
314 | + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
315 | 315 | $resql = $db->query($sql); |
316 | 316 | $obj = $db->fetch_object($resql); |
317 | 317 | if ($obj) |
@@ -320,25 +320,25 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | else { |
323 | - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; |
|
323 | + $from = $_POST['fromname'].' <'.$_POST['frommail'].'>'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | $replyto = $from; |
327 | - $subject = GETPOST('subject','none'); |
|
328 | - $message = GETPOST('message','none'); |
|
327 | + $subject = GETPOST('subject', 'none'); |
|
328 | + $message = GETPOST('message', 'none'); |
|
329 | 329 | |
330 | 330 | $sendtobcc = GETPOST('sendtoccc'); |
331 | - if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); |
|
332 | - if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); |
|
333 | - if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); |
|
334 | - if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); |
|
335 | - if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); |
|
336 | - if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); |
|
331 | + if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); |
|
332 | + if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); |
|
333 | + if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); |
|
334 | + if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); |
|
335 | + if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); |
|
336 | + if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); |
|
337 | 337 | |
338 | 338 | // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) |
339 | - $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0); |
|
340 | - $looparray=array(); |
|
341 | - if (! $oneemailperrecipient) |
|
339 | + $oneemailperrecipient = (GETPOST('oneemailperrecipient') == 'on' ? 1 : 0); |
|
340 | + $looparray = array(); |
|
341 | + if (!$oneemailperrecipient) |
|
342 | 342 | { |
343 | 343 | $looparray = $listofqualifiedobj; |
344 | 344 | foreach ($looparray as $key => $objecttmp) |
@@ -348,34 +348,34 @@ discard block |
||
348 | 348 | } |
349 | 349 | else |
350 | 350 | { |
351 | - $objectforloop=new $objectclass($db); |
|
351 | + $objectforloop = new $objectclass($db); |
|
352 | 352 | $objectforloop->thirdparty = $thirdparty; |
353 | - $looparray[0]=$objectforloop; |
|
353 | + $looparray[0] = $objectforloop; |
|
354 | 354 | } |
355 | 355 | //var_dump($looparray);exit; |
356 | 356 | |
357 | 357 | foreach ($looparray as $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per record |
358 | 358 | { |
359 | 359 | // Make substitution in email content |
360 | - $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); |
|
361 | - $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ',array_keys($listofqualifiedobj)) : $objecttmp->id); |
|
362 | - $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ',$listofqualifiedref) : $objecttmp->ref); |
|
360 | + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); |
|
361 | + $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); |
|
362 | + $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); |
|
363 | 363 | $substitutionarray['__EMAIL__'] = $thirdparty->email; |
364 | 364 | $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; |
365 | 365 | |
366 | - $parameters=array('mode'=>'formemail'); |
|
366 | + $parameters = array('mode'=>'formemail'); |
|
367 | 367 | |
368 | - if ( ! empty( $listofobjectthirdparties ) ) { |
|
368 | + if (!empty($listofobjectthirdparties)) { |
|
369 | 369 | $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; |
370 | 370 | } |
371 | - if ( ! empty( $listofobjectref ) ) { |
|
371 | + if (!empty($listofobjectref)) { |
|
372 | 372 | $parameters['listofobjectref'] = $listofobjectref; |
373 | 373 | } |
374 | 374 | |
375 | 375 | complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); |
376 | 376 | |
377 | - $subject=make_substitutions($subject, $substitutionarray); |
|
378 | - $message=make_substitutions($message, $substitutionarray); |
|
377 | + $subject = make_substitutions($subject, $substitutionarray); |
|
378 | + $message = make_substitutions($message, $substitutionarray); |
|
379 | 379 | |
380 | 380 | $filepath = $attachedfiles['paths']; |
381 | 381 | $filename = $attachedfiles['names']; |
@@ -384,44 +384,44 @@ discard block |
||
384 | 384 | // Define the trackid when emails sent from the mass action |
385 | 385 | if ($oneemailperrecipient) |
386 | 386 | { |
387 | - $trackid='thi'.$thirdparty->id; |
|
388 | - if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id; |
|
389 | - if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id; |
|
387 | + $trackid = 'thi'.$thirdparty->id; |
|
388 | + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; |
|
389 | + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; |
|
390 | 390 | } |
391 | 391 | else |
392 | 392 | { |
393 | - $trackid=strtolower(get_class($objecttmp)); |
|
394 | - if (get_class($objecttmp)=='Contrat') $trackid='con'; |
|
395 | - if (get_class($objecttmp)=='Propal') $trackid='pro'; |
|
396 | - if (get_class($objecttmp)=='Commande') $trackid='ord'; |
|
397 | - if (get_class($objecttmp)=='Facture') $trackid='inv'; |
|
398 | - if (get_class($objecttmp)=='Supplier_Proposal') $trackid='spr'; |
|
399 | - if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor'; |
|
400 | - if (get_class($objecttmp)=='FactureFournisseur') $trackid='sin'; |
|
401 | - |
|
402 | - $trackid.=$objecttmp->id; |
|
393 | + $trackid = strtolower(get_class($objecttmp)); |
|
394 | + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; |
|
395 | + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; |
|
396 | + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; |
|
397 | + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; |
|
398 | + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; |
|
399 | + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; |
|
400 | + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; |
|
401 | + |
|
402 | + $trackid .= $objecttmp->id; |
|
403 | 403 | } |
404 | 404 | //var_dump($filepath); |
405 | 405 | //var_dump($trackid);exit; |
406 | 406 | |
407 | 407 | // Send mail (substitutionarray must be done just before this) |
408 | 408 | require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
409 | - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid); |
|
409 | + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid); |
|
410 | 410 | if ($mailfile->error) |
411 | 411 | { |
412 | - $resaction.='<div class="error">'.$mailfile->error.'</div>'; |
|
412 | + $resaction .= '<div class="error">'.$mailfile->error.'</div>'; |
|
413 | 413 | } |
414 | 414 | else |
415 | 415 | { |
416 | - $result=$mailfile->sendfile(); |
|
416 | + $result = $mailfile->sendfile(); |
|
417 | 417 | if ($result) |
418 | 418 | { |
419 | - $resaction.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'<br>'; // Must not contain " |
|
419 | + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'<br>'; // Must not contain " |
|
420 | 420 | |
421 | - $error=0; |
|
421 | + $error = 0; |
|
422 | 422 | |
423 | 423 | // Insert logs into agenda |
424 | - foreach($listofqualifiedobj as $objid => $objectobj) |
|
424 | + foreach ($listofqualifiedobj as $objid => $objectobj) |
|
425 | 425 | { |
426 | 426 | /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; |
427 | 427 | if ($objectclass == 'Commande') $actiontypecode='AC_COM'; |
@@ -430,24 +430,24 @@ discard block |
||
430 | 430 | if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; |
431 | 431 | if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ |
432 | 432 | |
433 | - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; |
|
433 | + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; |
|
434 | 434 | if ($message) |
435 | 435 | { |
436 | - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); |
|
437 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
|
438 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
|
436 | + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); |
|
437 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); |
|
438 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); |
|
439 | 439 | $actionmsg = dol_concatdesc($actionmsg, $message); |
440 | 440 | } |
441 | - $actionmsg2=''; |
|
441 | + $actionmsg2 = ''; |
|
442 | 442 | |
443 | 443 | // Initialisation donnees |
444 | - $objectobj->sendtoid = 0; |
|
445 | - $objectobj->actionmsg = $actionmsg; // Long text |
|
444 | + $objectobj->sendtoid = 0; |
|
445 | + $objectobj->actionmsg = $actionmsg; // Long text |
|
446 | 446 | $objectobj->actionmsg2 = $actionmsg2; // Short text |
447 | 447 | $objectobj->fk_element = $objid; |
448 | 448 | $objectobj->elementtype = $objectobj->element; |
449 | 449 | |
450 | - $triggername = strtoupper(get_class($objectobj)) .'_SENTBYMAIL'; |
|
450 | + $triggername = strtoupper(get_class($objectobj)).'_SENTBYMAIL'; |
|
451 | 451 | if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL'; |
452 | 452 | if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL'; |
453 | 453 | if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL'; |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL'; |
458 | 458 | if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL'; |
459 | 459 | |
460 | - if (! empty($triggername)) |
|
460 | + if (!empty($triggername)) |
|
461 | 461 | { |
462 | 462 | // Appel des triggers |
463 | - include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"; |
|
464 | - $interface=new Interfaces($db); |
|
465 | - $result=$interface->run_triggers($triggername, $objectobj, $user, $langs, $conf); |
|
466 | - if ($result < 0) { $error++; $errors=$interface->errors; } |
|
463 | + include_once DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"; |
|
464 | + $interface = new Interfaces($db); |
|
465 | + $result = $interface->run_triggers($triggername, $objectobj, $user, $langs, $conf); |
|
466 | + if ($result < 0) { $error++; $errors = $interface->errors; } |
|
467 | 467 | // Fin appel triggers |
468 | 468 | |
469 | 469 | if ($error) |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | $langs->load("other"); |
482 | 482 | if ($mailfile->error) |
483 | 483 | { |
484 | - $resaction.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
|
485 | - $resaction.='<br><div class="error">'.$mailfile->error.'</div>'; |
|
484 | + $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); |
|
485 | + $resaction .= '<br><div class="error">'.$mailfile->error.'</div>'; |
|
486 | 486 | } |
487 | 487 | else |
488 | 488 | { |
489 | - $resaction.='<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>'; |
|
489 | + $resaction .= '<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>'; |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
@@ -494,15 +494,15 @@ discard block |
||
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - $resaction.=($resaction?'<br>':$resaction); |
|
498 | - $resaction.='<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n"; |
|
499 | - $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n<br>"; |
|
500 | - $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n<br>"; |
|
501 | - $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n<br>"; |
|
497 | + $resaction .= ($resaction ? '<br>' : $resaction); |
|
498 | + $resaction .= '<strong>'.$langs->trans("ResultOfMailSending").':</strong><br>'."\n"; |
|
499 | + $resaction .= $langs->trans("NbSelected").': '.count($toselect)."\n<br>"; |
|
500 | + $resaction .= $langs->trans("NbIgnored").': '.($nbignored ? $nbignored : 0)."\n<br>"; |
|
501 | + $resaction .= $langs->trans("NbSent").': '.($nbsent ? $nbsent : 0)."\n<br>"; |
|
502 | 502 | |
503 | 503 | if ($nbsent) |
504 | 504 | { |
505 | - $action=''; // Do not show form post if there was at least one successfull sent |
|
505 | + $action = ''; // Do not show form post if there was at least one successfull sent |
|
506 | 506 | //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); |
507 | 507 | setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); |
508 | 508 | setEventMessages($resaction, null, 'mesgs'); |
@@ -513,14 +513,14 @@ discard block |
||
513 | 513 | setEventMessages($resaction, null, 'warnings'); |
514 | 514 | } |
515 | 515 | |
516 | - $action='list'; |
|
517 | - $massaction=''; |
|
516 | + $action = 'list'; |
|
517 | + $massaction = ''; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | 521 | if ($massaction == 'confirm_createbills') |
522 | 522 | { |
523 | - $orders = GETPOST('toselect','array'); |
|
523 | + $orders = GETPOST('toselect', 'array'); |
|
524 | 524 | $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); |
525 | 525 | $validate_invoices = GETPOST('valdate_invoices', 'int'); |
526 | 526 | |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | |
532 | 532 | $db->begin(); |
533 | 533 | |
534 | - foreach($orders as $id_order) |
|
534 | + foreach ($orders as $id_order) |
|
535 | 535 | { |
536 | 536 | $cmd = new Commande($db); |
537 | 537 | if ($cmd->fetch($id_order) <= 0) continue; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $objecttmp->type = Facture::TYPE_STANDARD; |
545 | 545 | $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; |
546 | 546 | $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; |
547 | - $objecttmp->fk_project = $cmd->fk_project; |
|
547 | + $objecttmp->fk_project = $cmd->fk_project; |
|
548 | 548 | |
549 | 549 | $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); |
550 | 550 | if (empty($datefacture)) |
@@ -558,29 +558,29 @@ discard block |
||
558 | 558 | |
559 | 559 | $res = $objecttmp->create($user); |
560 | 560 | |
561 | - if($res > 0) $nb_bills_created++; |
|
561 | + if ($res > 0) $nb_bills_created++; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | if ($objecttmp->id > 0) |
565 | 565 | { |
566 | 566 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; |
567 | - $sql.= "fk_source"; |
|
568 | - $sql.= ", sourcetype"; |
|
569 | - $sql.= ", fk_target"; |
|
570 | - $sql.= ", targettype"; |
|
571 | - $sql.= ") VALUES ("; |
|
572 | - $sql.= $id_order; |
|
573 | - $sql.= ", '".$objecttmp->origin."'"; |
|
574 | - $sql.= ", ".$objecttmp->id; |
|
575 | - $sql.= ", '".$objecttmp->element."'"; |
|
576 | - $sql.= ")"; |
|
577 | - |
|
578 | - if (! $db->query($sql)) |
|
567 | + $sql .= "fk_source"; |
|
568 | + $sql .= ", sourcetype"; |
|
569 | + $sql .= ", fk_target"; |
|
570 | + $sql .= ", targettype"; |
|
571 | + $sql .= ") VALUES ("; |
|
572 | + $sql .= $id_order; |
|
573 | + $sql .= ", '".$objecttmp->origin."'"; |
|
574 | + $sql .= ", ".$objecttmp->id; |
|
575 | + $sql .= ", '".$objecttmp->element."'"; |
|
576 | + $sql .= ")"; |
|
577 | + |
|
578 | + if (!$db->query($sql)) |
|
579 | 579 | { |
580 | 580 | $error++; |
581 | 581 | } |
582 | 582 | |
583 | - if (! $error) |
|
583 | + if (!$error) |
|
584 | 584 | { |
585 | 585 | $lines = $cmd->lines; |
586 | 586 | if (empty($lines) && method_exists($cmd, 'fetch_lines')) |
@@ -589,27 +589,27 @@ discard block |
||
589 | 589 | $lines = $cmd->lines; |
590 | 590 | } |
591 | 591 | |
592 | - $fk_parent_line=0; |
|
593 | - $num=count($lines); |
|
592 | + $fk_parent_line = 0; |
|
593 | + $num = count($lines); |
|
594 | 594 | |
595 | - for ($i=0;$i<$num;$i++) |
|
595 | + for ($i = 0; $i < $num; $i++) |
|
596 | 596 | { |
597 | - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); |
|
597 | + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); |
|
598 | 598 | if ($lines[$i]->subprice < 0) |
599 | 599 | { |
600 | 600 | // Negative line, we create a discount line |
601 | 601 | $discount = new DiscountAbsolute($db); |
602 | - $discount->fk_soc=$objecttmp->socid; |
|
603 | - $discount->amount_ht=abs($lines[$i]->total_ht); |
|
604 | - $discount->amount_tva=abs($lines[$i]->total_tva); |
|
605 | - $discount->amount_ttc=abs($lines[$i]->total_ttc); |
|
606 | - $discount->tva_tx=$lines[$i]->tva_tx; |
|
607 | - $discount->fk_user=$user->id; |
|
608 | - $discount->description=$desc; |
|
609 | - $discountid=$discount->create($user); |
|
602 | + $discount->fk_soc = $objecttmp->socid; |
|
603 | + $discount->amount_ht = abs($lines[$i]->total_ht); |
|
604 | + $discount->amount_tva = abs($lines[$i]->total_tva); |
|
605 | + $discount->amount_ttc = abs($lines[$i]->total_ttc); |
|
606 | + $discount->tva_tx = $lines[$i]->tva_tx; |
|
607 | + $discount->fk_user = $user->id; |
|
608 | + $discount->description = $desc; |
|
609 | + $discountid = $discount->create($user); |
|
610 | 610 | if ($discountid > 0) |
611 | 611 | { |
612 | - $result=$objecttmp->insert_discount($discountid); |
|
612 | + $result = $objecttmp->insert_discount($discountid); |
|
613 | 613 | //$result=$discount->link_to_invoice($lineid,$id); |
614 | 614 | } |
615 | 615 | else |
@@ -622,17 +622,17 @@ discard block |
||
622 | 622 | else |
623 | 623 | { |
624 | 624 | // Positive line |
625 | - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); |
|
625 | + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); |
|
626 | 626 | // Date start |
627 | - $date_start=false; |
|
628 | - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; |
|
629 | - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; |
|
630 | - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; |
|
627 | + $date_start = false; |
|
628 | + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; |
|
629 | + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; |
|
630 | + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; |
|
631 | 631 | //Date end |
632 | - $date_end=false; |
|
633 | - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; |
|
634 | - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; |
|
635 | - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; |
|
632 | + $date_end = false; |
|
633 | + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; |
|
634 | + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; |
|
635 | + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; |
|
636 | 636 | // Reset fk_parent_line for no child products and special product |
637 | 637 | if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) |
638 | 638 | { |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | ); |
675 | 675 | if ($result > 0) |
676 | 676 | { |
677 | - $lineid=$result; |
|
677 | + $lineid = $result; |
|
678 | 678 | } |
679 | 679 | else |
680 | 680 | { |
681 | - $lineid=0; |
|
681 | + $lineid = 0; |
|
682 | 682 | $error++; |
683 | 683 | break; |
684 | 684 | } |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. |
696 | 696 | |
697 | - if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; |
|
697 | + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; |
|
698 | 698 | else $TFact[$objecttmp->id] = $objecttmp; |
699 | 699 | } |
700 | 700 | |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; |
703 | 703 | $toselect = array(); |
704 | 704 | |
705 | - if (! $error && $validate_invoices) |
|
705 | + if (!$error && $validate_invoices) |
|
706 | 706 | { |
707 | 707 | $massaction = $action = 'builddoc'; |
708 | - foreach($TAllFact as &$objecttmp) |
|
708 | + foreach ($TAllFact as &$objecttmp) |
|
709 | 709 | { |
710 | 710 | $result = $objecttmp->validate($user); |
711 | 711 | if ($result <= 0) |
@@ -720,43 +720,43 @@ discard block |
||
720 | 720 | // Builddoc |
721 | 721 | $donotredirect = 1; |
722 | 722 | $upload_dir = $conf->facture->dir_output; |
723 | - $permissioncreate=$user->rights->facture->creer; |
|
723 | + $permissioncreate = $user->rights->facture->creer; |
|
724 | 724 | include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $massaction = $action = 'confirm_createbills'; |
728 | 728 | } |
729 | 729 | |
730 | - if (! $error) |
|
730 | + if (!$error) |
|
731 | 731 | { |
732 | 732 | $db->commit(); |
733 | 733 | setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); |
734 | 734 | |
735 | 735 | // Make a redirect to avoid to bill twice if we make a refresh or back |
736 | - $param=''; |
|
737 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
738 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
739 | - if ($sall) $param.='&sall='.urlencode($sall); |
|
740 | - if ($socid > 0) $param.='&socid='.urlencode($socid); |
|
741 | - if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut); |
|
742 | - if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday); |
|
743 | - if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth); |
|
744 | - if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear); |
|
745 | - if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday); |
|
746 | - if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth); |
|
747 | - if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear); |
|
748 | - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); |
|
749 | - if ($search_company) $param.='&search_company='.urlencode($search_company); |
|
750 | - if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer); |
|
751 | - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); |
|
752 | - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); |
|
753 | - if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht); |
|
754 | - if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat); |
|
755 | - if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc); |
|
756 | - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); |
|
757 | - if ($show_files) $param.='&show_files=' .urlencode($show_files); |
|
758 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
759 | - if ($billed != '') $param.='&billed='.urlencode($billed); |
|
736 | + $param = ''; |
|
737 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
738 | + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
739 | + if ($sall) $param .= '&sall='.urlencode($sall); |
|
740 | + if ($socid > 0) $param .= '&socid='.urlencode($socid); |
|
741 | + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); |
|
742 | + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); |
|
743 | + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); |
|
744 | + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); |
|
745 | + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); |
|
746 | + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); |
|
747 | + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); |
|
748 | + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); |
|
749 | + if ($search_company) $param .= '&search_company='.urlencode($search_company); |
|
750 | + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); |
|
751 | + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); |
|
752 | + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); |
|
753 | + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); |
|
754 | + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); |
|
755 | + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); |
|
756 | + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); |
|
757 | + if ($show_files) $param .= '&show_files='.urlencode($show_files); |
|
758 | + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
759 | + if ($billed != '') $param .= '&billed='.urlencode($billed); |
|
760 | 760 | |
761 | 761 | header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); |
762 | 762 | exit; |
@@ -764,9 +764,9 @@ discard block |
||
764 | 764 | else |
765 | 765 | { |
766 | 766 | $db->rollback(); |
767 | - $action='create'; |
|
768 | - $_GET["origin"]=$_POST["origin"]; |
|
769 | - $_GET["originid"]=$_POST["originid"]; |
|
767 | + $action = 'create'; |
|
768 | + $_GET["origin"] = $_POST["origin"]; |
|
769 | + $_GET["originid"] = $_POST["originid"]; |
|
770 | 770 | setEventMessages("Error", null, 'errors'); |
771 | 771 | $error++; |
772 | 772 | } |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | } |
823 | 823 | |
824 | 824 | |
825 | -if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) |
|
825 | +if (!$error && $massaction == "builddoc" && $permtoread && !GETPOST('button_search')) |
|
826 | 826 | { |
827 | 827 | if (empty($diroutputmassaction)) |
828 | 828 | { |
@@ -834,36 +834,36 @@ discard block |
||
834 | 834 | require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; |
835 | 835 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
836 | 836 | |
837 | - $objecttmp=new $objectclass($db); |
|
838 | - $listofobjectid=array(); |
|
839 | - $listofobjectthirdparties=array(); |
|
840 | - $listofobjectref=array(); |
|
841 | - foreach($toselect as $toselectid) |
|
837 | + $objecttmp = new $objectclass($db); |
|
838 | + $listofobjectid = array(); |
|
839 | + $listofobjectthirdparties = array(); |
|
840 | + $listofobjectref = array(); |
|
841 | + foreach ($toselect as $toselectid) |
|
842 | 842 | { |
843 | - $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use |
|
844 | - $result=$objecttmp->fetch($toselectid); |
|
843 | + $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use |
|
844 | + $result = $objecttmp->fetch($toselectid); |
|
845 | 845 | if ($result > 0) |
846 | 846 | { |
847 | - $listofobjectid[$toselectid]=$toselectid; |
|
848 | - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; |
|
849 | - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; |
|
850 | - $listofobjectref[$toselectid]=$objecttmp->ref; |
|
847 | + $listofobjectid[$toselectid] = $toselectid; |
|
848 | + $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; |
|
849 | + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; |
|
850 | + $listofobjectref[$toselectid] = $objecttmp->ref; |
|
851 | 851 | } |
852 | 852 | } |
853 | 853 | |
854 | - $arrayofinclusion=array(); |
|
855 | - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'\.pdf$'; |
|
856 | - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files |
|
857 | - $listoffiles = dol_dir_list($uploaddir,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); |
|
854 | + $arrayofinclusion = array(); |
|
855 | + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; |
|
856 | + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files |
|
857 | + $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); |
|
858 | 858 | |
859 | 859 | // build list of files with full path |
860 | 860 | $files = array(); |
861 | - foreach($listofobjectref as $basename) |
|
861 | + foreach ($listofobjectref as $basename) |
|
862 | 862 | { |
863 | 863 | $basename = dol_sanitizeFileName($basename); |
864 | - foreach($listoffiles as $filefound) |
|
864 | + foreach ($listoffiles as $filefound) |
|
865 | 865 | { |
866 | - if (strstr($filefound["name"],$basename)) |
|
866 | + if (strstr($filefound["name"], $basename)) |
|
867 | 867 | { |
868 | 868 | $files[] = $uploaddir.'/'.$basename.'/'.$filefound["name"]; |
869 | 869 | break; |
@@ -873,12 +873,12 @@ discard block |
||
873 | 873 | |
874 | 874 | // Define output language (Here it is not used because we do only merging existing PDF) |
875 | 875 | $outputlangs = $langs; |
876 | - $newlang=''; |
|
877 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); |
|
878 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang; |
|
879 | - if (! empty($newlang)) |
|
876 | + $newlang = ''; |
|
877 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
878 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang; |
|
879 | + if (!empty($newlang)) |
|
880 | 880 | { |
881 | - $outputlangs = new Translate("",$conf); |
|
881 | + $outputlangs = new Translate("", $conf); |
|
882 | 882 | $outputlangs->setDefaultLang($newlang); |
883 | 883 | } |
884 | 884 | |
@@ -888,36 +888,36 @@ discard block |
||
888 | 888 | dol_mkdir($diroutputmassaction); |
889 | 889 | |
890 | 890 | // Defined name of merged file |
891 | - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); |
|
892 | - $filename=preg_replace('/\s/','_',$filename); |
|
891 | + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); |
|
892 | + $filename = preg_replace('/\s/', '_', $filename); |
|
893 | 893 | |
894 | 894 | // Save merged file |
895 | 895 | if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) |
896 | 896 | { |
897 | - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); |
|
898 | - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); |
|
897 | + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); |
|
898 | + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); |
|
899 | 899 | } |
900 | - if ($year) $filename.='_'.$year; |
|
901 | - if ($month) $filename.='_'.$month; |
|
900 | + if ($year) $filename .= '_'.$year; |
|
901 | + if ($month) $filename .= '_'.$month; |
|
902 | 902 | |
903 | - if (count($files)>0) |
|
903 | + if (count($files) > 0) |
|
904 | 904 | { |
905 | - $now=dol_now(); |
|
906 | - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; |
|
905 | + $now = dol_now(); |
|
906 | + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; |
|
907 | 907 | |
908 | 908 | $input_files = ''; |
909 | - foreach($files as $f) { |
|
910 | - $input_files.=' '.escapeshellarg($f); |
|
909 | + foreach ($files as $f) { |
|
910 | + $input_files .= ' '.escapeshellarg($f); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file); |
914 | 914 | exec($cmd); |
915 | 915 | |
916 | - if (! empty($conf->global->MAIN_UMASK)) |
|
916 | + if (!empty($conf->global->MAIN_UMASK)) |
|
917 | 917 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
918 | 918 | |
919 | 919 | $langs->load("exports"); |
920 | - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); |
|
920 | + setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); |
|
921 | 921 | } |
922 | 922 | else |
923 | 923 | { |
@@ -926,12 +926,12 @@ discard block |
||
926 | 926 | } |
927 | 927 | else { |
928 | 928 | // Create empty PDF |
929 | - $formatarray=pdf_getFormat(); |
|
929 | + $formatarray = pdf_getFormat(); |
|
930 | 930 | $page_largeur = $formatarray['width']; |
931 | 931 | $page_hauteur = $formatarray['height']; |
932 | - $format = array($page_largeur,$page_hauteur); |
|
932 | + $format = array($page_largeur, $page_hauteur); |
|
933 | 933 | |
934 | - $pdf=pdf_getInstance($format); |
|
934 | + $pdf = pdf_getInstance($format); |
|
935 | 935 | |
936 | 936 | if (class_exists('TCPDF')) |
937 | 937 | { |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | } |
941 | 941 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
942 | 942 | |
943 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
943 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
944 | 944 | |
945 | 945 | // Add all others |
946 | - foreach($files as $file) |
|
946 | + foreach ($files as $file) |
|
947 | 947 | { |
948 | 948 | // Charge un document PDF depuis un fichier. |
949 | 949 | $pagecount = $pdf->setSourceFile($file); |
@@ -960,27 +960,27 @@ discard block |
||
960 | 960 | dol_mkdir($diroutputmassaction); |
961 | 961 | |
962 | 962 | // Defined name of merged file |
963 | - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); |
|
964 | - $filename=preg_replace('/\s/','_',$filename); |
|
963 | + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); |
|
964 | + $filename = preg_replace('/\s/', '_', $filename); |
|
965 | 965 | |
966 | 966 | // Save merged file |
967 | 967 | if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) |
968 | 968 | { |
969 | - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); |
|
970 | - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); |
|
969 | + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); |
|
970 | + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); |
|
971 | 971 | } |
972 | - if ($year) $filename.='_'.$year; |
|
973 | - if ($month) $filename.='_'.$month; |
|
972 | + if ($year) $filename .= '_'.$year; |
|
973 | + if ($month) $filename .= '_'.$month; |
|
974 | 974 | if ($pagecount) |
975 | 975 | { |
976 | - $now=dol_now(); |
|
977 | - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; |
|
978 | - $pdf->Output($file,'F'); |
|
979 | - if (! empty($conf->global->MAIN_UMASK)) |
|
976 | + $now = dol_now(); |
|
977 | + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; |
|
978 | + $pdf->Output($file, 'F'); |
|
979 | + if (!empty($conf->global->MAIN_UMASK)) |
|
980 | 980 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
981 | 981 | |
982 | 982 | $langs->load("exports"); |
983 | - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); |
|
983 | + setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); |
|
984 | 984 | } |
985 | 985 | else |
986 | 986 | { |
@@ -996,38 +996,38 @@ discard block |
||
996 | 996 | |
997 | 997 | $langs->load("other"); |
998 | 998 | $upload_dir = $diroutputmassaction; |
999 | - $file = $upload_dir . '/' . GETPOST('file'); |
|
1000 | - $ret=dol_delete_file($file); |
|
999 | + $file = $upload_dir.'/'.GETPOST('file'); |
|
1000 | + $ret = dol_delete_file($file); |
|
1001 | 1001 | if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); |
1002 | 1002 | else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); |
1003 | - $action=''; |
|
1003 | + $action = ''; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | // Validate records |
1007 | -if (! $error && $massaction == 'validate' && $permtocreate) |
|
1007 | +if (!$error && $massaction == 'validate' && $permtocreate) |
|
1008 | 1008 | { |
1009 | - $objecttmp=new $objectclass($db); |
|
1009 | + $objecttmp = new $objectclass($db); |
|
1010 | 1010 | |
1011 | - if ($objecttmp->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
1011 | + if ($objecttmp->element == 'invoice' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
1012 | 1012 | { |
1013 | 1013 | $langs->load("errors"); |
1014 | 1014 | setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); |
1015 | 1015 | $error++; |
1016 | 1016 | } |
1017 | - if ($objecttmp->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) |
|
1017 | + if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) |
|
1018 | 1018 | { |
1019 | 1019 | $langs->load("errors"); |
1020 | 1020 | setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); |
1021 | 1021 | $error++; |
1022 | 1022 | } |
1023 | - if (! $error) |
|
1023 | + if (!$error) |
|
1024 | 1024 | { |
1025 | 1025 | $db->begin(); |
1026 | 1026 | |
1027 | 1027 | $nbok = 0; |
1028 | - foreach($toselect as $toselectid) |
|
1028 | + foreach ($toselect as $toselectid) |
|
1029 | 1029 | { |
1030 | - $result=$objecttmp->fetch($toselectid); |
|
1030 | + $result = $objecttmp->fetch($toselectid); |
|
1031 | 1031 | if ($result > 0) |
1032 | 1032 | { |
1033 | 1033 | //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | |
1059 | - if (! $error) |
|
1059 | + if (!$error) |
|
1060 | 1060 | { |
1061 | 1061 | if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); |
1062 | 1062 | else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); |
@@ -1105,15 +1105,15 @@ discard block |
||
1105 | 1105 | } |
1106 | 1106 | } |
1107 | 1107 | // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) |
1108 | -if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permtodelete) |
|
1108 | +if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permtodelete) |
|
1109 | 1109 | { |
1110 | 1110 | $db->begin(); |
1111 | 1111 | |
1112 | - $objecttmp=new $objectclass($db); |
|
1112 | + $objecttmp = new $objectclass($db); |
|
1113 | 1113 | $nbok = 0; |
1114 | - foreach($toselect as $toselectid) |
|
1114 | + foreach ($toselect as $toselectid) |
|
1115 | 1115 | { |
1116 | - $result=$objecttmp->fetch($toselectid); |
|
1116 | + $result = $objecttmp->fetch($toselectid); |
|
1117 | 1117 | if ($result > 0) |
1118 | 1118 | { |
1119 | 1119 | // Refuse deletion for some objects/status |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | { |
1122 | 1122 | $langs->load("errors"); |
1123 | 1123 | $nbignored++; |
1124 | - $resaction.='<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'</div><br>'; |
|
1124 | + $resaction .= '<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'</div><br>'; |
|
1125 | 1125 | continue; |
1126 | 1126 | } |
1127 | 1127 | |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | } |
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if (! $error) |
|
1159 | + if (!$error) |
|
1160 | 1160 | { |
1161 | 1161 | if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); |
1162 | 1162 | else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); |
@@ -1171,36 +1171,36 @@ discard block |
||
1171 | 1171 | |
1172 | 1172 | // Generate document foreach object according to model linked to object |
1173 | 1173 | // @TODO : propose model selection |
1174 | -if (! $error && $massaction == 'generate_doc' && $permtoread) |
|
1174 | +if (!$error && $massaction == 'generate_doc' && $permtoread) |
|
1175 | 1175 | { |
1176 | 1176 | $db->begin(); |
1177 | 1177 | |
1178 | - $objecttmp=new $objectclass($db); |
|
1178 | + $objecttmp = new $objectclass($db); |
|
1179 | 1179 | $nbok = 0; |
1180 | - foreach($toselect as $toselectid) |
|
1180 | + foreach ($toselect as $toselectid) |
|
1181 | 1181 | { |
1182 | - $result=$objecttmp->fetch($toselectid); |
|
1182 | + $result = $objecttmp->fetch($toselectid); |
|
1183 | 1183 | if ($result > 0) |
1184 | 1184 | { |
1185 | 1185 | $outputlangs = $langs; |
1186 | - $newlang=''; |
|
1186 | + $newlang = ''; |
|
1187 | 1187 | |
1188 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); |
|
1189 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang=$objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
1190 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang=$objecttmp->default_lang; // for thirdparty |
|
1191 | - if (! empty($newlang)) |
|
1188 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
1189 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
1190 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty |
|
1191 | + if (!empty($newlang)) |
|
1192 | 1192 | { |
1193 | - $outputlangs = new Translate("",$conf); |
|
1193 | + $outputlangs = new Translate("", $conf); |
|
1194 | 1194 | $outputlangs->setDefaultLang($newlang); |
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // To be sure vars is defined |
1198 | - if (empty($hidedetails)) $hidedetails=0; |
|
1199 | - if (empty($hidedesc)) $hidedesc=0; |
|
1200 | - if (empty($hideref)) $hideref=0; |
|
1201 | - if (empty($moreparams)) $moreparams=null; |
|
1198 | + if (empty($hidedetails)) $hidedetails = 0; |
|
1199 | + if (empty($hidedesc)) $hidedesc = 0; |
|
1200 | + if (empty($hideref)) $hideref = 0; |
|
1201 | + if (empty($moreparams)) $moreparams = null; |
|
1202 | 1202 | |
1203 | - $result= $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); |
|
1203 | + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); |
|
1204 | 1204 | |
1205 | 1205 | if ($result <= 0) |
1206 | 1206 | { |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if (! $error) |
|
1221 | + if (!$error) |
|
1222 | 1222 | { |
1223 | 1223 | if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); |
1224 | 1224 | else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | } |
1231 | 1231 | } |
1232 | 1232 | |
1233 | -$parameters['toselect']=$toselect; |
|
1234 | -$parameters['uploaddir']=$uploaddir; |
|
1233 | +$parameters['toselect'] = $toselect; |
|
1234 | +$parameters['uploaddir'] = $uploaddir; |
|
1235 | 1235 | |
1236 | -$reshook=$hookmanager->executeHooks('doMassActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1236 | +$reshook = $hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1237 | 1237 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
1238 | 1238 | |
1239 | 1239 |