@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | print '<head>'."\n"; |
59 | 59 | if (GETPOST('mode') && GETPOST('mode') == 'test') |
60 | 60 | { |
61 | - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php"></script>'."\n"; |
|
61 | + print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php"></script>'."\n"; |
|
62 | 62 | } |
63 | 63 | else |
64 | 64 | { |
65 | - print '<title>'.$langs->trans("Calendar").'</title>'; |
|
65 | + print '<title>'.$langs->trans("Calendar").'</title>'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Define tradMonths javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | print 'var tradMonths = ['; |
85 | 85 | foreach($tradTemp as $val) |
86 | 86 | { |
87 | - print '"'.addslashes($val).'",'; |
|
87 | + print '"'.addslashes($val).'",'; |
|
88 | 88 | } |
89 | 89 | print '""];'; |
90 | 90 | print '</script>'."\n"; |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | if (! isset($_GET["m"]) || ! isset($_GET["y"])) $qualified=false; |
101 | 101 | if (isset($_GET["m"]) && isset($_GET["y"])) |
102 | 102 | { |
103 | - if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified=false; |
|
104 | - if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified=false; |
|
103 | + if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified=false; |
|
104 | + if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified=false; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // If parameters provided, we show calendar |
108 | 108 | if ($qualified) |
109 | 109 | { |
110 | - //print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit; |
|
111 | - displayBox(GETPOST("sd",'alpha'), GETPOST("m",'int'), GETPOST("y",'int')); |
|
110 | + //print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit; |
|
111 | + displayBox(GETPOST("sd",'alpha'), GETPOST("m",'int'), GETPOST("y",'int')); |
|
112 | 112 | } |
113 | 113 | else |
114 | 114 | { |
115 | - dol_print_error('', 'ErrorBadParameters'); |
|
115 | + dol_print_error('', 'ErrorBadParameters'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function xyzToUnixTimestamp($mysqldate) |
128 | 128 | { |
129 | - $year=substr($mysqldate,0,4); |
|
130 | - $month=substr($mysqldate,4,2); |
|
131 | - $day=substr($mysqldate,6,2); |
|
132 | - $unixtimestamp=dol_mktime(12,0,0,$month,$day,$year); |
|
133 | - return $unixtimestamp; |
|
129 | + $year=substr($mysqldate,0,4); |
|
130 | + $month=substr($mysqldate,4,2); |
|
131 | + $day=substr($mysqldate,6,2); |
|
132 | + $unixtimestamp=dol_mktime(12,0,0,$month,$day,$year); |
|
133 | + return $unixtimestamp; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | */ |
144 | 144 | function displayBox($selectedDate,$month,$year) |
145 | 145 | { |
146 | - global $langs,$conf; |
|
146 | + global $langs,$conf; |
|
147 | 147 | |
148 | - //print "$selectedDate,$month,$year"; |
|
149 | - $thedate=dol_mktime(12,0,0,$month,1,$year); |
|
150 | - //print "thedate=$thedate"; |
|
151 | - $today=dol_now(); |
|
152 | - $todayArray=dol_getdate($today); |
|
153 | - if($selectedDate != "00000000") |
|
154 | - { |
|
155 | - $selDate=xyzToUnixTimestamp($selectedDate); |
|
156 | - $xyz=dol_print_date($selDate,"%Y%m%d"); |
|
157 | - } |
|
158 | - else |
|
159 | - { |
|
160 | - $selDate=0; |
|
161 | - $xyz=0; |
|
162 | - } |
|
163 | - ?> |
|
148 | + //print "$selectedDate,$month,$year"; |
|
149 | + $thedate=dol_mktime(12,0,0,$month,1,$year); |
|
150 | + //print "thedate=$thedate"; |
|
151 | + $today=dol_now(); |
|
152 | + $todayArray=dol_getdate($today); |
|
153 | + if($selectedDate != "00000000") |
|
154 | + { |
|
155 | + $selDate=xyzToUnixTimestamp($selectedDate); |
|
156 | + $xyz=dol_print_date($selDate,"%Y%m%d"); |
|
157 | + } |
|
158 | + else |
|
159 | + { |
|
160 | + $selDate=0; |
|
161 | + $xyz=0; |
|
162 | + } |
|
163 | + ?> |
|
164 | 164 | <table class="dp"> |
165 | 165 | <tr> |
166 | 166 | <td colspan="6" class="dpHead"><?php |
167 | - $selectMonth = dol_print_date($thedate, '%m'); |
|
168 | - $selectYear = dol_print_date($thedate, '%Y'); |
|
169 | - echo $langs->trans("Month".$selectMonth).", ".$selectYear; |
|
170 | - ?></td> |
|
167 | + $selectMonth = dol_print_date($thedate, '%m'); |
|
168 | + $selectYear = dol_print_date($thedate, '%Y'); |
|
169 | + echo $langs->trans("Month".$selectMonth).", ".$selectYear; |
|
170 | + ?></td> |
|
171 | 171 | <td class="dpHead"> |
172 | 172 | <button type="button" class="dpInvisibleButtons" id="DPCancel" |
173 | 173 | onClick="closeDPBox();">X</button> |
@@ -187,102 +187,102 @@ discard block |
||
187 | 187 | </tr> |
188 | 188 | <tr class="dpDayNames"> |
189 | 189 | <?php |
190 | - $startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; |
|
191 | - $day_names = array('ShortSunday', 'ShortMonday', 'ShortTuesday', 'ShortWednesday', 'ShortThursday', 'ShortFriday', 'ShortSaturday'); |
|
192 | - for( $i=0; $i < 7; $i++ ) |
|
193 | - { |
|
194 | - echo '<td width="', (int) (($i+1)*100/7) - (int) ($i*100/7), '%">', $langs->trans($day_names[($i + $startday) % 7]), '</td>', "\n"; |
|
195 | - } |
|
196 | - print '</tr>'; |
|
197 | - //print "x ".$thedate." y"; // $thedate = first day of month |
|
198 | - $firstdate=dol_getdate($thedate); |
|
199 | - //var_dump($firstdateofweek); |
|
200 | - $mydate=dol_get_first_day_week(1, $month, $year, true); // mydate = cursor date |
|
190 | + $startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; |
|
191 | + $day_names = array('ShortSunday', 'ShortMonday', 'ShortTuesday', 'ShortWednesday', 'ShortThursday', 'ShortFriday', 'ShortSaturday'); |
|
192 | + for( $i=0; $i < 7; $i++ ) |
|
193 | + { |
|
194 | + echo '<td width="', (int) (($i+1)*100/7) - (int) ($i*100/7), '%">', $langs->trans($day_names[($i + $startday) % 7]), '</td>', "\n"; |
|
195 | + } |
|
196 | + print '</tr>'; |
|
197 | + //print "x ".$thedate." y"; // $thedate = first day of month |
|
198 | + $firstdate=dol_getdate($thedate); |
|
199 | + //var_dump($firstdateofweek); |
|
200 | + $mydate=dol_get_first_day_week(1, $month, $year, true); // mydate = cursor date |
|
201 | 201 | |
202 | - // Loop on each day of month |
|
203 | - $stoploop=0; $day=1; $cols=0; |
|
204 | - while (! $stoploop) |
|
205 | - { |
|
206 | - //print_r($mydate); |
|
207 | - if ($mydate < $firstdate) // At first run |
|
208 | - { |
|
209 | - echo "<tr class=\"dpWeek\">"; |
|
210 | - //echo $conf->global->MAIN_START_WEEK.' '.$firstdate["wday"].' '.$startday; |
|
211 | - $cols=0; |
|
212 | - for ($i = 0; $i < 7; $i++) |
|
213 | - { |
|
214 | - $w = ($i + $startday) % 7; |
|
215 | - if ($w == $firstdate["wday"]) |
|
216 | - { |
|
217 | - $mydate = $firstdate; |
|
218 | - break; |
|
219 | - } |
|
220 | - echo "<td> </td>"; |
|
221 | - $cols++; |
|
222 | - } |
|
223 | - } |
|
224 | - else |
|
225 | - { |
|
226 | - if ($mydate["wday"] == $startday) |
|
227 | - { |
|
228 | - echo "<tr class=\"dpWeek\">"; |
|
229 | - $cols=0; |
|
230 | - } |
|
231 | - } |
|
202 | + // Loop on each day of month |
|
203 | + $stoploop=0; $day=1; $cols=0; |
|
204 | + while (! $stoploop) |
|
205 | + { |
|
206 | + //print_r($mydate); |
|
207 | + if ($mydate < $firstdate) // At first run |
|
208 | + { |
|
209 | + echo "<tr class=\"dpWeek\">"; |
|
210 | + //echo $conf->global->MAIN_START_WEEK.' '.$firstdate["wday"].' '.$startday; |
|
211 | + $cols=0; |
|
212 | + for ($i = 0; $i < 7; $i++) |
|
213 | + { |
|
214 | + $w = ($i + $startday) % 7; |
|
215 | + if ($w == $firstdate["wday"]) |
|
216 | + { |
|
217 | + $mydate = $firstdate; |
|
218 | + break; |
|
219 | + } |
|
220 | + echo "<td> </td>"; |
|
221 | + $cols++; |
|
222 | + } |
|
223 | + } |
|
224 | + else |
|
225 | + { |
|
226 | + if ($mydate["wday"] == $startday) |
|
227 | + { |
|
228 | + echo "<tr class=\"dpWeek\">"; |
|
229 | + $cols=0; |
|
230 | + } |
|
231 | + } |
|
232 | 232 | |
233 | - $dayclass="dpReg"; |
|
234 | - if($thedate==$selDate) $dayclass="dpSelected"; |
|
235 | - elseif($thedate==$today) $dayclass="dpToday"; |
|
233 | + $dayclass="dpReg"; |
|
234 | + if($thedate==$selDate) $dayclass="dpSelected"; |
|
235 | + elseif($thedate==$today) $dayclass="dpToday"; |
|
236 | 236 | |
237 | - if ($langs->trans("FormatDateShortJavaInput")=="FormatDateShortJavaInput") |
|
238 | - { |
|
239 | - print "ERROR FormatDateShortJavaInput not defined for language ".$langs->defaultlang; |
|
240 | - exit; |
|
241 | - } |
|
237 | + if ($langs->trans("FormatDateShortJavaInput")=="FormatDateShortJavaInput") |
|
238 | + { |
|
239 | + print "ERROR FormatDateShortJavaInput not defined for language ".$langs->defaultlang; |
|
240 | + exit; |
|
241 | + } |
|
242 | 242 | |
243 | - // Sur click dans calendrier, appelle fonction dpClickDay |
|
244 | - echo "<td class=\"".$dayclass."\""; |
|
245 | - echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",tradMonths)\""; |
|
246 | - echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJavaInput")."')\""; |
|
247 | - echo ">".sprintf("%02s",$mydate["mday"])."</td>"; |
|
248 | - $cols++; |
|
243 | + // Sur click dans calendrier, appelle fonction dpClickDay |
|
244 | + echo "<td class=\"".$dayclass."\""; |
|
245 | + echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",tradMonths)\""; |
|
246 | + echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJavaInput")."')\""; |
|
247 | + echo ">".sprintf("%02s",$mydate["mday"])."</td>"; |
|
248 | + $cols++; |
|
249 | 249 | |
250 | - if (($mydate["wday"] + 1) % 7 == $startday) echo "</TR>\n"; |
|
250 | + if (($mydate["wday"] + 1) % 7 == $startday) echo "</TR>\n"; |
|
251 | 251 | |
252 | - //$thedate=strtotime("tomorrow",$thedate); |
|
253 | - $day++; |
|
254 | - $thedate=dol_mktime(12, 0, 0, $month, $day, $year); |
|
255 | - if ($thedate == '') |
|
256 | - { |
|
257 | - $stoploop=1; |
|
258 | - } |
|
259 | - else |
|
260 | - { |
|
261 | - $mydate=dol_getdate($thedate); |
|
262 | - if ($firstdate["month"] != $mydate["month"]) $stoploop=1; |
|
263 | - } |
|
264 | - } |
|
252 | + //$thedate=strtotime("tomorrow",$thedate); |
|
253 | + $day++; |
|
254 | + $thedate=dol_mktime(12, 0, 0, $month, $day, $year); |
|
255 | + if ($thedate == '') |
|
256 | + { |
|
257 | + $stoploop=1; |
|
258 | + } |
|
259 | + else |
|
260 | + { |
|
261 | + $mydate=dol_getdate($thedate); |
|
262 | + if ($firstdate["month"] != $mydate["month"]) $stoploop=1; |
|
263 | + } |
|
264 | + } |
|
265 | 265 | |
266 | - if ($cols < 7) |
|
267 | - { |
|
268 | - for($i=6; $i>=$cols; $i--) echo "<td> </td>"; |
|
269 | - echo "</tr>\n"; |
|
270 | - } |
|
271 | - ?> |
|
266 | + if ($cols < 7) |
|
267 | + { |
|
268 | + for($i=6; $i>=$cols; $i--) echo "<td> </td>"; |
|
269 | + echo "</tr>\n"; |
|
270 | + } |
|
271 | + ?> |
|
272 | 272 | <tr> |
273 | 273 | <td id="dpExp" class="dpExplanation" colspan="7"><?php |
274 | - if($selDate) |
|
275 | - { |
|
276 | - $tempDate=dol_getdate($selDate); |
|
277 | - print $langs->trans("Month".$selectMonth)." "; |
|
278 | - print sprintf("%02s",$tempDate["mday"]); |
|
279 | - print ", ".$selectYear; |
|
280 | - } |
|
281 | - else |
|
282 | - { |
|
283 | - print "Click a Date"; |
|
284 | - } |
|
285 | - ?></td> |
|
274 | + if($selDate) |
|
275 | + { |
|
276 | + $tempDate=dol_getdate($selDate); |
|
277 | + print $langs->trans("Month".$selectMonth)." "; |
|
278 | + print sprintf("%02s",$tempDate["mday"]); |
|
279 | + print ", ".$selectYear; |
|
280 | + } |
|
281 | + else |
|
282 | + { |
|
283 | + print "Click a Date"; |
|
284 | + } |
|
285 | + ?></td> |
|
286 | 286 | </tr> |
287 | 287 | </table> |
288 | 288 | <?php |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | * \brief File to manage popup date selector |
27 | 27 | */ |
28 | 28 | |
29 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // disabled |
|
29 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // disabled |
|
30 | 30 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language |
31 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
31 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
32 | 32 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations |
33 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
34 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
35 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); // disabled |
|
36 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
37 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); |
|
33 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); |
|
34 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); |
|
35 | +if (!defined('NOLOGIN')) define('NOLOGIN', 1); // disabled |
|
36 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); |
|
37 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); |
|
38 | 38 | |
39 | 39 | require_once '../main.inc.php'; |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
41 | 41 | |
42 | -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php |
|
42 | +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php |
|
43 | 43 | |
44 | 44 | // Load translation files required by the page |
45 | -$langs->loadLangs(array("main","agenda")); |
|
45 | +$langs->loadLangs(array("main", "agenda")); |
|
46 | 46 | |
47 | -$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); |
|
48 | -$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); |
|
47 | +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); |
|
48 | +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); |
|
49 | 49 | |
50 | 50 | //var_dump($langs->defaultlang); |
51 | 51 | //var_dump($conf->format_date_short_java); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Define tradMonths javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) |
69 | -$tradTemp=array( |
|
69 | +$tradTemp = array( |
|
70 | 70 | $langs->trans("January"), |
71 | 71 | $langs->trans("February"), |
72 | 72 | $langs->trans("March"), |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ); |
83 | 83 | print '<script type="text/javascript">'; |
84 | 84 | print 'var tradMonths = ['; |
85 | -foreach($tradTemp as $val) |
|
85 | +foreach ($tradTemp as $val) |
|
86 | 86 | { |
87 | 87 | print '"'.addslashes($val).'",'; |
88 | 88 | } |
@@ -93,22 +93,22 @@ discard block |
||
93 | 93 | print '<body>'."\n"; |
94 | 94 | |
95 | 95 | |
96 | -$qualified=true; |
|
96 | +$qualified = true; |
|
97 | 97 | |
98 | -if (! isset($_GET["sd"])) $_GET["sd"]="00000000"; |
|
98 | +if (!isset($_GET["sd"])) $_GET["sd"] = "00000000"; |
|
99 | 99 | |
100 | -if (! isset($_GET["m"]) || ! isset($_GET["y"])) $qualified=false; |
|
100 | +if (!isset($_GET["m"]) || !isset($_GET["y"])) $qualified = false; |
|
101 | 101 | if (isset($_GET["m"]) && isset($_GET["y"])) |
102 | 102 | { |
103 | - if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified=false; |
|
104 | - if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified=false; |
|
103 | + if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified = false; |
|
104 | + if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified = false; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // If parameters provided, we show calendar |
108 | 108 | if ($qualified) |
109 | 109 | { |
110 | 110 | //print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit; |
111 | - displayBox(GETPOST("sd",'alpha'), GETPOST("m",'int'), GETPOST("y",'int')); |
|
111 | + displayBox(GETPOST("sd", 'alpha'), GETPOST("m", 'int'), GETPOST("y", 'int')); |
|
112 | 112 | } |
113 | 113 | else |
114 | 114 | { |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function xyzToUnixTimestamp($mysqldate) |
128 | 128 | { |
129 | - $year=substr($mysqldate,0,4); |
|
130 | - $month=substr($mysqldate,4,2); |
|
131 | - $day=substr($mysqldate,6,2); |
|
132 | - $unixtimestamp=dol_mktime(12,0,0,$month,$day,$year); |
|
129 | + $year = substr($mysqldate, 0, 4); |
|
130 | + $month = substr($mysqldate, 4, 2); |
|
131 | + $day = substr($mysqldate, 6, 2); |
|
132 | + $unixtimestamp = dol_mktime(12, 0, 0, $month, $day, $year); |
|
133 | 133 | return $unixtimestamp; |
134 | 134 | } |
135 | 135 | |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | * @param int $year Year |
142 | 142 | * @return void |
143 | 143 | */ |
144 | -function displayBox($selectedDate,$month,$year) |
|
144 | +function displayBox($selectedDate, $month, $year) |
|
145 | 145 | { |
146 | - global $langs,$conf; |
|
146 | + global $langs, $conf; |
|
147 | 147 | |
148 | 148 | //print "$selectedDate,$month,$year"; |
149 | - $thedate=dol_mktime(12,0,0,$month,1,$year); |
|
149 | + $thedate = dol_mktime(12, 0, 0, $month, 1, $year); |
|
150 | 150 | //print "thedate=$thedate"; |
151 | - $today=dol_now(); |
|
152 | - $todayArray=dol_getdate($today); |
|
153 | - if($selectedDate != "00000000") |
|
151 | + $today = dol_now(); |
|
152 | + $todayArray = dol_getdate($today); |
|
153 | + if ($selectedDate != "00000000") |
|
154 | 154 | { |
155 | - $selDate=xyzToUnixTimestamp($selectedDate); |
|
156 | - $xyz=dol_print_date($selDate,"%Y%m%d"); |
|
155 | + $selDate = xyzToUnixTimestamp($selectedDate); |
|
156 | + $xyz = dol_print_date($selDate, "%Y%m%d"); |
|
157 | 157 | } |
158 | 158 | else |
159 | 159 | { |
160 | - $selDate=0; |
|
161 | - $xyz=0; |
|
160 | + $selDate = 0; |
|
161 | + $xyz = 0; |
|
162 | 162 | } |
163 | 163 | ?> |
164 | 164 | <table class="dp"> |
@@ -175,40 +175,40 @@ discard block |
||
175 | 175 | </tr> |
176 | 176 | <tr> |
177 | 177 | <td class="dpButtons" |
178 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year-1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><<</td> |
|
178 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year - 1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><<</td> |
|
179 | 179 | <td class="dpButtons" |
180 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==1) echo "12"; else echo $month-1?>','<?php if($month==1) echo $year-1; else echo $year?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><</td> |
|
180 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if ($month == 1) echo "12"; else echo $month - 1?>','<?php if ($month == 1) echo $year - 1; else echo $year?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><</td> |
|
181 | 181 | <td colspan="3" class="dpButtons" |
182 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo (int) dol_print_date($today,'%m')?>','<?php echo $todayArray["year"]?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><?php echo '-' ?></td> |
|
182 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo (int) dol_print_date($today, '%m')?>','<?php echo $todayArray["year"]?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><?php echo '-' ?></td> |
|
183 | 183 | <td class="dpButtons" |
184 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==12) echo "1"; else echo $month+1?>','<?php if($month==12) echo $year+1; else echo $year;?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">></td> |
|
184 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if ($month == 12) echo "1"; else echo $month + 1?>','<?php if ($month == 12) echo $year + 1; else echo $year; ?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">></td> |
|
185 | 185 | <td class="dpButtons" |
186 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year+1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">>></td> |
|
186 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year + 1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">>></td> |
|
187 | 187 | </tr> |
188 | 188 | <tr class="dpDayNames"> |
189 | 189 | <?php |
190 | - $startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; |
|
190 | + $startday = isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1; |
|
191 | 191 | $day_names = array('ShortSunday', 'ShortMonday', 'ShortTuesday', 'ShortWednesday', 'ShortThursday', 'ShortFriday', 'ShortSaturday'); |
192 | - for( $i=0; $i < 7; $i++ ) |
|
192 | + for ($i = 0; $i < 7; $i++) |
|
193 | 193 | { |
194 | - echo '<td width="', (int) (($i+1)*100/7) - (int) ($i*100/7), '%">', $langs->trans($day_names[($i + $startday) % 7]), '</td>', "\n"; |
|
194 | + echo '<td width="', (int) (($i + 1) * 100 / 7) - (int) ($i * 100 / 7), '%">', $langs->trans($day_names[($i + $startday) % 7]), '</td>', "\n"; |
|
195 | 195 | } |
196 | 196 | print '</tr>'; |
197 | 197 | //print "x ".$thedate." y"; // $thedate = first day of month |
198 | - $firstdate=dol_getdate($thedate); |
|
198 | + $firstdate = dol_getdate($thedate); |
|
199 | 199 | //var_dump($firstdateofweek); |
200 | - $mydate=dol_get_first_day_week(1, $month, $year, true); // mydate = cursor date |
|
200 | + $mydate = dol_get_first_day_week(1, $month, $year, true); // mydate = cursor date |
|
201 | 201 | |
202 | 202 | // Loop on each day of month |
203 | - $stoploop=0; $day=1; $cols=0; |
|
204 | - while (! $stoploop) |
|
203 | + $stoploop = 0; $day = 1; $cols = 0; |
|
204 | + while (!$stoploop) |
|
205 | 205 | { |
206 | 206 | //print_r($mydate); |
207 | 207 | if ($mydate < $firstdate) // At first run |
208 | 208 | { |
209 | 209 | echo "<tr class=\"dpWeek\">"; |
210 | 210 | //echo $conf->global->MAIN_START_WEEK.' '.$firstdate["wday"].' '.$startday; |
211 | - $cols=0; |
|
211 | + $cols = 0; |
|
212 | 212 | for ($i = 0; $i < 7; $i++) |
213 | 213 | { |
214 | 214 | $w = ($i + $startday) % 7; |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | if ($mydate["wday"] == $startday) |
227 | 227 | { |
228 | 228 | echo "<tr class=\"dpWeek\">"; |
229 | - $cols=0; |
|
229 | + $cols = 0; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - $dayclass="dpReg"; |
|
234 | - if($thedate==$selDate) $dayclass="dpSelected"; |
|
235 | - elseif($thedate==$today) $dayclass="dpToday"; |
|
233 | + $dayclass = "dpReg"; |
|
234 | + if ($thedate == $selDate) $dayclass = "dpSelected"; |
|
235 | + elseif ($thedate == $today) $dayclass = "dpToday"; |
|
236 | 236 | |
237 | - if ($langs->trans("FormatDateShortJavaInput")=="FormatDateShortJavaInput") |
|
237 | + if ($langs->trans("FormatDateShortJavaInput") == "FormatDateShortJavaInput") |
|
238 | 238 | { |
239 | 239 | print "ERROR FormatDateShortJavaInput not defined for language ".$langs->defaultlang; |
240 | 240 | exit; |
@@ -242,40 +242,40 @@ discard block |
||
242 | 242 | |
243 | 243 | // Sur click dans calendrier, appelle fonction dpClickDay |
244 | 244 | echo "<td class=\"".$dayclass."\""; |
245 | - echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",tradMonths)\""; |
|
246 | - echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate,"%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJavaInput")."')\""; |
|
247 | - echo ">".sprintf("%02s",$mydate["mday"])."</td>"; |
|
245 | + echo " onMouseOver=\"dpHighlightDay(".$mydate["year"].",parseInt('".dol_print_date($thedate, "%m")."',10),".$mydate["mday"].",tradMonths)\""; |
|
246 | + echo " onClick=\"dpClickDay(".$mydate["year"].",parseInt('".dol_print_date($thedate, "%m")."',10),".$mydate["mday"].",'".$langs->trans("FormatDateShortJavaInput")."')\""; |
|
247 | + echo ">".sprintf("%02s", $mydate["mday"])."</td>"; |
|
248 | 248 | $cols++; |
249 | 249 | |
250 | 250 | if (($mydate["wday"] + 1) % 7 == $startday) echo "</TR>\n"; |
251 | 251 | |
252 | 252 | //$thedate=strtotime("tomorrow",$thedate); |
253 | 253 | $day++; |
254 | - $thedate=dol_mktime(12, 0, 0, $month, $day, $year); |
|
254 | + $thedate = dol_mktime(12, 0, 0, $month, $day, $year); |
|
255 | 255 | if ($thedate == '') |
256 | 256 | { |
257 | - $stoploop=1; |
|
257 | + $stoploop = 1; |
|
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | - $mydate=dol_getdate($thedate); |
|
262 | - if ($firstdate["month"] != $mydate["month"]) $stoploop=1; |
|
261 | + $mydate = dol_getdate($thedate); |
|
262 | + if ($firstdate["month"] != $mydate["month"]) $stoploop = 1; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | 266 | if ($cols < 7) |
267 | 267 | { |
268 | - for($i=6; $i>=$cols; $i--) echo "<td> </td>"; |
|
268 | + for ($i = 6; $i >= $cols; $i--) echo "<td> </td>"; |
|
269 | 269 | echo "</tr>\n"; |
270 | 270 | } |
271 | 271 | ?> |
272 | 272 | <tr> |
273 | 273 | <td id="dpExp" class="dpExplanation" colspan="7"><?php |
274 | - if($selDate) |
|
274 | + if ($selDate) |
|
275 | 275 | { |
276 | - $tempDate=dol_getdate($selDate); |
|
276 | + $tempDate = dol_getdate($selDate); |
|
277 | 277 | print $langs->trans("Month".$selectMonth)." "; |
278 | - print sprintf("%02s",$tempDate["mday"]); |
|
278 | + print sprintf("%02s", $tempDate["mday"]); |
|
279 | 279 | print ", ".$selectYear; |
280 | 280 | } |
281 | 281 | else |
@@ -26,20 +26,39 @@ discard block |
||
26 | 26 | * \brief File to manage popup date selector |
27 | 27 | */ |
28 | 28 | |
29 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // disabled |
|
29 | +if (! defined('NOREQUIREUSER')) { |
|
30 | + define('NOREQUIREUSER','1'); |
|
31 | +} |
|
32 | +// disabled |
|
30 | 33 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language |
31 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
34 | +if (! defined('NOREQUIRESOC')) { |
|
35 | + define('NOREQUIRESOC','1'); |
|
36 | +} |
|
32 | 37 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations |
33 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
34 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
35 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); // disabled |
|
36 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
37 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); |
|
38 | +if (! defined('NOCSRFCHECK')) { |
|
39 | + define('NOCSRFCHECK',1); |
|
40 | +} |
|
41 | +if (! defined('NOTOKENRENEWAL')) { |
|
42 | + define('NOTOKENRENEWAL',1); |
|
43 | +} |
|
44 | +if (! defined('NOLOGIN')) { |
|
45 | + define('NOLOGIN',1); |
|
46 | +} |
|
47 | +// disabled |
|
48 | +if (! defined('NOREQUIREMENU')) { |
|
49 | + define('NOREQUIREMENU',1); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREHTML')) { |
|
52 | + define('NOREQUIREHTML',1); |
|
53 | +} |
|
38 | 54 | |
39 | 55 | require_once '../main.inc.php'; |
40 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
41 | 57 | |
42 | -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php |
|
58 | +if (GETPOST('lang', 'aZ09')) { |
|
59 | + $langs->setDefaultLang(GETPOST('lang', 'aZ09')); |
|
60 | +} |
|
61 | +// If language was forced on URL by the main.inc.php |
|
43 | 62 | |
44 | 63 | // Load translation files required by the page |
45 | 64 | $langs->loadLangs(array("main","agenda")); |
@@ -59,8 +78,7 @@ discard block |
||
59 | 78 | if (GETPOST('mode') && GETPOST('mode') == 'test') |
60 | 79 | { |
61 | 80 | print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php"></script>'."\n"; |
62 | -} |
|
63 | -else |
|
81 | +} else |
|
64 | 82 | { |
65 | 83 | print '<title>'.$langs->trans("Calendar").'</title>'; |
66 | 84 | } |
@@ -95,22 +113,29 @@ discard block |
||
95 | 113 | |
96 | 114 | $qualified=true; |
97 | 115 | |
98 | -if (! isset($_GET["sd"])) $_GET["sd"]="00000000"; |
|
116 | +if (! isset($_GET["sd"])) { |
|
117 | + $_GET["sd"]="00000000"; |
|
118 | +} |
|
99 | 119 | |
100 | -if (! isset($_GET["m"]) || ! isset($_GET["y"])) $qualified=false; |
|
120 | +if (! isset($_GET["m"]) || ! isset($_GET["y"])) { |
|
121 | + $qualified=false; |
|
122 | +} |
|
101 | 123 | if (isset($_GET["m"]) && isset($_GET["y"])) |
102 | 124 | { |
103 | - if ($_GET["m"] < 1 || $_GET["m"] > 12) $qualified=false; |
|
104 | - if ($_GET["y"] < 0 || $_GET["y"] > 9999) $qualified=false; |
|
105 | -} |
|
125 | + if ($_GET["m"] < 1 || $_GET["m"] > 12) { |
|
126 | + $qualified=false; |
|
127 | + } |
|
128 | + if ($_GET["y"] < 0 || $_GET["y"] > 9999) { |
|
129 | + $qualified=false; |
|
130 | + } |
|
131 | + } |
|
106 | 132 | |
107 | 133 | // If parameters provided, we show calendar |
108 | 134 | if ($qualified) |
109 | 135 | { |
110 | 136 | //print $_GET["cm"].",".$_GET["sd"].",".$_GET["m"].",".$_GET["y"];exit; |
111 | 137 | displayBox(GETPOST("sd",'alpha'), GETPOST("m",'int'), GETPOST("y",'int')); |
112 | -} |
|
113 | -else |
|
138 | +} else |
|
114 | 139 | { |
115 | 140 | dol_print_error('', 'ErrorBadParameters'); |
116 | 141 | } |
@@ -154,8 +179,7 @@ discard block |
||
154 | 179 | { |
155 | 180 | $selDate=xyzToUnixTimestamp($selectedDate); |
156 | 181 | $xyz=dol_print_date($selDate,"%Y%m%d"); |
157 | - } |
|
158 | - else |
|
182 | + } else |
|
159 | 183 | { |
160 | 184 | $selDate=0; |
161 | 185 | $xyz=0; |
@@ -177,11 +201,25 @@ discard block |
||
177 | 201 | <td class="dpButtons" |
178 | 202 | onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year-1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><<</td> |
179 | 203 | <td class="dpButtons" |
180 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==1) echo "12"; else echo $month-1?>','<?php if($month==1) echo $year-1; else echo $year?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><</td> |
|
204 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==1) { |
|
205 | + echo "12"; |
|
206 | +} else { |
|
207 | + echo $month-1?>','<?php if($month==1) echo $year-1; |
|
208 | +} |
|
209 | +else { |
|
210 | + echo $year?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><</td> |
|
181 | 211 | <td colspan="3" class="dpButtons" |
182 | 212 | onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo (int) dol_print_date($today,'%m')?>','<?php echo $todayArray["year"]?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')"><?php echo '-' ?></td> |
183 | 213 | <td class="dpButtons" |
184 | - onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==12) echo "1"; else echo $month+1?>','<?php if($month==12) echo $year+1; else echo $year;?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">></td> |
|
214 | + onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php if($month==12) echo "1"; |
|
215 | +} |
|
216 | +else { |
|
217 | + echo $month+1?>','<?php if($month==12) echo $year+1; |
|
218 | +} |
|
219 | +else { |
|
220 | + echo $year; |
|
221 | +} |
|
222 | +?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">></td> |
|
185 | 223 | <td class="dpButtons" |
186 | 224 | onClick="loadMonth('<?php echo DOL_URL_ROOT.'/core/' ?>','<?php echo $month?>','<?php echo $year+1?>','<?php echo $xyz ?>','<?php echo $langs->defaultlang ?>')">>></td> |
187 | 225 | </tr> |
@@ -204,9 +242,11 @@ discard block |
||
204 | 242 | while (! $stoploop) |
205 | 243 | { |
206 | 244 | //print_r($mydate); |
207 | - if ($mydate < $firstdate) // At first run |
|
245 | + if ($mydate < $firstdate) { |
|
246 | + // At first run |
|
208 | 247 | { |
209 | 248 | echo "<tr class=\"dpWeek\">"; |
249 | + } |
|
210 | 250 | //echo $conf->global->MAIN_START_WEEK.' '.$firstdate["wday"].' '.$startday; |
211 | 251 | $cols=0; |
212 | 252 | for ($i = 0; $i < 7; $i++) |
@@ -220,8 +260,7 @@ discard block |
||
220 | 260 | echo "<td> </td>"; |
221 | 261 | $cols++; |
222 | 262 | } |
223 | - } |
|
224 | - else |
|
263 | + } else |
|
225 | 264 | { |
226 | 265 | if ($mydate["wday"] == $startday) |
227 | 266 | { |
@@ -231,8 +270,11 @@ discard block |
||
231 | 270 | } |
232 | 271 | |
233 | 272 | $dayclass="dpReg"; |
234 | - if($thedate==$selDate) $dayclass="dpSelected"; |
|
235 | - elseif($thedate==$today) $dayclass="dpToday"; |
|
273 | + if($thedate==$selDate) { |
|
274 | + $dayclass="dpSelected"; |
|
275 | + } elseif($thedate==$today) { |
|
276 | + $dayclass="dpToday"; |
|
277 | + } |
|
236 | 278 | |
237 | 279 | if ($langs->trans("FormatDateShortJavaInput")=="FormatDateShortJavaInput") |
238 | 280 | { |
@@ -247,7 +289,9 @@ discard block |
||
247 | 289 | echo ">".sprintf("%02s",$mydate["mday"])."</td>"; |
248 | 290 | $cols++; |
249 | 291 | |
250 | - if (($mydate["wday"] + 1) % 7 == $startday) echo "</TR>\n"; |
|
292 | + if (($mydate["wday"] + 1) % 7 == $startday) { |
|
293 | + echo "</TR>\n"; |
|
294 | + } |
|
251 | 295 | |
252 | 296 | //$thedate=strtotime("tomorrow",$thedate); |
253 | 297 | $day++; |
@@ -255,17 +299,20 @@ discard block |
||
255 | 299 | if ($thedate == '') |
256 | 300 | { |
257 | 301 | $stoploop=1; |
258 | - } |
|
259 | - else |
|
302 | + } else |
|
260 | 303 | { |
261 | 304 | $mydate=dol_getdate($thedate); |
262 | - if ($firstdate["month"] != $mydate["month"]) $stoploop=1; |
|
305 | + if ($firstdate["month"] != $mydate["month"]) { |
|
306 | + $stoploop=1; |
|
307 | + } |
|
263 | 308 | } |
264 | 309 | } |
265 | 310 | |
266 | 311 | if ($cols < 7) |
267 | 312 | { |
268 | - for($i=6; $i>=$cols; $i--) echo "<td> </td>"; |
|
313 | + for($i=6; $i>=$cols; $i--) { |
|
314 | + echo "<td> </td>"; |
|
315 | + } |
|
269 | 316 | echo "</tr>\n"; |
270 | 317 | } |
271 | 318 | ?> |
@@ -277,8 +324,7 @@ discard block |
||
277 | 324 | print $langs->trans("Month".$selectMonth)." "; |
278 | 325 | print sprintf("%02s",$tempDate["mday"]); |
279 | 326 | print ", ".$selectYear; |
280 | - } |
|
281 | - else |
|
327 | + } else |
|
282 | 328 | { |
283 | 329 | print "Click a Date"; |
284 | 330 | } |
@@ -30,44 +30,44 @@ |
||
30 | 30 | |
31 | 31 | if ($action == 'up' && $permissiontoedit) |
32 | 32 | { |
33 | - $object->line_up(GETPOST('rowid')); |
|
33 | + $object->line_up(GETPOST('rowid')); |
|
34 | 34 | |
35 | - // Define output language |
|
36 | - $outputlangs = $langs; |
|
37 | - $newlang = ''; |
|
38 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
39 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
40 | - if (! empty($newlang)) { |
|
41 | - $outputlangs = new Translate("", $conf); |
|
42 | - $outputlangs->setDefaultLang($newlang); |
|
43 | - } |
|
35 | + // Define output language |
|
36 | + $outputlangs = $langs; |
|
37 | + $newlang = ''; |
|
38 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
39 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
40 | + if (! empty($newlang)) { |
|
41 | + $outputlangs = new Translate("", $conf); |
|
42 | + $outputlangs->setDefaultLang($newlang); |
|
43 | + } |
|
44 | 44 | |
45 | - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
46 | - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
47 | - } |
|
45 | + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
46 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
47 | + } |
|
48 | 48 | |
49 | - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
50 | - exit(); |
|
49 | + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
50 | + exit(); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if ($action == 'down' && $permissiontoedit) |
54 | 54 | { |
55 | - $object->line_down(GETPOST('rowid')); |
|
55 | + $object->line_down(GETPOST('rowid')); |
|
56 | 56 | |
57 | - // Define output language |
|
58 | - $outputlangs = $langs; |
|
59 | - $newlang = ''; |
|
60 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
61 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
62 | - if (! empty($newlang)) { |
|
63 | - $outputlangs = new Translate("", $conf); |
|
64 | - $outputlangs->setDefaultLang($newlang); |
|
65 | - } |
|
66 | - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
67 | - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
68 | - } |
|
57 | + // Define output language |
|
58 | + $outputlangs = $langs; |
|
59 | + $newlang = ''; |
|
60 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
61 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
62 | + if (! empty($newlang)) { |
|
63 | + $outputlangs = new Translate("", $conf); |
|
64 | + $outputlangs->setDefaultLang($newlang); |
|
65 | + } |
|
66 | + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
67 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
68 | + } |
|
69 | 69 | |
70 | - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
71 | - exit(); |
|
70 | + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
71 | + exit(); |
|
72 | 72 | } |
73 | 73 |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | // Define output language |
36 | 36 | $outputlangs = $langs; |
37 | 37 | $newlang = ''; |
38 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
38 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
39 | 39 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
40 | - if (! empty($newlang)) { |
|
40 | + if (!empty($newlang)) { |
|
41 | 41 | $outputlangs = new Translate("", $conf); |
42 | 42 | $outputlangs->setDefaultLang($newlang); |
43 | 43 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
47 | 47 | } |
48 | 48 | |
49 | - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
49 | + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); |
|
50 | 50 | exit(); |
51 | 51 | } |
52 | 52 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | // Define output language |
58 | 58 | $outputlangs = $langs; |
59 | 59 | $newlang = ''; |
60 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
60 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
61 | 61 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
62 | - if (! empty($newlang)) { |
|
62 | + if (!empty($newlang)) { |
|
63 | 63 | $outputlangs = new Translate("", $conf); |
64 | 64 | $outputlangs->setDefaultLang($newlang); |
65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
68 | 68 | } |
69 | 69 | |
70 | - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); |
|
70 | + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); |
|
71 | 71 | exit(); |
72 | 72 | } |
73 | 73 |
@@ -35,8 +35,12 @@ discard block |
||
35 | 35 | // Define output language |
36 | 36 | $outputlangs = $langs; |
37 | 37 | $newlang = ''; |
38 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
39 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
38 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
39 | + $newlang = GETPOST('lang_id','aZ09'); |
|
40 | + } |
|
41 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
42 | + $newlang = $object->thirdparty->default_lang; |
|
43 | + } |
|
40 | 44 | if (! empty($newlang)) { |
41 | 45 | $outputlangs = new Translate("", $conf); |
42 | 46 | $outputlangs->setDefaultLang($newlang); |
@@ -57,8 +61,12 @@ discard block |
||
57 | 61 | // Define output language |
58 | 62 | $outputlangs = $langs; |
59 | 63 | $newlang = ''; |
60 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
61 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
64 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
65 | + $newlang = GETPOST('lang_id','aZ09'); |
|
66 | + } |
|
67 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
68 | + $newlang = $object->thirdparty->default_lang; |
|
69 | + } |
|
62 | 70 | if (! empty($newlang)) { |
63 | 71 | $outputlangs = new Translate("", $conf); |
64 | 72 | $outputlangs->setDefaultLang($newlang); |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | // Define $website |
29 | 29 | if (! is_object($website)) |
30 | 30 | { |
31 | - $website=new Website($db); |
|
32 | - $website->fetch(0,$websitekey); |
|
31 | + $website=new Website($db); |
|
32 | + $website->fetch(0,$websitekey); |
|
33 | 33 | } |
34 | 34 | // Define $weblangs |
35 | 35 | if (! is_object($weblangs)) |
36 | 36 | { |
37 | - $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice |
|
37 | + $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice |
|
38 | 38 | } |
39 | 39 | // Define $websitepage if we have $websitepagefile defined |
40 | 40 | if (! $pageid && ! empty($websitepagefile)) |
41 | 41 | { |
42 | - $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); |
|
42 | + $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); |
|
43 | 43 | } |
44 | 44 | if ($pageid > 0) |
45 | 45 | { |
46 | - include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
47 | - $websitepage=new WebsitePage($db); |
|
48 | - $websitepage->fetch($pageid); |
|
46 | + include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
47 | + $websitepage=new WebsitePage($db); |
|
48 | + $websitepage->fetch($pageid); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // A lang was forced, so we change weblangs init |
@@ -53,40 +53,40 @@ discard block |
||
53 | 53 | // A lang was forced, so we check to find if we must make a redirect on translation page |
54 | 54 | if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing page using Dolibarr server or a Native web server |
55 | 55 | { |
56 | - //print_r(get_defined_constants(true));exit; |
|
57 | - if (GETPOST('l','aZ09')) |
|
58 | - { |
|
59 | - $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; |
|
60 | - $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp"; |
|
61 | - $sql.=" WHERE wp.fk_website = ".$website->id; |
|
62 | - $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; |
|
63 | - if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
64 | - $sql.=")"; |
|
65 | - $sql.= " AND wp.lang = '".$db->escape(GETPOST('l','aZ09'))."'"; |
|
56 | + //print_r(get_defined_constants(true));exit; |
|
57 | + if (GETPOST('l','aZ09')) |
|
58 | + { |
|
59 | + $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; |
|
60 | + $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp"; |
|
61 | + $sql.=" WHERE wp.fk_website = ".$website->id; |
|
62 | + $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; |
|
63 | + if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
64 | + $sql.=")"; |
|
65 | + $sql.= " AND wp.lang = '".$db->escape(GETPOST('l','aZ09'))."'"; |
|
66 | 66 | |
67 | - $resql = $db->query($sql); |
|
68 | - if ($resql) |
|
69 | - { |
|
70 | - $obj = $db->fetch_object($resql); |
|
71 | - if ($obj) |
|
72 | - { |
|
73 | - $newpageid = $obj->rowid; |
|
74 | - if ($newpageid != $pageid) // To avoid to make a redirect on same page (infinite loop) |
|
75 | - { |
|
76 | - if (defined('USEDOLIBARRSERVER')) { |
|
77 | - header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l','aZ09')); |
|
78 | - exit; |
|
79 | - } |
|
80 | - else |
|
81 | - { |
|
82 | - $newpageref = $obj->pageurl; |
|
83 | - header("Location: ".$newpageref.'.php?l='.GETPOST('l','aZ09')); |
|
84 | - exit; |
|
85 | - } |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
67 | + $resql = $db->query($sql); |
|
68 | + if ($resql) |
|
69 | + { |
|
70 | + $obj = $db->fetch_object($resql); |
|
71 | + if ($obj) |
|
72 | + { |
|
73 | + $newpageid = $obj->rowid; |
|
74 | + if ($newpageid != $pageid) // To avoid to make a redirect on same page (infinite loop) |
|
75 | + { |
|
76 | + if (defined('USEDOLIBARRSERVER')) { |
|
77 | + header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l','aZ09')); |
|
78 | + exit; |
|
79 | + } |
|
80 | + else |
|
81 | + { |
|
82 | + $newpageref = $obj->pageurl; |
|
83 | + header("Location: ".$newpageref.'.php?l='.GETPOST('l','aZ09')); |
|
84 | + exit; |
|
85 | + } |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // Load websitepage class |
@@ -26,43 +26,43 @@ discard block |
||
26 | 26 | // Load website class |
27 | 27 | include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; |
28 | 28 | // Define $website |
29 | -if (! is_object($website)) |
|
29 | +if (!is_object($website)) |
|
30 | 30 | { |
31 | - $website=new Website($db); |
|
32 | - $website->fetch(0,$websitekey); |
|
31 | + $website = new Website($db); |
|
32 | + $website->fetch(0, $websitekey); |
|
33 | 33 | } |
34 | 34 | // Define $weblangs |
35 | -if (! is_object($weblangs)) |
|
35 | +if (!is_object($weblangs)) |
|
36 | 36 | { |
37 | - $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice |
|
37 | + $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice |
|
38 | 38 | } |
39 | 39 | // Define $websitepage if we have $websitepagefile defined |
40 | -if (! $pageid && ! empty($websitepagefile)) |
|
40 | +if (!$pageid && !empty($websitepagefile)) |
|
41 | 41 | { |
42 | 42 | $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); |
43 | 43 | } |
44 | 44 | if ($pageid > 0) |
45 | 45 | { |
46 | 46 | include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
47 | - $websitepage=new WebsitePage($db); |
|
47 | + $websitepage = new WebsitePage($db); |
|
48 | 48 | $websitepage->fetch($pageid); |
49 | 49 | } |
50 | 50 | |
51 | 51 | // A lang was forced, so we change weblangs init |
52 | -if (GETPOST('l','aZ09')) $weblangs->setDefaultLang(GETPOST('l','aZ09')); |
|
52 | +if (GETPOST('l', 'aZ09')) $weblangs->setDefaultLang(GETPOST('l', 'aZ09')); |
|
53 | 53 | // A lang was forced, so we check to find if we must make a redirect on translation page |
54 | 54 | if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing page using Dolibarr server or a Native web server |
55 | 55 | { |
56 | 56 | //print_r(get_defined_constants(true));exit; |
57 | - if (GETPOST('l','aZ09')) |
|
57 | + if (GETPOST('l', 'aZ09')) |
|
58 | 58 | { |
59 | - $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; |
|
60 | - $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp"; |
|
61 | - $sql.=" WHERE wp.fk_website = ".$website->id; |
|
62 | - $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; |
|
63 | - if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
64 | - $sql.=")"; |
|
65 | - $sql.= " AND wp.lang = '".$db->escape(GETPOST('l','aZ09'))."'"; |
|
59 | + $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; |
|
60 | + $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; |
|
61 | + $sql .= " WHERE wp.fk_website = ".$website->id; |
|
62 | + $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; |
|
63 | + if (is_object($websitepage) && $websitepage->fk_page > 0) $sql .= " OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
64 | + $sql .= ")"; |
|
65 | + $sql .= " AND wp.lang = '".$db->escape(GETPOST('l', 'aZ09'))."'"; |
|
66 | 66 | |
67 | 67 | $resql = $db->query($sql); |
68 | 68 | if ($resql) |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | if ($newpageid != $pageid) // To avoid to make a redirect on same page (infinite loop) |
75 | 75 | { |
76 | 76 | if (defined('USEDOLIBARRSERVER')) { |
77 | - header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l','aZ09')); |
|
77 | + header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l', 'aZ09')); |
|
78 | 78 | exit; |
79 | 79 | } |
80 | 80 | else |
81 | 81 | { |
82 | 82 | $newpageref = $obj->pageurl; |
83 | - header("Location: ".$newpageref.'.php?l='.GETPOST('l','aZ09')); |
|
83 | + header("Location: ".$newpageref.'.php?l='.GETPOST('l', 'aZ09')); |
|
84 | 84 | exit; |
85 | 85 | } |
86 | 86 | } |
@@ -49,18 +49,24 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | // A lang was forced, so we change weblangs init |
52 | -if (GETPOST('l','aZ09')) $weblangs->setDefaultLang(GETPOST('l','aZ09')); |
|
52 | +if (GETPOST('l','aZ09')) { |
|
53 | + $weblangs->setDefaultLang(GETPOST('l','aZ09')); |
|
54 | +} |
|
53 | 55 | // A lang was forced, so we check to find if we must make a redirect on translation page |
54 | -if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing page using Dolibarr server or a Native web server |
|
56 | +if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') { |
|
57 | + // If we browsing page using Dolibarr server or a Native web server |
|
55 | 58 | { |
56 | 59 | //print_r(get_defined_constants(true));exit; |
57 | 60 | if (GETPOST('l','aZ09')) |
58 | 61 | { |
59 | 62 | $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; |
63 | +} |
|
60 | 64 | $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp"; |
61 | 65 | $sql.=" WHERE wp.fk_website = ".$website->id; |
62 | 66 | $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; |
63 | - if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
67 | + if (is_object($websitepage) && $websitepage->fk_page > 0) { |
|
68 | + $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; |
|
69 | + } |
|
64 | 70 | $sql.=")"; |
65 | 71 | $sql.= " AND wp.lang = '".$db->escape(GETPOST('l','aZ09'))."'"; |
66 | 72 | |
@@ -71,13 +77,14 @@ discard block |
||
71 | 77 | if ($obj) |
72 | 78 | { |
73 | 79 | $newpageid = $obj->rowid; |
74 | - if ($newpageid != $pageid) // To avoid to make a redirect on same page (infinite loop) |
|
80 | + if ($newpageid != $pageid) { |
|
81 | + // To avoid to make a redirect on same page (infinite loop) |
|
75 | 82 | { |
76 | 83 | if (defined('USEDOLIBARRSERVER')) { |
77 | 84 | header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l','aZ09')); |
85 | + } |
|
78 | 86 | exit; |
79 | - } |
|
80 | - else |
|
87 | + } else |
|
81 | 88 | { |
82 | 89 | $newpageref = $obj->pageurl; |
83 | 90 | header("Location: ".$newpageref.'.php?l='.GETPOST('l','aZ09')); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $head[$h][1] = $langs->trans("UserConf"); |
62 | 62 | $head[$h][2] = 'userconf'; |
63 | 63 | $h++; |
64 | - */ |
|
64 | + */ |
|
65 | 65 | |
66 | 66 | //$object=new stdClass(); |
67 | 67 |
@@ -43,14 +43,14 @@ |
||
43 | 43 | $h++; |
44 | 44 | |
45 | 45 | if ($mode == 'setup') { |
46 | - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver','alpha'); |
|
46 | + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver', 'alpha'); |
|
47 | 47 | $head[$h][1] = $langs->trans("SetupDriver"); |
48 | 48 | $head[$h][2] = 'setup'; |
49 | 49 | $h++; |
50 | 50 | } |
51 | 51 | |
52 | 52 | if ($mode == 'test') { |
53 | - $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver','alpha'); |
|
53 | + $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver', 'alpha'); |
|
54 | 54 | $head[$h][1] = $langs->trans("TargetedPrinter"); |
55 | 55 | $head[$h][2] = 'test'; |
56 | 56 | $h++; |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | // Load translation files required by the page |
34 | 34 | $langs->loadLangs(array('admin', 'printing', 'oauth')); |
35 | 35 | |
36 | -if (! $user->admin) accessforbidden(); |
|
36 | +if (! $user->admin) { |
|
37 | + accessforbidden(); |
|
38 | +} |
|
37 | 39 | |
38 | 40 | $action = GETPOST('action','alpha'); |
39 | 41 | $mode = GETPOST('mode','alpha'); |
@@ -41,9 +43,13 @@ discard block |
||
41 | 43 | $varname = GETPOST('varname', 'alpha'); |
42 | 44 | $driver = GETPOST('driver', 'alpha'); |
43 | 45 | |
44 | -if (! empty($driver)) $langs->load($driver); |
|
46 | +if (! empty($driver)) { |
|
47 | + $langs->load($driver); |
|
48 | +} |
|
45 | 49 | |
46 | -if (!$mode) $mode='config'; |
|
50 | +if (!$mode) { |
|
51 | + $mode='config'; |
|
52 | +} |
|
47 | 53 | |
48 | 54 | $OAUTH_SERVICENAME_GOOGLE = 'Google'; |
49 | 55 | |
@@ -66,15 +72,16 @@ discard block |
||
66 | 72 | foreach ($_POST['setupdriver'] as $setupconst) { |
67 | 73 | //print '<pre>'.print_r($setupconst, true).'</pre>'; |
68 | 74 | $result=dolibarr_set_const($db, $setupconst['varname'],$setupconst['value'],'chaine',0,'',$conf->entity); |
69 | - if (! $result > 0) $error++; |
|
75 | + if (! $result > 0) { |
|
76 | + $error++; |
|
77 | + } |
|
70 | 78 | } |
71 | 79 | |
72 | 80 | if (! $error) |
73 | 81 | { |
74 | 82 | $db->commit(); |
75 | 83 | setEventMessages($langs->trans("SetupSaved"), null); |
76 | - } |
|
77 | - else |
|
84 | + } else |
|
78 | 85 | { |
79 | 86 | $db->rollback(); |
80 | 87 | dol_print_error($db); |
@@ -87,14 +94,15 @@ discard block |
||
87 | 94 | $db->begin(); |
88 | 95 | |
89 | 96 | $result=dolibarr_set_const($db, $varname, $value,'chaine',0,'',$conf->entity); |
90 | - if (! $result > 0) $error++; |
|
97 | + if (! $result > 0) { |
|
98 | + $error++; |
|
99 | + } |
|
91 | 100 | |
92 | 101 | if (! $error) |
93 | 102 | { |
94 | 103 | $db->commit(); |
95 | 104 | setEventMessages($langs->trans("SetupSaved"), null); |
96 | - } |
|
97 | - else |
|
105 | + } else |
|
98 | 106 | { |
99 | 107 | $db->rollback(); |
100 | 108 | dol_print_error($db); |
@@ -161,8 +169,7 @@ discard block |
||
161 | 169 | if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') |
162 | 170 | { |
163 | 171 | print $langs->trans("IsTokenGenerated"); |
164 | - } |
|
165 | - else |
|
172 | + } else |
|
166 | 173 | { |
167 | 174 | print $langs->trans($key['varname']); |
168 | 175 | } |
@@ -173,7 +180,9 @@ discard block |
||
173 | 180 | if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') |
174 | 181 | { |
175 | 182 | // Delete remote tokens |
176 | - if (! empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; |
|
183 | + if (! empty($key['delete'])) { |
|
184 | + print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; |
|
185 | + } |
|
177 | 186 | // Request remote token |
178 | 187 | print '<a class="button" href="'.$key['renew'].'">'.$langs->trans('RequestAccess').'</a><br><br>'; |
179 | 188 | // Check remote access |
@@ -183,7 +192,9 @@ discard block |
||
183 | 192 | print '</tr>'."\n"; |
184 | 193 | break; |
185 | 194 | case "submit": |
186 | - if ($key['enabled']) $submit_enabled=1; |
|
195 | + if ($key['enabled']) { |
|
196 | + $submit_enabled=1; |
|
197 | + } |
|
187 | 198 | break; |
188 | 199 | } |
189 | 200 | $i++; |
@@ -200,8 +211,7 @@ discard block |
||
200 | 211 | try |
201 | 212 | { |
202 | 213 | $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE); |
203 | - } |
|
204 | - catch(Exception $e) |
|
214 | + } catch(Exception $e) |
|
205 | 215 | { |
206 | 216 | // Return an error if token not found |
207 | 217 | } |
@@ -267,14 +277,12 @@ discard block |
||
267 | 277 | if (! empty($conf->use_javascript_ajax)) |
268 | 278 | { |
269 | 279 | print ajax_constantonoff($printer->active); |
270 | - } |
|
271 | - else |
|
280 | + } else |
|
272 | 281 | { |
273 | 282 | if (empty($conf->global->{$printer->conf})) |
274 | 283 | { |
275 | 284 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=1">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
276 | - } |
|
277 | - else |
|
285 | + } else |
|
278 | 286 | { |
279 | 287 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=0">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
280 | 288 | } |
@@ -309,8 +317,7 @@ discard block |
||
309 | 317 | } else { |
310 | 318 | setEventMessages($printer->error, $printer->errors, 'errors'); |
311 | 319 | } |
312 | - } |
|
313 | - else { |
|
320 | + } else { |
|
314 | 321 | print $langs->trans('PleaseConfigureDriverfromList'); |
315 | 322 | } |
316 | 323 | } else { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | // Load translation files required by the page |
36 | 36 | $langs->loadLangs(array('admin', 'printing', 'oauth')); |
37 | 37 | |
38 | -if (! $user->admin) accessforbidden(); |
|
38 | +if (!$user->admin) accessforbidden(); |
|
39 | 39 | |
40 | -$action = GETPOST('action','alpha'); |
|
41 | -$mode = GETPOST('mode','alpha'); |
|
42 | -$value = GETPOST('value','alpha',0,null,null,1); // The value may be __google__docs so we force disable of replace |
|
40 | +$action = GETPOST('action', 'alpha'); |
|
41 | +$mode = GETPOST('mode', 'alpha'); |
|
42 | +$value = GETPOST('value', 'alpha', 0, null, null, 1); // The value may be __google__docs so we force disable of replace |
|
43 | 43 | $varname = GETPOST('varname', 'alpha'); |
44 | 44 | $driver = GETPOST('driver', 'alpha'); |
45 | 45 | |
46 | -if (! empty($driver)) $langs->load($driver); |
|
46 | +if (!empty($driver)) $langs->load($driver); |
|
47 | 47 | |
48 | -if (!$mode) $mode='config'; |
|
48 | +if (!$mode) $mode = 'config'; |
|
49 | 49 | |
50 | 50 | $OAUTH_SERVICENAME_GOOGLE = 'Google'; |
51 | 51 | |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | |
64 | 64 | if ($action == 'setconst' && $user->admin) |
65 | 65 | { |
66 | - $error=0; |
|
66 | + $error = 0; |
|
67 | 67 | $db->begin(); |
68 | 68 | foreach ($_POST['setupdriver'] as $setupconst) { |
69 | 69 | //print '<pre>'.print_r($setupconst, true).'</pre>'; |
70 | - $result=dolibarr_set_const($db, $setupconst['varname'],$setupconst['value'],'chaine',0,'',$conf->entity); |
|
71 | - if (! $result > 0) $error++; |
|
70 | + $result = dolibarr_set_const($db, $setupconst['varname'], $setupconst['value'], 'chaine', 0, '', $conf->entity); |
|
71 | + if (!$result > 0) $error++; |
|
72 | 72 | } |
73 | 73 | |
74 | - if (! $error) |
|
74 | + if (!$error) |
|
75 | 75 | { |
76 | 76 | $db->commit(); |
77 | 77 | setEventMessages($langs->trans("SetupSaved"), null); |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | $db->rollback(); |
82 | 82 | dol_print_error($db); |
83 | 83 | } |
84 | - $action=''; |
|
84 | + $action = ''; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | if ($action == 'setvalue' && $user->admin) |
88 | 88 | { |
89 | 89 | $db->begin(); |
90 | 90 | |
91 | - $result=dolibarr_set_const($db, $varname, $value,'chaine',0,'',$conf->entity); |
|
92 | - if (! $result > 0) $error++; |
|
91 | + $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity); |
|
92 | + if (!$result > 0) $error++; |
|
93 | 93 | |
94 | - if (! $error) |
|
94 | + if (!$error) |
|
95 | 95 | { |
96 | 96 | $db->commit(); |
97 | 97 | setEventMessages($langs->trans("SetupSaved"), null); |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | |
114 | 114 | llxHeader('', $langs->trans("PrintingSetup")); |
115 | 115 | |
116 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
117 | -print load_fiche_titre($langs->trans("PrintingSetup"),$linkback,'title_setup'); |
|
116 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
117 | +print load_fiche_titre($langs->trans("PrintingSetup"), $linkback, 'title_setup'); |
|
118 | 118 | |
119 | 119 | $head = printingAdminPrepareHead($mode); |
120 | 120 | |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | print '<th>'.$langs->trans("Value").'</th>'; |
135 | 135 | print '<th> </th>'; |
136 | 136 | print "</tr>\n"; |
137 | - $submit_enabled=0; |
|
137 | + $submit_enabled = 0; |
|
138 | 138 | |
139 | - if (! empty($driver)) { |
|
139 | + if (!empty($driver)) { |
|
140 | 140 | require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; |
141 | 141 | $classname = 'printing_'.$driver; |
142 | 142 | $langs->load($driver); |
143 | 143 | $printer = new $classname($db); |
144 | 144 | |
145 | - $i=0; |
|
146 | - $submit_enabled=0; |
|
145 | + $i = 0; |
|
146 | + $submit_enabled = 0; |
|
147 | 147 | foreach ($printer->conf as $key) |
148 | 148 | { |
149 | 149 | switch ($key['type']) { |
150 | 150 | case "text": |
151 | 151 | case "password": |
152 | 152 | print '<tr class="oddeven">'; |
153 | - print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td>'; |
|
154 | - print '<td><input size="32" type="'.(empty($key['type'])?'text':$key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'"'; |
|
155 | - print isset($key['moreattributes'])?' '.$key['moreattributes']:''; |
|
153 | + print '<td'.($key['required'] ? ' class=required' : '').'>'.$langs->trans($key['varname']).'</td>'; |
|
154 | + print '<td><input size="32" type="'.(empty($key['type']) ? 'text' : $key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'"'; |
|
155 | + print isset($key['moreattributes']) ? ' '.$key['moreattributes'] : ''; |
|
156 | 156 | print '><input type="hidden" name="setupdriver['.$i.'][varname]" value="'.$key['varname'].'"></td>'; |
157 | - print '<td> '.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:'').'</td>'; |
|
157 | + print '<td> '.($key['example'] != '' ? $langs->trans("Example").' : '.$key['example'] : '').'</td>'; |
|
158 | 158 | print '</tr>'."\n"; |
159 | 159 | break; |
160 | 160 | case "info": // Google Api setup or Google OAuth Token |
161 | 161 | print '<tr class="oddeven">'; |
162 | - print '<td'.($key['required']?' class=required':'').'>'; |
|
162 | + print '<td'.($key['required'] ? ' class=required' : '').'>'; |
|
163 | 163 | if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') |
164 | 164 | { |
165 | 165 | print $langs->trans("IsTokenGenerated"); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if ($key['varname'] == 'PRINTGCP_TOKEN_ACCESS') |
176 | 176 | { |
177 | 177 | // Delete remote tokens |
178 | - if (! empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; |
|
178 | + if (!empty($key['delete'])) print '<a class="button" href="'.$key['delete'].'">'.$langs->trans('DeleteAccess').'</a><br><br>'; |
|
179 | 179 | // Request remote token |
180 | 180 | print '<a class="button" href="'.$key['renew'].'">'.$langs->trans('RequestAccess').'</a><br><br>'; |
181 | 181 | // Check remote access |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | print '</tr>'."\n"; |
186 | 186 | break; |
187 | 187 | case "submit": |
188 | - if ($key['enabled']) $submit_enabled=1; |
|
188 | + if ($key['enabled']) $submit_enabled = 1; |
|
189 | 189 | break; |
190 | 190 | } |
191 | 191 | $i++; |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | print '<tr class="oddeven">'; |
197 | 197 | print '<td>'.$langs->trans("Token").'</td>'; |
198 | 198 | print '<td colspan="2">'; |
199 | - $tokenobj=null; |
|
199 | + $tokenobj = null; |
|
200 | 200 | // Dolibarr storage |
201 | 201 | $storage = new DoliStorage($db, $conf); |
202 | 202 | try |
203 | 203 | { |
204 | 204 | $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE); |
205 | 205 | } |
206 | - catch(Exception $e) |
|
206 | + catch (Exception $e) |
|
207 | 207 | { |
208 | 208 | // Return an error if token not found |
209 | 209 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | dol_fiche_end(); |
232 | 232 | |
233 | - if (! empty($driver)) |
|
233 | + if (!empty($driver)) |
|
234 | 234 | { |
235 | 235 | if ($submit_enabled) { |
236 | 236 | print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>'; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | print '<tr class="oddeven">'; |
267 | 267 | print '<td>'.img_picto('', $printer->picto).' '.$langs->trans($printer->desc).'</td>'; |
268 | 268 | print '<td class="center">'; |
269 | - if (! empty($conf->use_javascript_ajax)) |
|
269 | + if (!empty($conf->use_javascript_ajax)) |
|
270 | 270 | { |
271 | 271 | print ajax_constantonoff($printer->active); |
272 | 272 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | { |
275 | 275 | if (empty($conf->global->{$printer->conf})) |
276 | 276 | { |
277 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=1">'.img_picto($langs->trans("Disabled"),'off').'</a>'; |
|
277 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=1">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
278 | 278 | } |
279 | 279 | else |
280 | 280 | { |
281 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=0">'.img_picto($langs->trans("Enabled"),'on').'</a>'; |
|
281 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&varname='.$printer->active.'&value=0">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?mode=setup&driver='.$printer->name.'">'.img_picto('', 'setup').'</a></td>'; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n"; |
299 | 299 | |
300 | 300 | print '<table class="noborder" width="100%">'; |
301 | - if (! empty($driver)) |
|
301 | + if (!empty($driver)) |
|
302 | 302 | { |
303 | 303 | require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; |
304 | 304 | $classname = 'printing_'.$driver; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $printer = new $classname($db); |
307 | 307 | //print '<pre>'.print_r($printer, true).'</pre>'; |
308 | 308 | if (count($printer->getlistAvailablePrinters())) { |
309 | - if ($printer->listAvailablePrinters()==0) { |
|
309 | + if ($printer->listAvailablePrinters() == 0) { |
|
310 | 310 | print $printer->resprint; |
311 | 311 | } else { |
312 | 312 | setEventMessages($printer->error, $printer->errors, 'errors'); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | print "</tr>\n"; |
343 | 343 | $sql = 'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.'printing as p, '.MAIN_DB_PREFIX.'user as u WHERE p.userid=u.rowid'; |
344 | 344 | $resql = $db->query($sql); |
345 | - while ($row=$db->fetch_array($resql)) { |
|
345 | + while ($row = $db->fetch_array($resql)) { |
|
346 | 346 | |
347 | 347 | print '<tr class="oddeven">'; |
348 | 348 | print '<td>'.$row['login'].'</td>'; |
@@ -31,243 +31,243 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class Asset extends CommonObject |
33 | 33 | { |
34 | - /** |
|
35 | - * @var string ID to identify managed object |
|
36 | - */ |
|
37 | - public $element = 'asset'; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string Name of table without prefix where object is stored |
|
41 | - */ |
|
42 | - public $table_element = 'asset'; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
46 | - */ |
|
47 | - public $ismultientitymanaged = 0; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var int Does asset support extrafields ? 0=No, 1=Yes |
|
51 | - */ |
|
52 | - public $isextrafieldmanaged = 1; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png |
|
56 | - */ |
|
57 | - public $picto = 'asset'; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * 'type' if the field format. |
|
62 | - * 'label' the translation key. |
|
63 | - * 'enabled' is a condition when the field must be managed. |
|
64 | - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) |
|
65 | - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). |
|
66 | - * 'index' if we want an index in database. |
|
67 | - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). |
|
68 | - * 'position' is the sort order of field. |
|
69 | - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. |
|
70 | - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). |
|
71 | - * 'help' is a string visible as a tooltip on field |
|
72 | - * 'comment' is not used. You can store here any text of your choice. It is not used by application. |
|
73 | - * 'default' is a default value for creation (can still be replaced by the global setup of default values) |
|
74 | - * 'showoncombobox' if field must be shown into the label of combobox |
|
75 | - */ |
|
76 | - |
|
77 | - /** |
|
78 | - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
|
79 | - */ |
|
80 | - public $fields=array( |
|
81 | - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
|
82 | - 'ref' => array('type'=>'varchar(10)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), |
|
83 | - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), |
|
84 | - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",), |
|
85 | - 'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), |
|
86 | - 'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), |
|
87 | - 'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), |
|
88 | - 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,), |
|
89 | - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,), |
|
90 | - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,), |
|
91 | - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), |
|
92 | - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), |
|
93 | - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), |
|
94 | - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), |
|
95 | - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), |
|
96 | - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Active', '-1'=>'Cancel')), |
|
97 | - ); |
|
98 | - |
|
99 | - /** |
|
100 | - * @var int ID |
|
101 | - */ |
|
102 | - public $rowid; |
|
103 | - |
|
104 | - /** |
|
105 | - * @var string Ref |
|
106 | - */ |
|
107 | - public $ref; |
|
108 | - |
|
109 | - /** |
|
110 | - * @var int Entity |
|
111 | - */ |
|
112 | - public $entity; |
|
34 | + /** |
|
35 | + * @var string ID to identify managed object |
|
36 | + */ |
|
37 | + public $element = 'asset'; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string Name of table without prefix where object is stored |
|
41 | + */ |
|
42 | + public $table_element = 'asset'; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
46 | + */ |
|
47 | + public $ismultientitymanaged = 0; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var int Does asset support extrafields ? 0=No, 1=Yes |
|
51 | + */ |
|
52 | + public $isextrafieldmanaged = 1; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png |
|
56 | + */ |
|
57 | + public $picto = 'asset'; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * 'type' if the field format. |
|
62 | + * 'label' the translation key. |
|
63 | + * 'enabled' is a condition when the field must be managed. |
|
64 | + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) |
|
65 | + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). |
|
66 | + * 'index' if we want an index in database. |
|
67 | + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). |
|
68 | + * 'position' is the sort order of field. |
|
69 | + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. |
|
70 | + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). |
|
71 | + * 'help' is a string visible as a tooltip on field |
|
72 | + * 'comment' is not used. You can store here any text of your choice. It is not used by application. |
|
73 | + * 'default' is a default value for creation (can still be replaced by the global setup of default values) |
|
74 | + * 'showoncombobox' if field must be shown into the label of combobox |
|
75 | + */ |
|
76 | + |
|
77 | + /** |
|
78 | + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
|
79 | + */ |
|
80 | + public $fields=array( |
|
81 | + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
|
82 | + 'ref' => array('type'=>'varchar(10)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), |
|
83 | + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), |
|
84 | + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text",), |
|
85 | + 'amount_ht' => array('type'=>'double(24,8)', 'label'=>'AmountHTShort', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), |
|
86 | + 'amount_vat' => array('type'=>'double(24,8)', 'label'=>'AmountVAT', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'isameasure'=>'1', 'help'=>"Help text",), |
|
87 | + 'fk_asset_type' => array('type'=>'integer:AssetType:asset/class/asset.class.php', 'label'=>'AssetsType', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty",), |
|
88 | + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>90, 'notnull'=>-1,), |
|
89 | + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>-1,), |
|
90 | + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>-1,), |
|
91 | + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), |
|
92 | + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), |
|
93 | + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), |
|
94 | + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), |
|
95 | + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), |
|
96 | + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Active', '-1'=>'Cancel')), |
|
97 | + ); |
|
98 | + |
|
99 | + /** |
|
100 | + * @var int ID |
|
101 | + */ |
|
102 | + public $rowid; |
|
103 | + |
|
104 | + /** |
|
105 | + * @var string Ref |
|
106 | + */ |
|
107 | + public $ref; |
|
108 | + |
|
109 | + /** |
|
110 | + * @var int Entity |
|
111 | + */ |
|
112 | + public $entity; |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @var string Asset label |
116 | 116 | */ |
117 | 117 | public $label; |
118 | 118 | |
119 | - public $amount; |
|
119 | + public $amount; |
|
120 | 120 | |
121 | - /** |
|
122 | - * @var int Thirdparty ID |
|
123 | - */ |
|
121 | + /** |
|
122 | + * @var int Thirdparty ID |
|
123 | + */ |
|
124 | 124 | public $fk_soc; |
125 | 125 | |
126 | - /** |
|
127 | - * @var string description |
|
128 | - */ |
|
129 | - public $description; |
|
126 | + /** |
|
127 | + * @var string description |
|
128 | + */ |
|
129 | + public $description; |
|
130 | 130 | |
131 | - public $note_public; |
|
132 | - public $note_private; |
|
133 | - public $date_creation; |
|
134 | - public $tms; |
|
131 | + public $note_public; |
|
132 | + public $note_private; |
|
133 | + public $date_creation; |
|
134 | + public $tms; |
|
135 | 135 | |
136 | - /** |
|
136 | + /** |
|
137 | 137 | * @var int ID |
138 | 138 | */ |
139 | - public $fk_user_creat; |
|
139 | + public $fk_user_creat; |
|
140 | 140 | |
141 | - /** |
|
141 | + /** |
|
142 | 142 | * @var int ID |
143 | 143 | */ |
144 | - public $fk_user_modif; |
|
145 | - |
|
146 | - public $import_key; |
|
147 | - |
|
148 | - /** |
|
149 | - * @var int Status |
|
150 | - */ |
|
151 | - public $status; |
|
152 | - |
|
153 | - // If this object has a subtable with lines |
|
154 | - |
|
155 | - /** |
|
156 | - * @var int Name of subtable line |
|
157 | - */ |
|
158 | - //public $table_element_line = 'assetdet'; |
|
159 | - /** |
|
160 | - * @var int Field with ID of parent key if this field has a parent |
|
161 | - */ |
|
162 | - //public $fk_element = 'fk_asset'; |
|
163 | - /** |
|
164 | - * @var int Name of subtable class that manage subtable lines |
|
165 | - */ |
|
166 | - //public $class_element_line = 'Assetline'; |
|
167 | - /** |
|
168 | - * @var array Array of child tables (child tables to delete before deleting a record) |
|
169 | - */ |
|
170 | - //protected $childtables=array('assetdet'); |
|
171 | - /** |
|
172 | - * @var AssetLine[] Array of subtable lines |
|
173 | - */ |
|
174 | - //public $lines = array(); |
|
175 | - |
|
176 | - /** |
|
177 | - * Constructor |
|
178 | - * |
|
179 | - * @param DoliDb $db Database handler |
|
180 | - */ |
|
181 | - public function __construct(DoliDB $db) |
|
182 | - { |
|
183 | - global $conf; |
|
184 | - |
|
185 | - $this->db = $db; |
|
186 | - |
|
187 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
188 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Create object into database |
|
193 | - * |
|
194 | - * @param User $user User that creates |
|
195 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
196 | - * @return int <0 if KO, Id of created object if OK |
|
197 | - */ |
|
198 | - public function create(User $user, $notrigger = false) |
|
199 | - { |
|
200 | - return $this->createCommon($user, $notrigger); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Clone and object into another one |
|
205 | - * |
|
206 | - * @param User $user User that creates |
|
207 | - * @param int $fromid Id of object to clone |
|
208 | - * @return mixed New object created, <0 if KO |
|
209 | - */ |
|
210 | - public function createFromClone(User $user, $fromid) |
|
211 | - { |
|
212 | - global $hookmanager, $langs; |
|
213 | - $error = 0; |
|
214 | - |
|
215 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
216 | - |
|
217 | - $object = new self($this->db); |
|
218 | - |
|
219 | - $this->db->begin(); |
|
220 | - |
|
221 | - // Load source object |
|
222 | - $object->fetchCommon($fromid); |
|
223 | - // Reset some properties |
|
224 | - unset($object->id); |
|
225 | - unset($object->fk_user_creat); |
|
226 | - unset($object->import_key); |
|
227 | - |
|
228 | - // Clear fields |
|
229 | - $object->ref = "copy_of_".$object->ref; |
|
230 | - $object->title = $langs->trans("CopyOf")." ".$object->title; |
|
231 | - |
|
232 | - // Create clone |
|
233 | - $object->context['createfromclone'] = 'createfromclone'; |
|
234 | - $result = $object->createCommon($user); |
|
235 | - if ($result < 0) { |
|
236 | - $error++; |
|
237 | - $this->error = $object->error; |
|
238 | - $this->errors = $object->errors; |
|
239 | - } |
|
240 | - |
|
241 | - // End |
|
242 | - if (!$error) { |
|
243 | - $this->db->commit(); |
|
244 | - return $object; |
|
245 | - } else { |
|
246 | - $this->db->rollback(); |
|
247 | - return -1; |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Load object in memory from the database |
|
253 | - * |
|
254 | - * @param int $id Id object |
|
255 | - * @param string $ref Ref |
|
256 | - * @return int <0 if KO, 0 if not found, >0 if OK |
|
257 | - */ |
|
258 | - public function fetch($id, $ref = null) |
|
259 | - { |
|
260 | - $result = $this->fetchCommon($id, $ref); |
|
261 | - //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); |
|
262 | - return $result; |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * Load object lines in memory from the database |
|
267 | - * |
|
268 | - * @return int <0 if KO, 0 if not found, >0 if OK |
|
269 | - */ |
|
270 | - /*public function fetchLines() |
|
144 | + public $fk_user_modif; |
|
145 | + |
|
146 | + public $import_key; |
|
147 | + |
|
148 | + /** |
|
149 | + * @var int Status |
|
150 | + */ |
|
151 | + public $status; |
|
152 | + |
|
153 | + // If this object has a subtable with lines |
|
154 | + |
|
155 | + /** |
|
156 | + * @var int Name of subtable line |
|
157 | + */ |
|
158 | + //public $table_element_line = 'assetdet'; |
|
159 | + /** |
|
160 | + * @var int Field with ID of parent key if this field has a parent |
|
161 | + */ |
|
162 | + //public $fk_element = 'fk_asset'; |
|
163 | + /** |
|
164 | + * @var int Name of subtable class that manage subtable lines |
|
165 | + */ |
|
166 | + //public $class_element_line = 'Assetline'; |
|
167 | + /** |
|
168 | + * @var array Array of child tables (child tables to delete before deleting a record) |
|
169 | + */ |
|
170 | + //protected $childtables=array('assetdet'); |
|
171 | + /** |
|
172 | + * @var AssetLine[] Array of subtable lines |
|
173 | + */ |
|
174 | + //public $lines = array(); |
|
175 | + |
|
176 | + /** |
|
177 | + * Constructor |
|
178 | + * |
|
179 | + * @param DoliDb $db Database handler |
|
180 | + */ |
|
181 | + public function __construct(DoliDB $db) |
|
182 | + { |
|
183 | + global $conf; |
|
184 | + |
|
185 | + $this->db = $db; |
|
186 | + |
|
187 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
188 | + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Create object into database |
|
193 | + * |
|
194 | + * @param User $user User that creates |
|
195 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
196 | + * @return int <0 if KO, Id of created object if OK |
|
197 | + */ |
|
198 | + public function create(User $user, $notrigger = false) |
|
199 | + { |
|
200 | + return $this->createCommon($user, $notrigger); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Clone and object into another one |
|
205 | + * |
|
206 | + * @param User $user User that creates |
|
207 | + * @param int $fromid Id of object to clone |
|
208 | + * @return mixed New object created, <0 if KO |
|
209 | + */ |
|
210 | + public function createFromClone(User $user, $fromid) |
|
211 | + { |
|
212 | + global $hookmanager, $langs; |
|
213 | + $error = 0; |
|
214 | + |
|
215 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
216 | + |
|
217 | + $object = new self($this->db); |
|
218 | + |
|
219 | + $this->db->begin(); |
|
220 | + |
|
221 | + // Load source object |
|
222 | + $object->fetchCommon($fromid); |
|
223 | + // Reset some properties |
|
224 | + unset($object->id); |
|
225 | + unset($object->fk_user_creat); |
|
226 | + unset($object->import_key); |
|
227 | + |
|
228 | + // Clear fields |
|
229 | + $object->ref = "copy_of_".$object->ref; |
|
230 | + $object->title = $langs->trans("CopyOf")." ".$object->title; |
|
231 | + |
|
232 | + // Create clone |
|
233 | + $object->context['createfromclone'] = 'createfromclone'; |
|
234 | + $result = $object->createCommon($user); |
|
235 | + if ($result < 0) { |
|
236 | + $error++; |
|
237 | + $this->error = $object->error; |
|
238 | + $this->errors = $object->errors; |
|
239 | + } |
|
240 | + |
|
241 | + // End |
|
242 | + if (!$error) { |
|
243 | + $this->db->commit(); |
|
244 | + return $object; |
|
245 | + } else { |
|
246 | + $this->db->rollback(); |
|
247 | + return -1; |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Load object in memory from the database |
|
253 | + * |
|
254 | + * @param int $id Id object |
|
255 | + * @param string $ref Ref |
|
256 | + * @return int <0 if KO, 0 if not found, >0 if OK |
|
257 | + */ |
|
258 | + public function fetch($id, $ref = null) |
|
259 | + { |
|
260 | + $result = $this->fetchCommon($id, $ref); |
|
261 | + //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); |
|
262 | + return $result; |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * Load object lines in memory from the database |
|
267 | + * |
|
268 | + * @return int <0 if KO, 0 if not found, >0 if OK |
|
269 | + */ |
|
270 | + /*public function fetchLines() |
|
271 | 271 | { |
272 | 272 | $this->lines=array(); |
273 | 273 | |
@@ -276,227 +276,227 @@ discard block |
||
276 | 276 | return count($this->lines)?1:0; |
277 | 277 | }*/ |
278 | 278 | |
279 | - /** |
|
280 | - * Update object into database |
|
281 | - * |
|
282 | - * @param User $user User that modifies |
|
283 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
284 | - * @return int <0 if KO, >0 if OK |
|
285 | - */ |
|
286 | - public function update(User $user, $notrigger = false) |
|
287 | - { |
|
288 | - return $this->updateCommon($user, $notrigger); |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Delete object in database |
|
293 | - * |
|
294 | - * @param User $user User that deletes |
|
295 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
296 | - * @return int <0 if KO, >0 if OK |
|
297 | - */ |
|
298 | - public function delete(User $user, $notrigger = false) |
|
299 | - { |
|
300 | - return $this->deleteCommon($user, $notrigger); |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Return a link to the object card (with optionaly the picto) |
|
305 | - * |
|
306 | - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
|
307 | - * @param string $option On what the link point to ('nolink', ...) |
|
308 | - * @param int $notooltip 1=Disable tooltip |
|
309 | - * @param string $morecss Add more css on link |
|
310 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
311 | - * @return string String with URL |
|
312 | - */ |
|
313 | - function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) |
|
314 | - { |
|
315 | - global $db, $conf, $langs; |
|
316 | - global $dolibarr_main_authentication, $dolibarr_main_demo; |
|
317 | - global $menumanager; |
|
318 | - |
|
319 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
320 | - |
|
321 | - $result = ''; |
|
322 | - $companylink = ''; |
|
323 | - |
|
324 | - $label = '<u>' . $langs->trans("Asset") . '</u>'; |
|
325 | - $label.= '<br>'; |
|
326 | - $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
327 | - |
|
328 | - $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; |
|
329 | - |
|
330 | - if ($option != 'nolink') |
|
331 | - { |
|
332 | - // Add param to save lastsearch_values or not |
|
333 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
334 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
335 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
336 | - } |
|
337 | - |
|
338 | - $linkclose=''; |
|
339 | - if (empty($notooltip)) |
|
340 | - { |
|
341 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
342 | - { |
|
343 | - $label=$langs->trans("ShowAssets"); |
|
344 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
345 | - } |
|
346 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
347 | - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
348 | - } |
|
349 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
350 | - |
|
351 | - $linkstart = '<a href="'.$url.'"'; |
|
352 | - $linkstart.=$linkclose.'>'; |
|
353 | - $linkend='</a>'; |
|
354 | - |
|
355 | - $result .= $linkstart; |
|
356 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
357 | - if ($withpicto != 2) $result.= $this->ref; |
|
358 | - $result .= $linkend; |
|
359 | - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
360 | - |
|
361 | - return $result; |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * Retourne le libelle du status d'un user (actif, inactif) |
|
366 | - * |
|
367 | - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
368 | - * @return string Label of status |
|
369 | - */ |
|
370 | - function getLibStatut($mode=0) |
|
371 | - { |
|
372 | - return $this->LibStatut($this->status,$mode); |
|
373 | - } |
|
279 | + /** |
|
280 | + * Update object into database |
|
281 | + * |
|
282 | + * @param User $user User that modifies |
|
283 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
284 | + * @return int <0 if KO, >0 if OK |
|
285 | + */ |
|
286 | + public function update(User $user, $notrigger = false) |
|
287 | + { |
|
288 | + return $this->updateCommon($user, $notrigger); |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Delete object in database |
|
293 | + * |
|
294 | + * @param User $user User that deletes |
|
295 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
296 | + * @return int <0 if KO, >0 if OK |
|
297 | + */ |
|
298 | + public function delete(User $user, $notrigger = false) |
|
299 | + { |
|
300 | + return $this->deleteCommon($user, $notrigger); |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Return a link to the object card (with optionaly the picto) |
|
305 | + * |
|
306 | + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
|
307 | + * @param string $option On what the link point to ('nolink', ...) |
|
308 | + * @param int $notooltip 1=Disable tooltip |
|
309 | + * @param string $morecss Add more css on link |
|
310 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
311 | + * @return string String with URL |
|
312 | + */ |
|
313 | + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) |
|
314 | + { |
|
315 | + global $db, $conf, $langs; |
|
316 | + global $dolibarr_main_authentication, $dolibarr_main_demo; |
|
317 | + global $menumanager; |
|
318 | + |
|
319 | + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
320 | + |
|
321 | + $result = ''; |
|
322 | + $companylink = ''; |
|
323 | + |
|
324 | + $label = '<u>' . $langs->trans("Asset") . '</u>'; |
|
325 | + $label.= '<br>'; |
|
326 | + $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
327 | + |
|
328 | + $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; |
|
329 | + |
|
330 | + if ($option != 'nolink') |
|
331 | + { |
|
332 | + // Add param to save lastsearch_values or not |
|
333 | + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
334 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
335 | + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
336 | + } |
|
337 | + |
|
338 | + $linkclose=''; |
|
339 | + if (empty($notooltip)) |
|
340 | + { |
|
341 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
342 | + { |
|
343 | + $label=$langs->trans("ShowAssets"); |
|
344 | + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
345 | + } |
|
346 | + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
347 | + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
348 | + } |
|
349 | + else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
350 | + |
|
351 | + $linkstart = '<a href="'.$url.'"'; |
|
352 | + $linkstart.=$linkclose.'>'; |
|
353 | + $linkend='</a>'; |
|
354 | + |
|
355 | + $result .= $linkstart; |
|
356 | + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
357 | + if ($withpicto != 2) $result.= $this->ref; |
|
358 | + $result .= $linkend; |
|
359 | + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
|
360 | + |
|
361 | + return $result; |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * Retourne le libelle du status d'un user (actif, inactif) |
|
366 | + * |
|
367 | + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
368 | + * @return string Label of status |
|
369 | + */ |
|
370 | + function getLibStatut($mode=0) |
|
371 | + { |
|
372 | + return $this->LibStatut($this->status,$mode); |
|
373 | + } |
|
374 | 374 | |
375 | 375 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
376 | - /** |
|
377 | - * Return the status |
|
378 | - * |
|
379 | - * @param int $status Id status |
|
380 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
|
381 | - * @return string Label of status |
|
382 | - */ |
|
383 | - static function LibStatut($status,$mode=0) |
|
384 | - { |
|
376 | + /** |
|
377 | + * Return the status |
|
378 | + * |
|
379 | + * @param int $status Id status |
|
380 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
|
381 | + * @return string Label of status |
|
382 | + */ |
|
383 | + static function LibStatut($status,$mode=0) |
|
384 | + { |
|
385 | 385 | // phpcs:enable |
386 | - global $langs; |
|
387 | - |
|
388 | - if ($mode == 0 || $mode == 1) |
|
389 | - { |
|
390 | - if ($status == 1) return $langs->trans('Enabled'); |
|
391 | - elseif ($status == 0) return $langs->trans('Disabled'); |
|
392 | - } |
|
393 | - elseif ($mode == 2) |
|
394 | - { |
|
395 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
396 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
397 | - } |
|
398 | - elseif ($mode == 3) |
|
399 | - { |
|
400 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
401 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
402 | - } |
|
403 | - elseif ($mode == 4) |
|
404 | - { |
|
405 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
406 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
407 | - } |
|
408 | - elseif ($mode == 5) |
|
409 | - { |
|
410 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
411 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
412 | - } |
|
413 | - elseif ($mode == 6) |
|
414 | - { |
|
415 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
416 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * Charge les informations d'ordre info dans l'objet commande |
|
422 | - * |
|
423 | - * @param int $id Id of order |
|
424 | - * @return void |
|
425 | - */ |
|
426 | - function info($id) |
|
427 | - { |
|
428 | - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; |
|
429 | - $sql.= ' fk_user_creat, fk_user_modif'; |
|
430 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
431 | - $sql.= ' WHERE t.rowid = '.$id; |
|
432 | - $result=$this->db->query($sql); |
|
433 | - if ($result) |
|
434 | - { |
|
435 | - if ($this->db->num_rows($result)) |
|
436 | - { |
|
437 | - $obj = $this->db->fetch_object($result); |
|
438 | - $this->id = $obj->rowid; |
|
439 | - if ($obj->fk_user_author) |
|
440 | - { |
|
441 | - $cuser = new User($this->db); |
|
442 | - $cuser->fetch($obj->fk_user_author); |
|
443 | - $this->user_creation = $cuser; |
|
444 | - } |
|
445 | - |
|
446 | - if ($obj->fk_user_valid) |
|
447 | - { |
|
448 | - $vuser = new User($this->db); |
|
449 | - $vuser->fetch($obj->fk_user_valid); |
|
450 | - $this->user_validation = $vuser; |
|
451 | - } |
|
452 | - |
|
453 | - if ($obj->fk_user_cloture) |
|
454 | - { |
|
455 | - $cluser = new User($this->db); |
|
456 | - $cluser->fetch($obj->fk_user_cloture); |
|
457 | - $this->user_cloture = $cluser; |
|
458 | - } |
|
459 | - |
|
460 | - $this->date_creation = $this->db->jdate($obj->datec); |
|
461 | - $this->date_modification = $this->db->jdate($obj->datem); |
|
462 | - $this->date_validation = $this->db->jdate($obj->datev); |
|
463 | - } |
|
464 | - |
|
465 | - $this->db->free($result); |
|
466 | - } |
|
467 | - else |
|
468 | - { |
|
469 | - dol_print_error($this->db); |
|
470 | - } |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Initialise object with example values |
|
475 | - * Id must be 0 if object instance is a specimen |
|
476 | - * |
|
477 | - * @return void |
|
478 | - */ |
|
479 | - public function initAsSpecimen() |
|
480 | - { |
|
481 | - $this->initAsSpecimenCommon(); |
|
482 | - } |
|
386 | + global $langs; |
|
387 | + |
|
388 | + if ($mode == 0 || $mode == 1) |
|
389 | + { |
|
390 | + if ($status == 1) return $langs->trans('Enabled'); |
|
391 | + elseif ($status == 0) return $langs->trans('Disabled'); |
|
392 | + } |
|
393 | + elseif ($mode == 2) |
|
394 | + { |
|
395 | + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
396 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
397 | + } |
|
398 | + elseif ($mode == 3) |
|
399 | + { |
|
400 | + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
401 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
402 | + } |
|
403 | + elseif ($mode == 4) |
|
404 | + { |
|
405 | + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
406 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
407 | + } |
|
408 | + elseif ($mode == 5) |
|
409 | + { |
|
410 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
411 | + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
412 | + } |
|
413 | + elseif ($mode == 6) |
|
414 | + { |
|
415 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
416 | + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
417 | + } |
|
418 | + } |
|
483 | 419 | |
420 | + /** |
|
421 | + * Charge les informations d'ordre info dans l'objet commande |
|
422 | + * |
|
423 | + * @param int $id Id of order |
|
424 | + * @return void |
|
425 | + */ |
|
426 | + function info($id) |
|
427 | + { |
|
428 | + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; |
|
429 | + $sql.= ' fk_user_creat, fk_user_modif'; |
|
430 | + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
431 | + $sql.= ' WHERE t.rowid = '.$id; |
|
432 | + $result=$this->db->query($sql); |
|
433 | + if ($result) |
|
434 | + { |
|
435 | + if ($this->db->num_rows($result)) |
|
436 | + { |
|
437 | + $obj = $this->db->fetch_object($result); |
|
438 | + $this->id = $obj->rowid; |
|
439 | + if ($obj->fk_user_author) |
|
440 | + { |
|
441 | + $cuser = new User($this->db); |
|
442 | + $cuser->fetch($obj->fk_user_author); |
|
443 | + $this->user_creation = $cuser; |
|
444 | + } |
|
445 | + |
|
446 | + if ($obj->fk_user_valid) |
|
447 | + { |
|
448 | + $vuser = new User($this->db); |
|
449 | + $vuser->fetch($obj->fk_user_valid); |
|
450 | + $this->user_validation = $vuser; |
|
451 | + } |
|
452 | + |
|
453 | + if ($obj->fk_user_cloture) |
|
454 | + { |
|
455 | + $cluser = new User($this->db); |
|
456 | + $cluser->fetch($obj->fk_user_cloture); |
|
457 | + $this->user_cloture = $cluser; |
|
458 | + } |
|
459 | + |
|
460 | + $this->date_creation = $this->db->jdate($obj->datec); |
|
461 | + $this->date_modification = $this->db->jdate($obj->datem); |
|
462 | + $this->date_validation = $this->db->jdate($obj->datev); |
|
463 | + } |
|
464 | + |
|
465 | + $this->db->free($result); |
|
466 | + } |
|
467 | + else |
|
468 | + { |
|
469 | + dol_print_error($this->db); |
|
470 | + } |
|
471 | + } |
|
484 | 472 | |
485 | - /** |
|
486 | - * Action executed by scheduler |
|
487 | - * CAN BE A CRON TASK |
|
488 | - * |
|
489 | - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) |
|
490 | - */ |
|
491 | - public function doScheduledJob() |
|
492 | - { |
|
493 | - global $conf, $langs; |
|
473 | + /** |
|
474 | + * Initialise object with example values |
|
475 | + * Id must be 0 if object instance is a specimen |
|
476 | + * |
|
477 | + * @return void |
|
478 | + */ |
|
479 | + public function initAsSpecimen() |
|
480 | + { |
|
481 | + $this->initAsSpecimenCommon(); |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * Action executed by scheduler |
|
487 | + * CAN BE A CRON TASK |
|
488 | + * |
|
489 | + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) |
|
490 | + */ |
|
491 | + public function doScheduledJob() |
|
492 | + { |
|
493 | + global $conf, $langs; |
|
494 | 494 | |
495 | - $this->output = ''; |
|
496 | - $this->error=''; |
|
495 | + $this->output = ''; |
|
496 | + $this->error=''; |
|
497 | 497 | |
498 | - dol_syslog(__METHOD__, LOG_DEBUG); |
|
498 | + dol_syslog(__METHOD__, LOG_DEBUG); |
|
499 | 499 | |
500 | - return 0; |
|
501 | - } |
|
500 | + return 0; |
|
501 | + } |
|
502 | 502 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief This file is a CRUD class file for asset (Create/Read/Update/Delete) |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
26 | 26 | //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
27 | 27 | //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
28 | 28 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
79 | 79 | */ |
80 | - public $fields=array( |
|
80 | + public $fields = array( |
|
81 | 81 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
82 | 82 | 'ref' => array('type'=>'varchar(10)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object",), |
83 | 83 | 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | |
185 | 185 | $this->db = $db; |
186 | 186 | |
187 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
188 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
187 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; |
|
188 | + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -310,51 +310,51 @@ discard block |
||
310 | 310 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
311 | 311 | * @return string String with URL |
312 | 312 | */ |
313 | - function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) |
|
313 | + function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) |
|
314 | 314 | { |
315 | 315 | global $db, $conf, $langs; |
316 | 316 | global $dolibarr_main_authentication, $dolibarr_main_demo; |
317 | 317 | global $menumanager; |
318 | 318 | |
319 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
319 | + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
320 | 320 | |
321 | 321 | $result = ''; |
322 | 322 | $companylink = ''; |
323 | 323 | |
324 | - $label = '<u>' . $langs->trans("Asset") . '</u>'; |
|
325 | - $label.= '<br>'; |
|
326 | - $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
|
324 | + $label = '<u>'.$langs->trans("Asset").'</u>'; |
|
325 | + $label .= '<br>'; |
|
326 | + $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
327 | 327 | |
328 | - $url = dol_buildpath('/assets/card.php',1).'?id='.$this->id; |
|
328 | + $url = dol_buildpath('/assets/card.php', 1).'?id='.$this->id; |
|
329 | 329 | |
330 | 330 | if ($option != 'nolink') |
331 | 331 | { |
332 | 332 | // Add param to save lastsearch_values or not |
333 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
334 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
335 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
333 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
334 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
335 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
336 | 336 | } |
337 | 337 | |
338 | - $linkclose=''; |
|
338 | + $linkclose = ''; |
|
339 | 339 | if (empty($notooltip)) |
340 | 340 | { |
341 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
341 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
342 | 342 | { |
343 | - $label=$langs->trans("ShowAssets"); |
|
344 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
343 | + $label = $langs->trans("ShowAssets"); |
|
344 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
345 | 345 | } |
346 | - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
|
347 | - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
|
346 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
|
347 | + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
|
348 | 348 | } |
349 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
349 | + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
350 | 350 | |
351 | 351 | $linkstart = '<a href="'.$url.'"'; |
352 | - $linkstart.=$linkclose.'>'; |
|
353 | - $linkend='</a>'; |
|
352 | + $linkstart .= $linkclose.'>'; |
|
353 | + $linkend = '</a>'; |
|
354 | 354 | |
355 | 355 | $result .= $linkstart; |
356 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
357 | - if ($withpicto != 2) $result.= $this->ref; |
|
356 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
357 | + if ($withpicto != 2) $result .= $this->ref; |
|
358 | 358 | $result .= $linkend; |
359 | 359 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
360 | 360 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
368 | 368 | * @return string Label of status |
369 | 369 | */ |
370 | - function getLibStatut($mode=0) |
|
370 | + function getLibStatut($mode = 0) |
|
371 | 371 | { |
372 | - return $this->LibStatut($this->status,$mode); |
|
372 | + return $this->LibStatut($this->status, $mode); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
381 | 381 | * @return string Label of status |
382 | 382 | */ |
383 | - static function LibStatut($status,$mode=0) |
|
383 | + static function LibStatut($status, $mode = 0) |
|
384 | 384 | { |
385 | 385 | // phpcs:enable |
386 | 386 | global $langs; |
@@ -392,28 +392,28 @@ discard block |
||
392 | 392 | } |
393 | 393 | elseif ($mode == 2) |
394 | 394 | { |
395 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
396 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
395 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); |
|
396 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); |
|
397 | 397 | } |
398 | 398 | elseif ($mode == 3) |
399 | 399 | { |
400 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
401 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
400 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); |
|
401 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); |
|
402 | 402 | } |
403 | 403 | elseif ($mode == 4) |
404 | 404 | { |
405 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
406 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
405 | + if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); |
|
406 | + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); |
|
407 | 407 | } |
408 | 408 | elseif ($mode == 5) |
409 | 409 | { |
410 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
411 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
410 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); |
|
411 | + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); |
|
412 | 412 | } |
413 | 413 | elseif ($mode == 6) |
414 | 414 | { |
415 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
416 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
415 | + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); |
|
416 | + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | function info($id) |
427 | 427 | { |
428 | 428 | $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; |
429 | - $sql.= ' fk_user_creat, fk_user_modif'; |
|
430 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
431 | - $sql.= ' WHERE t.rowid = '.$id; |
|
432 | - $result=$this->db->query($sql); |
|
429 | + $sql .= ' fk_user_creat, fk_user_modif'; |
|
430 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
|
431 | + $sql .= ' WHERE t.rowid = '.$id; |
|
432 | + $result = $this->db->query($sql); |
|
433 | 433 | if ($result) |
434 | 434 | { |
435 | 435 | if ($this->db->num_rows($result)) |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | { |
441 | 441 | $cuser = new User($this->db); |
442 | 442 | $cuser->fetch($obj->fk_user_author); |
443 | - $this->user_creation = $cuser; |
|
443 | + $this->user_creation = $cuser; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | if ($obj->fk_user_valid) |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | { |
455 | 455 | $cluser = new User($this->db); |
456 | 456 | $cluser->fetch($obj->fk_user_cloture); |
457 | - $this->user_cloture = $cluser; |
|
457 | + $this->user_cloture = $cluser; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | $this->date_creation = $this->db->jdate($obj->datec); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | global $conf, $langs; |
494 | 494 | |
495 | 495 | $this->output = ''; |
496 | - $this->error=''; |
|
496 | + $this->error = ''; |
|
497 | 497 | |
498 | 498 | dol_syslog(__METHOD__, LOG_DEBUG); |
499 | 499 |
@@ -184,8 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | $this->db = $db; |
186 | 186 | |
187 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
188 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
187 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { |
|
188 | + $this->fields['rowid']['visible']=0; |
|
189 | + } |
|
190 | + if (empty($conf->multicompany->enabled)) { |
|
191 | + $this->fields['entity']['enabled']=0; |
|
192 | + } |
|
189 | 193 | } |
190 | 194 | |
191 | 195 | /** |
@@ -316,7 +320,10 @@ discard block |
||
316 | 320 | global $dolibarr_main_authentication, $dolibarr_main_demo; |
317 | 321 | global $menumanager; |
318 | 322 | |
319 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
323 | + if (! empty($conf->dol_no_mouse_hover)) { |
|
324 | + $notooltip=1; |
|
325 | + } |
|
326 | + // Force disable tooltips |
|
320 | 327 | |
321 | 328 | $result = ''; |
322 | 329 | $companylink = ''; |
@@ -331,8 +338,12 @@ discard block |
||
331 | 338 | { |
332 | 339 | // Add param to save lastsearch_values or not |
333 | 340 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
334 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
335 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
341 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
342 | + $add_save_lastsearch_values=1; |
|
343 | + } |
|
344 | + if ($add_save_lastsearch_values) { |
|
345 | + $url.='&save_lastsearch_values=1'; |
|
346 | + } |
|
336 | 347 | } |
337 | 348 | |
338 | 349 | $linkclose=''; |
@@ -345,16 +356,21 @@ discard block |
||
345 | 356 | } |
346 | 357 | $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; |
347 | 358 | $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; |
359 | + } else { |
|
360 | + $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
348 | 361 | } |
349 | - else $linkclose = ($morecss?' class="'.$morecss.'"':''); |
|
350 | 362 | |
351 | 363 | $linkstart = '<a href="'.$url.'"'; |
352 | 364 | $linkstart.=$linkclose.'>'; |
353 | 365 | $linkend='</a>'; |
354 | 366 | |
355 | 367 | $result .= $linkstart; |
356 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
357 | - if ($withpicto != 2) $result.= $this->ref; |
|
368 | + if ($withpicto) { |
|
369 | + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
370 | + } |
|
371 | + if ($withpicto != 2) { |
|
372 | + $result.= $this->ref; |
|
373 | + } |
|
358 | 374 | $result .= $linkend; |
359 | 375 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
360 | 376 | |
@@ -387,33 +403,46 @@ discard block |
||
387 | 403 | |
388 | 404 | if ($mode == 0 || $mode == 1) |
389 | 405 | { |
390 | - if ($status == 1) return $langs->trans('Enabled'); |
|
391 | - elseif ($status == 0) return $langs->trans('Disabled'); |
|
392 | - } |
|
393 | - elseif ($mode == 2) |
|
406 | + if ($status == 1) { |
|
407 | + return $langs->trans('Enabled'); |
|
408 | + } elseif ($status == 0) { |
|
409 | + return $langs->trans('Disabled'); |
|
410 | + } |
|
411 | + } elseif ($mode == 2) |
|
394 | 412 | { |
395 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
396 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
397 | - } |
|
398 | - elseif ($mode == 3) |
|
413 | + if ($status == 1) { |
|
414 | + return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
415 | + } elseif ($status == 0) { |
|
416 | + return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
417 | + } |
|
418 | + } elseif ($mode == 3) |
|
399 | 419 | { |
400 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
401 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
402 | - } |
|
403 | - elseif ($mode == 4) |
|
420 | + if ($status == 1) { |
|
421 | + return img_picto($langs->trans('Enabled'),'statut4'); |
|
422 | + } elseif ($status == 0) { |
|
423 | + return img_picto($langs->trans('Disabled'),'statut5'); |
|
424 | + } |
|
425 | + } elseif ($mode == 4) |
|
404 | 426 | { |
405 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
406 | - elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
407 | - } |
|
408 | - elseif ($mode == 5) |
|
427 | + if ($status == 1) { |
|
428 | + return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
429 | + } elseif ($status == 0) { |
|
430 | + return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
431 | + } |
|
432 | + } elseif ($mode == 5) |
|
409 | 433 | { |
410 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
411 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
412 | - } |
|
413 | - elseif ($mode == 6) |
|
434 | + if ($status == 1) { |
|
435 | + return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
436 | + } elseif ($status == 0) { |
|
437 | + return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
438 | + } |
|
439 | + } elseif ($mode == 6) |
|
414 | 440 | { |
415 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
416 | - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
441 | + if ($status == 1) { |
|
442 | + return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
443 | + } elseif ($status == 0) { |
|
444 | + return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
445 | + } |
|
417 | 446 | } |
418 | 447 | } |
419 | 448 | |
@@ -463,8 +492,7 @@ discard block |
||
463 | 492 | } |
464 | 493 | |
465 | 494 | $this->db->free($result); |
466 | - } |
|
467 | - else |
|
495 | + } else |
|
468 | 496 | { |
469 | 497 | dol_print_error($this->db); |
470 | 498 | } |
@@ -29,432 +29,432 @@ |
||
29 | 29 | */ |
30 | 30 | class AssetType extends CommonObject |
31 | 31 | { |
32 | - /** |
|
33 | - * @var string Name of table without prefix where object is stored |
|
34 | - */ |
|
35 | - public $table_element = 'asset_type'; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string ID to identify managed object |
|
39 | - */ |
|
40 | - public $element = 'asset_type'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png |
|
44 | - */ |
|
45 | - public $picto = 'invoice'; |
|
46 | - |
|
47 | - /** |
|
48 | - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - public $ismultientitymanaged = 1; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var string Asset type label |
|
55 | - */ |
|
56 | - public $label; |
|
57 | - |
|
58 | - /** @var string Accountancy code asset */ |
|
59 | - public $accountancy_code_asset; |
|
60 | - |
|
61 | - /** @var string Accountancy code depreciation asset */ |
|
62 | - public $accountancy_code_depreciation_asset; |
|
63 | - |
|
64 | - /** @var string Accountancy code depreciation expense */ |
|
65 | - public $accountancy_code_depreciation_expense; |
|
66 | - |
|
67 | - /** @var string Public note */ |
|
68 | - public $note; |
|
69 | - |
|
70 | - /** @var array Array of asset */ |
|
71 | - public $asset=array(); |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Constructor |
|
76 | - * |
|
77 | - * @param DoliDB $db Database handler |
|
78 | - */ |
|
79 | - function __construct($db) |
|
80 | - { |
|
81 | - $this->db = $db; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Fonction qui permet de creer le type d'immobilisation |
|
87 | - * |
|
88 | - * @param User $user User making creation |
|
89 | - * @param int $notrigger 1=do not execute triggers, 0 otherwise |
|
90 | - * @return int >0 if OK, < 0 if KO |
|
91 | - */ |
|
92 | - function create($user,$notrigger=0) |
|
93 | - { |
|
94 | - global $conf; |
|
95 | - |
|
96 | - $error=0; |
|
97 | - |
|
98 | - $this->label=trim($this->label); |
|
99 | - $this->accountancy_code_asset = trim($this->accountancy_code_asset); |
|
100 | - $this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset); |
|
101 | - $this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense); |
|
102 | - |
|
103 | - $this->db->begin(); |
|
104 | - |
|
105 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; |
|
106 | - $sql.= "label"; |
|
107 | - $sql.= ", accountancy_code_asset"; |
|
108 | - $sql.= ", accountancy_code_depreciation_asset"; |
|
109 | - $sql.= ", accountancy_code_depreciation_expense"; |
|
110 | - $sql.= ", note"; |
|
111 | - $sql.= ", entity"; |
|
112 | - $sql.= ") VALUES ("; |
|
113 | - $sql.= "'".$this->db->escape($this->label)."'"; |
|
114 | - $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; |
|
115 | - $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; |
|
116 | - $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; |
|
117 | - $sql.= ", '".$this->db->escape($this->note)."'"; |
|
118 | - $sql.= ", ".$conf->entity; |
|
119 | - $sql.= ")"; |
|
120 | - |
|
121 | - dol_syslog("Asset_type::create", LOG_DEBUG); |
|
122 | - $result = $this->db->query($sql); |
|
123 | - if ($result) |
|
124 | - { |
|
125 | - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type"); |
|
126 | - |
|
127 | - $result = $this->update($user,1); |
|
128 | - if ($result < 0) |
|
129 | - { |
|
130 | - $this->db->rollback(); |
|
131 | - return -3; |
|
132 | - } |
|
133 | - |
|
134 | - if (! $notrigger) |
|
135 | - { |
|
136 | - // Call trigger |
|
137 | - $result=$this->call_trigger('ASSET_TYPE_CREATE',$user); |
|
138 | - if ($result < 0) { $error++; } |
|
139 | - // End call triggers |
|
140 | - } |
|
141 | - |
|
142 | - if (! $error) |
|
143 | - { |
|
144 | - $this->db->commit(); |
|
145 | - return $this->id; |
|
146 | - } |
|
147 | - else |
|
148 | - { |
|
149 | - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
|
150 | - $this->db->rollback(); |
|
151 | - return -2; |
|
152 | - } |
|
153 | - } |
|
154 | - else |
|
155 | - { |
|
156 | - $this->error=$this->db->lasterror(); |
|
157 | - $this->db->rollback(); |
|
158 | - return -1; |
|
159 | - } |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Met a jour en base donnees du type |
|
164 | - * |
|
165 | - * @param User $user Object user making change |
|
166 | - * @param int $notrigger 1=do not execute triggers, 0 otherwise |
|
167 | - * @return int >0 if OK, < 0 if KO |
|
168 | - */ |
|
169 | - function update($user,$notrigger=0) |
|
170 | - { |
|
171 | - global $conf, $hookmanager; |
|
172 | - |
|
173 | - $error=0; |
|
174 | - |
|
175 | - $this->label=trim($this->label); |
|
176 | - |
|
177 | - $this->db->begin(); |
|
178 | - |
|
179 | - $sql = "UPDATE ".MAIN_DB_PREFIX."asset_type "; |
|
180 | - $sql.= "SET "; |
|
181 | - $sql.= "label = '".$this->db->escape($this->label) ."',"; |
|
182 | - $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; |
|
183 | - $sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; |
|
184 | - $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; |
|
185 | - $sql.= "note = '".$this->db->escape($this->note) ."'"; |
|
186 | - $sql.= " WHERE rowid =".$this->id; |
|
187 | - |
|
188 | - $result = $this->db->query($sql); |
|
189 | - if ($result) |
|
190 | - { |
|
191 | - $action='update'; |
|
192 | - |
|
193 | - // Actions on extra fields |
|
194 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
195 | - { |
|
196 | - $result=$this->insertExtraFields(); |
|
197 | - if ($result < 0) |
|
198 | - { |
|
199 | - $error++; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - if (! $error && ! $notrigger) |
|
204 | - { |
|
205 | - // Call trigger |
|
206 | - $result=$this->call_trigger('ASSET_TYPE_MODIFY',$user); |
|
207 | - if ($result < 0) { $error++; } |
|
208 | - // End call triggers |
|
209 | - } |
|
210 | - |
|
211 | - if (! $error) |
|
212 | - { |
|
213 | - $this->db->commit(); |
|
214 | - return 1; |
|
215 | - } |
|
216 | - else |
|
217 | - { |
|
218 | - $this->db->rollback(); |
|
219 | - dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); |
|
220 | - return -$error; |
|
221 | - } |
|
222 | - } |
|
223 | - else |
|
224 | - { |
|
225 | - $this->error=$this->db->lasterror(); |
|
226 | - $this->db->rollback(); |
|
227 | - return -1; |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Fonction qui permet de supprimer le status de l'adherent |
|
233 | - * |
|
234 | - * @return int >0 if OK, 0 if not found, < 0 if KO |
|
235 | - */ |
|
236 | - function delete() |
|
237 | - { |
|
238 | - global $user; |
|
239 | - |
|
240 | - $error = 0; |
|
241 | - |
|
242 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type"; |
|
243 | - $sql.= " WHERE rowid = ".$this->id; |
|
244 | - |
|
245 | - $resql=$this->db->query($sql); |
|
246 | - if ($resql) |
|
247 | - { |
|
248 | - // Call trigger |
|
249 | - $result=$this->call_trigger('ASSET_TYPE_DELETE',$user); |
|
250 | - if ($result < 0) { $error++; $this->db->rollback(); return -2; } |
|
251 | - // End call triggers |
|
252 | - |
|
253 | - $this->db->commit(); |
|
254 | - return 1; |
|
255 | - } |
|
256 | - else |
|
257 | - { |
|
258 | - $this->db->rollback(); |
|
259 | - $this->error=$this->db->lasterror(); |
|
260 | - return -1; |
|
261 | - } |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Fonction qui permet de recuperer le status de l'immobilisation |
|
266 | - * |
|
267 | - * @param int $rowid Id of member type to load |
|
268 | - * @return int <0 if KO, >0 if OK |
|
269 | - */ |
|
270 | - function fetch($rowid) |
|
271 | - { |
|
272 | - $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; |
|
273 | - $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
274 | - $sql .= " WHERE d.rowid = ".(int) $rowid; |
|
275 | - |
|
276 | - dol_syslog("Asset_type::fetch", LOG_DEBUG); |
|
277 | - |
|
278 | - $resql=$this->db->query($sql); |
|
279 | - if ($resql) |
|
280 | - { |
|
281 | - if ($this->db->num_rows($resql)) |
|
282 | - { |
|
283 | - $obj = $this->db->fetch_object($resql); |
|
284 | - |
|
285 | - $this->id = $obj->rowid; |
|
286 | - $this->ref = $obj->rowid; |
|
287 | - $this->label = $obj->label; |
|
288 | - $this->accountancy_code_asset = $obj->accountancy_code_asset; |
|
289 | - $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; |
|
290 | - $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; |
|
291 | - $this->note = $obj->note; |
|
292 | - } |
|
293 | - |
|
294 | - return 1; |
|
295 | - } |
|
296 | - else |
|
297 | - { |
|
298 | - $this->error=$this->db->lasterror(); |
|
299 | - return -1; |
|
300 | - } |
|
301 | - } |
|
32 | + /** |
|
33 | + * @var string Name of table without prefix where object is stored |
|
34 | + */ |
|
35 | + public $table_element = 'asset_type'; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string ID to identify managed object |
|
39 | + */ |
|
40 | + public $element = 'asset_type'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png |
|
44 | + */ |
|
45 | + public $picto = 'invoice'; |
|
46 | + |
|
47 | + /** |
|
48 | + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + public $ismultientitymanaged = 1; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var string Asset type label |
|
55 | + */ |
|
56 | + public $label; |
|
57 | + |
|
58 | + /** @var string Accountancy code asset */ |
|
59 | + public $accountancy_code_asset; |
|
60 | + |
|
61 | + /** @var string Accountancy code depreciation asset */ |
|
62 | + public $accountancy_code_depreciation_asset; |
|
63 | + |
|
64 | + /** @var string Accountancy code depreciation expense */ |
|
65 | + public $accountancy_code_depreciation_expense; |
|
66 | + |
|
67 | + /** @var string Public note */ |
|
68 | + public $note; |
|
69 | + |
|
70 | + /** @var array Array of asset */ |
|
71 | + public $asset=array(); |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Constructor |
|
76 | + * |
|
77 | + * @param DoliDB $db Database handler |
|
78 | + */ |
|
79 | + function __construct($db) |
|
80 | + { |
|
81 | + $this->db = $db; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Fonction qui permet de creer le type d'immobilisation |
|
87 | + * |
|
88 | + * @param User $user User making creation |
|
89 | + * @param int $notrigger 1=do not execute triggers, 0 otherwise |
|
90 | + * @return int >0 if OK, < 0 if KO |
|
91 | + */ |
|
92 | + function create($user,$notrigger=0) |
|
93 | + { |
|
94 | + global $conf; |
|
95 | + |
|
96 | + $error=0; |
|
97 | + |
|
98 | + $this->label=trim($this->label); |
|
99 | + $this->accountancy_code_asset = trim($this->accountancy_code_asset); |
|
100 | + $this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset); |
|
101 | + $this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense); |
|
102 | + |
|
103 | + $this->db->begin(); |
|
104 | + |
|
105 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; |
|
106 | + $sql.= "label"; |
|
107 | + $sql.= ", accountancy_code_asset"; |
|
108 | + $sql.= ", accountancy_code_depreciation_asset"; |
|
109 | + $sql.= ", accountancy_code_depreciation_expense"; |
|
110 | + $sql.= ", note"; |
|
111 | + $sql.= ", entity"; |
|
112 | + $sql.= ") VALUES ("; |
|
113 | + $sql.= "'".$this->db->escape($this->label)."'"; |
|
114 | + $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; |
|
115 | + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; |
|
116 | + $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; |
|
117 | + $sql.= ", '".$this->db->escape($this->note)."'"; |
|
118 | + $sql.= ", ".$conf->entity; |
|
119 | + $sql.= ")"; |
|
120 | + |
|
121 | + dol_syslog("Asset_type::create", LOG_DEBUG); |
|
122 | + $result = $this->db->query($sql); |
|
123 | + if ($result) |
|
124 | + { |
|
125 | + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type"); |
|
126 | + |
|
127 | + $result = $this->update($user,1); |
|
128 | + if ($result < 0) |
|
129 | + { |
|
130 | + $this->db->rollback(); |
|
131 | + return -3; |
|
132 | + } |
|
133 | + |
|
134 | + if (! $notrigger) |
|
135 | + { |
|
136 | + // Call trigger |
|
137 | + $result=$this->call_trigger('ASSET_TYPE_CREATE',$user); |
|
138 | + if ($result < 0) { $error++; } |
|
139 | + // End call triggers |
|
140 | + } |
|
141 | + |
|
142 | + if (! $error) |
|
143 | + { |
|
144 | + $this->db->commit(); |
|
145 | + return $this->id; |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
|
150 | + $this->db->rollback(); |
|
151 | + return -2; |
|
152 | + } |
|
153 | + } |
|
154 | + else |
|
155 | + { |
|
156 | + $this->error=$this->db->lasterror(); |
|
157 | + $this->db->rollback(); |
|
158 | + return -1; |
|
159 | + } |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Met a jour en base donnees du type |
|
164 | + * |
|
165 | + * @param User $user Object user making change |
|
166 | + * @param int $notrigger 1=do not execute triggers, 0 otherwise |
|
167 | + * @return int >0 if OK, < 0 if KO |
|
168 | + */ |
|
169 | + function update($user,$notrigger=0) |
|
170 | + { |
|
171 | + global $conf, $hookmanager; |
|
172 | + |
|
173 | + $error=0; |
|
174 | + |
|
175 | + $this->label=trim($this->label); |
|
176 | + |
|
177 | + $this->db->begin(); |
|
178 | + |
|
179 | + $sql = "UPDATE ".MAIN_DB_PREFIX."asset_type "; |
|
180 | + $sql.= "SET "; |
|
181 | + $sql.= "label = '".$this->db->escape($this->label) ."',"; |
|
182 | + $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; |
|
183 | + $sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; |
|
184 | + $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; |
|
185 | + $sql.= "note = '".$this->db->escape($this->note) ."'"; |
|
186 | + $sql.= " WHERE rowid =".$this->id; |
|
187 | + |
|
188 | + $result = $this->db->query($sql); |
|
189 | + if ($result) |
|
190 | + { |
|
191 | + $action='update'; |
|
192 | + |
|
193 | + // Actions on extra fields |
|
194 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
195 | + { |
|
196 | + $result=$this->insertExtraFields(); |
|
197 | + if ($result < 0) |
|
198 | + { |
|
199 | + $error++; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + if (! $error && ! $notrigger) |
|
204 | + { |
|
205 | + // Call trigger |
|
206 | + $result=$this->call_trigger('ASSET_TYPE_MODIFY',$user); |
|
207 | + if ($result < 0) { $error++; } |
|
208 | + // End call triggers |
|
209 | + } |
|
210 | + |
|
211 | + if (! $error) |
|
212 | + { |
|
213 | + $this->db->commit(); |
|
214 | + return 1; |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
218 | + $this->db->rollback(); |
|
219 | + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); |
|
220 | + return -$error; |
|
221 | + } |
|
222 | + } |
|
223 | + else |
|
224 | + { |
|
225 | + $this->error=$this->db->lasterror(); |
|
226 | + $this->db->rollback(); |
|
227 | + return -1; |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Fonction qui permet de supprimer le status de l'adherent |
|
233 | + * |
|
234 | + * @return int >0 if OK, 0 if not found, < 0 if KO |
|
235 | + */ |
|
236 | + function delete() |
|
237 | + { |
|
238 | + global $user; |
|
239 | + |
|
240 | + $error = 0; |
|
241 | + |
|
242 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type"; |
|
243 | + $sql.= " WHERE rowid = ".$this->id; |
|
244 | + |
|
245 | + $resql=$this->db->query($sql); |
|
246 | + if ($resql) |
|
247 | + { |
|
248 | + // Call trigger |
|
249 | + $result=$this->call_trigger('ASSET_TYPE_DELETE',$user); |
|
250 | + if ($result < 0) { $error++; $this->db->rollback(); return -2; } |
|
251 | + // End call triggers |
|
252 | + |
|
253 | + $this->db->commit(); |
|
254 | + return 1; |
|
255 | + } |
|
256 | + else |
|
257 | + { |
|
258 | + $this->db->rollback(); |
|
259 | + $this->error=$this->db->lasterror(); |
|
260 | + return -1; |
|
261 | + } |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Fonction qui permet de recuperer le status de l'immobilisation |
|
266 | + * |
|
267 | + * @param int $rowid Id of member type to load |
|
268 | + * @return int <0 if KO, >0 if OK |
|
269 | + */ |
|
270 | + function fetch($rowid) |
|
271 | + { |
|
272 | + $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; |
|
273 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; |
|
274 | + $sql .= " WHERE d.rowid = ".(int) $rowid; |
|
275 | + |
|
276 | + dol_syslog("Asset_type::fetch", LOG_DEBUG); |
|
277 | + |
|
278 | + $resql=$this->db->query($sql); |
|
279 | + if ($resql) |
|
280 | + { |
|
281 | + if ($this->db->num_rows($resql)) |
|
282 | + { |
|
283 | + $obj = $this->db->fetch_object($resql); |
|
284 | + |
|
285 | + $this->id = $obj->rowid; |
|
286 | + $this->ref = $obj->rowid; |
|
287 | + $this->label = $obj->label; |
|
288 | + $this->accountancy_code_asset = $obj->accountancy_code_asset; |
|
289 | + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; |
|
290 | + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; |
|
291 | + $this->note = $obj->note; |
|
292 | + } |
|
293 | + |
|
294 | + return 1; |
|
295 | + } |
|
296 | + else |
|
297 | + { |
|
298 | + $this->error=$this->db->lasterror(); |
|
299 | + return -1; |
|
300 | + } |
|
301 | + } |
|
302 | 302 | |
303 | 303 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
304 | - /** |
|
305 | - * Return list of asset's type |
|
306 | - * |
|
307 | - * @return array List of types of members |
|
308 | - */ |
|
309 | - function liste_array() |
|
310 | - { |
|
304 | + /** |
|
305 | + * Return list of asset's type |
|
306 | + * |
|
307 | + * @return array List of types of members |
|
308 | + */ |
|
309 | + function liste_array() |
|
310 | + { |
|
311 | 311 | // phpcs:enable |
312 | - global $conf,$langs; |
|
313 | - |
|
314 | - $assettypes = array(); |
|
315 | - |
|
316 | - $sql = "SELECT rowid, label as label"; |
|
317 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type"; |
|
318 | - $sql.= " WHERE entity IN (".getEntity('asset_type').")"; |
|
319 | - |
|
320 | - $resql=$this->db->query($sql); |
|
321 | - if ($resql) |
|
322 | - { |
|
323 | - $nump = $this->db->num_rows($resql); |
|
324 | - |
|
325 | - if ($nump) |
|
326 | - { |
|
327 | - $i = 0; |
|
328 | - while ($i < $nump) |
|
329 | - { |
|
330 | - $obj = $this->db->fetch_object($resql); |
|
331 | - |
|
332 | - $assettypes[$obj->rowid] = $langs->trans($obj->label); |
|
333 | - $i++; |
|
334 | - } |
|
335 | - } |
|
336 | - } |
|
337 | - else |
|
338 | - { |
|
339 | - print $this->db->error(); |
|
340 | - } |
|
341 | - return $assettypes; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Return array of Asset objects for asset type this->id (or all if this->id not defined) |
|
346 | - * |
|
347 | - * @param string $excludefilter Filter to exclude |
|
348 | - * @param int $mode 0=Return array of asset instance |
|
349 | - * 1=Return array of asset instance without extra data |
|
350 | - * 2=Return array of asset id only |
|
351 | - * @return mixed Array of asset or -1 on error |
|
352 | - */ |
|
353 | - function listAssetForAssetType($excludefilter='', $mode=0) |
|
354 | - { |
|
355 | - global $conf, $user; |
|
356 | - |
|
357 | - $ret=array(); |
|
358 | - |
|
359 | - $sql = "SELECT a.rowid"; |
|
360 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset as a"; |
|
361 | - $sql.= " WHERE a.entity IN (".getEntity('asset').")"; |
|
362 | - $sql.= " AND a.fk_asset_type = ".$this->id; |
|
363 | - if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; |
|
364 | - |
|
365 | - dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); |
|
366 | - $resql = $this->db->query($sql); |
|
367 | - if ($resql) |
|
368 | - { |
|
369 | - while ($obj = $this->db->fetch_object($resql)) |
|
370 | - { |
|
371 | - if (! array_key_exists($obj->rowid, $ret)) |
|
372 | - { |
|
373 | - if ($mode < 2) |
|
374 | - { |
|
375 | - $assetstatic=new Asset($this->db); |
|
376 | - if ($mode == 1) { |
|
377 | - $assetstatic->fetch($obj->rowid,'','','',false, false); |
|
378 | - } else { |
|
379 | - $assetstatic->fetch($obj->rowid); |
|
380 | - } |
|
381 | - $ret[$obj->rowid]=$assetstatic; |
|
382 | - } |
|
383 | - else $ret[$obj->rowid]=$obj->rowid; |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - $this->db->free($resql); |
|
388 | - |
|
389 | - $this->asset=$ret; |
|
390 | - |
|
391 | - return $ret; |
|
392 | - } |
|
393 | - else |
|
394 | - { |
|
395 | - $this->error=$this->db->lasterror(); |
|
396 | - return -1; |
|
397 | - } |
|
398 | - } |
|
399 | - |
|
400 | - /** |
|
401 | - * Return clicable name (with picto eventually) |
|
402 | - * |
|
403 | - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
|
404 | - * @param int $maxlen length max label |
|
405 | - * @param int $notooltip 1=Disable tooltip |
|
406 | - * @return string String with URL |
|
407 | - */ |
|
408 | - function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
409 | - { |
|
410 | - global $langs; |
|
411 | - |
|
412 | - $result=''; |
|
413 | - $label=$langs->trans("ShowTypeCard",$this->label); |
|
414 | - |
|
415 | - $linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
|
416 | - $linkend='</a>'; |
|
417 | - |
|
418 | - $result .= $linkstart; |
|
419 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
420 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); |
|
421 | - $result .= $linkend; |
|
422 | - |
|
423 | - return $result; |
|
424 | - } |
|
425 | - |
|
426 | - /** |
|
427 | - * Initialise an instance with random values. |
|
428 | - * Used to build previews or test instances. |
|
429 | - * id must be 0 if object instance is a specimen. |
|
430 | - * |
|
431 | - * @return void |
|
432 | - */ |
|
433 | - function initAsSpecimen() |
|
434 | - { |
|
435 | - global $conf, $user, $langs; |
|
436 | - |
|
437 | - // Initialize parameters |
|
438 | - $this->id = 0; |
|
439 | - $this->ref = 'ATSPEC'; |
|
440 | - $this->specimen=1; |
|
441 | - |
|
442 | - $this->label='ASSET TYPE SPECIMEN'; |
|
443 | - $this->note='This is a note'; |
|
444 | - |
|
445 | - // Assets of this asset type is just me |
|
446 | - $this->asset=array( |
|
447 | - $user->id => $user |
|
448 | - ); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * getLibStatut |
|
453 | - * |
|
454 | - * @return string Return status of a type of asset |
|
455 | - */ |
|
456 | - function getLibStatut() |
|
457 | - { |
|
458 | - return ''; |
|
459 | - } |
|
312 | + global $conf,$langs; |
|
313 | + |
|
314 | + $assettypes = array(); |
|
315 | + |
|
316 | + $sql = "SELECT rowid, label as label"; |
|
317 | + $sql.= " FROM ".MAIN_DB_PREFIX."asset_type"; |
|
318 | + $sql.= " WHERE entity IN (".getEntity('asset_type').")"; |
|
319 | + |
|
320 | + $resql=$this->db->query($sql); |
|
321 | + if ($resql) |
|
322 | + { |
|
323 | + $nump = $this->db->num_rows($resql); |
|
324 | + |
|
325 | + if ($nump) |
|
326 | + { |
|
327 | + $i = 0; |
|
328 | + while ($i < $nump) |
|
329 | + { |
|
330 | + $obj = $this->db->fetch_object($resql); |
|
331 | + |
|
332 | + $assettypes[$obj->rowid] = $langs->trans($obj->label); |
|
333 | + $i++; |
|
334 | + } |
|
335 | + } |
|
336 | + } |
|
337 | + else |
|
338 | + { |
|
339 | + print $this->db->error(); |
|
340 | + } |
|
341 | + return $assettypes; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Return array of Asset objects for asset type this->id (or all if this->id not defined) |
|
346 | + * |
|
347 | + * @param string $excludefilter Filter to exclude |
|
348 | + * @param int $mode 0=Return array of asset instance |
|
349 | + * 1=Return array of asset instance without extra data |
|
350 | + * 2=Return array of asset id only |
|
351 | + * @return mixed Array of asset or -1 on error |
|
352 | + */ |
|
353 | + function listAssetForAssetType($excludefilter='', $mode=0) |
|
354 | + { |
|
355 | + global $conf, $user; |
|
356 | + |
|
357 | + $ret=array(); |
|
358 | + |
|
359 | + $sql = "SELECT a.rowid"; |
|
360 | + $sql.= " FROM ".MAIN_DB_PREFIX."asset as a"; |
|
361 | + $sql.= " WHERE a.entity IN (".getEntity('asset').")"; |
|
362 | + $sql.= " AND a.fk_asset_type = ".$this->id; |
|
363 | + if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; |
|
364 | + |
|
365 | + dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); |
|
366 | + $resql = $this->db->query($sql); |
|
367 | + if ($resql) |
|
368 | + { |
|
369 | + while ($obj = $this->db->fetch_object($resql)) |
|
370 | + { |
|
371 | + if (! array_key_exists($obj->rowid, $ret)) |
|
372 | + { |
|
373 | + if ($mode < 2) |
|
374 | + { |
|
375 | + $assetstatic=new Asset($this->db); |
|
376 | + if ($mode == 1) { |
|
377 | + $assetstatic->fetch($obj->rowid,'','','',false, false); |
|
378 | + } else { |
|
379 | + $assetstatic->fetch($obj->rowid); |
|
380 | + } |
|
381 | + $ret[$obj->rowid]=$assetstatic; |
|
382 | + } |
|
383 | + else $ret[$obj->rowid]=$obj->rowid; |
|
384 | + } |
|
385 | + } |
|
386 | + |
|
387 | + $this->db->free($resql); |
|
388 | + |
|
389 | + $this->asset=$ret; |
|
390 | + |
|
391 | + return $ret; |
|
392 | + } |
|
393 | + else |
|
394 | + { |
|
395 | + $this->error=$this->db->lasterror(); |
|
396 | + return -1; |
|
397 | + } |
|
398 | + } |
|
399 | + |
|
400 | + /** |
|
401 | + * Return clicable name (with picto eventually) |
|
402 | + * |
|
403 | + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
|
404 | + * @param int $maxlen length max label |
|
405 | + * @param int $notooltip 1=Disable tooltip |
|
406 | + * @return string String with URL |
|
407 | + */ |
|
408 | + function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
409 | + { |
|
410 | + global $langs; |
|
411 | + |
|
412 | + $result=''; |
|
413 | + $label=$langs->trans("ShowTypeCard",$this->label); |
|
414 | + |
|
415 | + $linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
|
416 | + $linkend='</a>'; |
|
417 | + |
|
418 | + $result .= $linkstart; |
|
419 | + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
420 | + if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); |
|
421 | + $result .= $linkend; |
|
422 | + |
|
423 | + return $result; |
|
424 | + } |
|
425 | + |
|
426 | + /** |
|
427 | + * Initialise an instance with random values. |
|
428 | + * Used to build previews or test instances. |
|
429 | + * id must be 0 if object instance is a specimen. |
|
430 | + * |
|
431 | + * @return void |
|
432 | + */ |
|
433 | + function initAsSpecimen() |
|
434 | + { |
|
435 | + global $conf, $user, $langs; |
|
436 | + |
|
437 | + // Initialize parameters |
|
438 | + $this->id = 0; |
|
439 | + $this->ref = 'ATSPEC'; |
|
440 | + $this->specimen=1; |
|
441 | + |
|
442 | + $this->label='ASSET TYPE SPECIMEN'; |
|
443 | + $this->note='This is a note'; |
|
444 | + |
|
445 | + // Assets of this asset type is just me |
|
446 | + $this->asset=array( |
|
447 | + $user->id => $user |
|
448 | + ); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * getLibStatut |
|
453 | + * |
|
454 | + * @return string Return status of a type of asset |
|
455 | + */ |
|
456 | + function getLibStatut() |
|
457 | + { |
|
458 | + return ''; |
|
459 | + } |
|
460 | 460 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public $note; |
69 | 69 | |
70 | 70 | /** @var array Array of asset */ |
71 | - public $asset=array(); |
|
71 | + public $asset = array(); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * @param int $notrigger 1=do not execute triggers, 0 otherwise |
90 | 90 | * @return int >0 if OK, < 0 if KO |
91 | 91 | */ |
92 | - function create($user,$notrigger=0) |
|
92 | + function create($user, $notrigger = 0) |
|
93 | 93 | { |
94 | 94 | global $conf; |
95 | 95 | |
96 | - $error=0; |
|
96 | + $error = 0; |
|
97 | 97 | |
98 | - $this->label=trim($this->label); |
|
98 | + $this->label = trim($this->label); |
|
99 | 99 | $this->accountancy_code_asset = trim($this->accountancy_code_asset); |
100 | 100 | $this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset); |
101 | 101 | $this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense); |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | $this->db->begin(); |
104 | 104 | |
105 | 105 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type ("; |
106 | - $sql.= "label"; |
|
107 | - $sql.= ", accountancy_code_asset"; |
|
108 | - $sql.= ", accountancy_code_depreciation_asset"; |
|
109 | - $sql.= ", accountancy_code_depreciation_expense"; |
|
110 | - $sql.= ", note"; |
|
111 | - $sql.= ", entity"; |
|
112 | - $sql.= ") VALUES ("; |
|
113 | - $sql.= "'".$this->db->escape($this->label)."'"; |
|
114 | - $sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'"; |
|
115 | - $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; |
|
116 | - $sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; |
|
117 | - $sql.= ", '".$this->db->escape($this->note)."'"; |
|
118 | - $sql.= ", ".$conf->entity; |
|
119 | - $sql.= ")"; |
|
106 | + $sql .= "label"; |
|
107 | + $sql .= ", accountancy_code_asset"; |
|
108 | + $sql .= ", accountancy_code_depreciation_asset"; |
|
109 | + $sql .= ", accountancy_code_depreciation_expense"; |
|
110 | + $sql .= ", note"; |
|
111 | + $sql .= ", entity"; |
|
112 | + $sql .= ") VALUES ("; |
|
113 | + $sql .= "'".$this->db->escape($this->label)."'"; |
|
114 | + $sql .= ", '".$this->db->escape($this->accountancy_code_asset)."'"; |
|
115 | + $sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'"; |
|
116 | + $sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'"; |
|
117 | + $sql .= ", '".$this->db->escape($this->note)."'"; |
|
118 | + $sql .= ", ".$conf->entity; |
|
119 | + $sql .= ")"; |
|
120 | 120 | |
121 | 121 | dol_syslog("Asset_type::create", LOG_DEBUG); |
122 | 122 | $result = $this->db->query($sql); |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | { |
125 | 125 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type"); |
126 | 126 | |
127 | - $result = $this->update($user,1); |
|
127 | + $result = $this->update($user, 1); |
|
128 | 128 | if ($result < 0) |
129 | 129 | { |
130 | 130 | $this->db->rollback(); |
131 | 131 | return -3; |
132 | 132 | } |
133 | 133 | |
134 | - if (! $notrigger) |
|
134 | + if (!$notrigger) |
|
135 | 135 | { |
136 | 136 | // Call trigger |
137 | - $result=$this->call_trigger('ASSET_TYPE_CREATE',$user); |
|
137 | + $result = $this->call_trigger('ASSET_TYPE_CREATE', $user); |
|
138 | 138 | if ($result < 0) { $error++; } |
139 | 139 | // End call triggers |
140 | 140 | } |
141 | 141 | |
142 | - if (! $error) |
|
142 | + if (!$error) |
|
143 | 143 | { |
144 | 144 | $this->db->commit(); |
145 | 145 | return $this->id; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | else |
155 | 155 | { |
156 | - $this->error=$this->db->lasterror(); |
|
156 | + $this->error = $this->db->lasterror(); |
|
157 | 157 | $this->db->rollback(); |
158 | 158 | return -1; |
159 | 159 | } |
@@ -166,49 +166,49 @@ discard block |
||
166 | 166 | * @param int $notrigger 1=do not execute triggers, 0 otherwise |
167 | 167 | * @return int >0 if OK, < 0 if KO |
168 | 168 | */ |
169 | - function update($user,$notrigger=0) |
|
169 | + function update($user, $notrigger = 0) |
|
170 | 170 | { |
171 | 171 | global $conf, $hookmanager; |
172 | 172 | |
173 | - $error=0; |
|
173 | + $error = 0; |
|
174 | 174 | |
175 | - $this->label=trim($this->label); |
|
175 | + $this->label = trim($this->label); |
|
176 | 176 | |
177 | 177 | $this->db->begin(); |
178 | 178 | |
179 | 179 | $sql = "UPDATE ".MAIN_DB_PREFIX."asset_type "; |
180 | - $sql.= "SET "; |
|
181 | - $sql.= "label = '".$this->db->escape($this->label) ."',"; |
|
182 | - $sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; |
|
183 | - $sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; |
|
184 | - $sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; |
|
185 | - $sql.= "note = '".$this->db->escape($this->note) ."'"; |
|
186 | - $sql.= " WHERE rowid =".$this->id; |
|
180 | + $sql .= "SET "; |
|
181 | + $sql .= "label = '".$this->db->escape($this->label)."',"; |
|
182 | + $sql .= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',"; |
|
183 | + $sql .= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; |
|
184 | + $sql .= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; |
|
185 | + $sql .= "note = '".$this->db->escape($this->note)."'"; |
|
186 | + $sql .= " WHERE rowid =".$this->id; |
|
187 | 187 | |
188 | 188 | $result = $this->db->query($sql); |
189 | 189 | if ($result) |
190 | 190 | { |
191 | - $action='update'; |
|
191 | + $action = 'update'; |
|
192 | 192 | |
193 | 193 | // Actions on extra fields |
194 | 194 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
195 | 195 | { |
196 | - $result=$this->insertExtraFields(); |
|
196 | + $result = $this->insertExtraFields(); |
|
197 | 197 | if ($result < 0) |
198 | 198 | { |
199 | 199 | $error++; |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - if (! $error && ! $notrigger) |
|
203 | + if (!$error && !$notrigger) |
|
204 | 204 | { |
205 | 205 | // Call trigger |
206 | - $result=$this->call_trigger('ASSET_TYPE_MODIFY',$user); |
|
206 | + $result = $this->call_trigger('ASSET_TYPE_MODIFY', $user); |
|
207 | 207 | if ($result < 0) { $error++; } |
208 | 208 | // End call triggers |
209 | 209 | } |
210 | 210 | |
211 | - if (! $error) |
|
211 | + if (!$error) |
|
212 | 212 | { |
213 | 213 | $this->db->commit(); |
214 | 214 | return 1; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | else |
224 | 224 | { |
225 | - $this->error=$this->db->lasterror(); |
|
225 | + $this->error = $this->db->lasterror(); |
|
226 | 226 | $this->db->rollback(); |
227 | 227 | return -1; |
228 | 228 | } |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | $error = 0; |
241 | 241 | |
242 | 242 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type"; |
243 | - $sql.= " WHERE rowid = ".$this->id; |
|
243 | + $sql .= " WHERE rowid = ".$this->id; |
|
244 | 244 | |
245 | - $resql=$this->db->query($sql); |
|
245 | + $resql = $this->db->query($sql); |
|
246 | 246 | if ($resql) |
247 | 247 | { |
248 | 248 | // Call trigger |
249 | - $result=$this->call_trigger('ASSET_TYPE_DELETE',$user); |
|
249 | + $result = $this->call_trigger('ASSET_TYPE_DELETE', $user); |
|
250 | 250 | if ($result < 0) { $error++; $this->db->rollback(); return -2; } |
251 | 251 | // End call triggers |
252 | 252 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | else |
257 | 257 | { |
258 | 258 | $this->db->rollback(); |
259 | - $this->error=$this->db->lasterror(); |
|
259 | + $this->error = $this->db->lasterror(); |
|
260 | 260 | return -1; |
261 | 261 | } |
262 | 262 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | dol_syslog("Asset_type::fetch", LOG_DEBUG); |
277 | 277 | |
278 | - $resql=$this->db->query($sql); |
|
278 | + $resql = $this->db->query($sql); |
|
279 | 279 | if ($resql) |
280 | 280 | { |
281 | 281 | if ($this->db->num_rows($resql)) |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - $this->error=$this->db->lasterror(); |
|
298 | + $this->error = $this->db->lasterror(); |
|
299 | 299 | return -1; |
300 | 300 | } |
301 | 301 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | function liste_array() |
310 | 310 | { |
311 | 311 | // phpcs:enable |
312 | - global $conf,$langs; |
|
312 | + global $conf, $langs; |
|
313 | 313 | |
314 | 314 | $assettypes = array(); |
315 | 315 | |
316 | 316 | $sql = "SELECT rowid, label as label"; |
317 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset_type"; |
|
318 | - $sql.= " WHERE entity IN (".getEntity('asset_type').")"; |
|
317 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_type"; |
|
318 | + $sql .= " WHERE entity IN (".getEntity('asset_type').")"; |
|
319 | 319 | |
320 | - $resql=$this->db->query($sql); |
|
320 | + $resql = $this->db->query($sql); |
|
321 | 321 | if ($resql) |
322 | 322 | { |
323 | 323 | $nump = $this->db->num_rows($resql); |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | * 2=Return array of asset id only |
351 | 351 | * @return mixed Array of asset or -1 on error |
352 | 352 | */ |
353 | - function listAssetForAssetType($excludefilter='', $mode=0) |
|
353 | + function listAssetForAssetType($excludefilter = '', $mode = 0) |
|
354 | 354 | { |
355 | 355 | global $conf, $user; |
356 | 356 | |
357 | - $ret=array(); |
|
357 | + $ret = array(); |
|
358 | 358 | |
359 | 359 | $sql = "SELECT a.rowid"; |
360 | - $sql.= " FROM ".MAIN_DB_PREFIX."asset as a"; |
|
361 | - $sql.= " WHERE a.entity IN (".getEntity('asset').")"; |
|
362 | - $sql.= " AND a.fk_asset_type = ".$this->id; |
|
363 | - if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; |
|
360 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset as a"; |
|
361 | + $sql .= " WHERE a.entity IN (".getEntity('asset').")"; |
|
362 | + $sql .= " AND a.fk_asset_type = ".$this->id; |
|
363 | + if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; |
|
364 | 364 | |
365 | 365 | dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); |
366 | 366 | $resql = $this->db->query($sql); |
@@ -368,31 +368,31 @@ discard block |
||
368 | 368 | { |
369 | 369 | while ($obj = $this->db->fetch_object($resql)) |
370 | 370 | { |
371 | - if (! array_key_exists($obj->rowid, $ret)) |
|
371 | + if (!array_key_exists($obj->rowid, $ret)) |
|
372 | 372 | { |
373 | 373 | if ($mode < 2) |
374 | 374 | { |
375 | - $assetstatic=new Asset($this->db); |
|
375 | + $assetstatic = new Asset($this->db); |
|
376 | 376 | if ($mode == 1) { |
377 | - $assetstatic->fetch($obj->rowid,'','','',false, false); |
|
377 | + $assetstatic->fetch($obj->rowid, '', '', '', false, false); |
|
378 | 378 | } else { |
379 | 379 | $assetstatic->fetch($obj->rowid); |
380 | 380 | } |
381 | - $ret[$obj->rowid]=$assetstatic; |
|
381 | + $ret[$obj->rowid] = $assetstatic; |
|
382 | 382 | } |
383 | - else $ret[$obj->rowid]=$obj->rowid; |
|
383 | + else $ret[$obj->rowid] = $obj->rowid; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | 387 | $this->db->free($resql); |
388 | 388 | |
389 | - $this->asset=$ret; |
|
389 | + $this->asset = $ret; |
|
390 | 390 | |
391 | 391 | return $ret; |
392 | 392 | } |
393 | 393 | else |
394 | 394 | { |
395 | - $this->error=$this->db->lasterror(); |
|
395 | + $this->error = $this->db->lasterror(); |
|
396 | 396 | return -1; |
397 | 397 | } |
398 | 398 | } |
@@ -405,19 +405,19 @@ discard block |
||
405 | 405 | * @param int $notooltip 1=Disable tooltip |
406 | 406 | * @return string String with URL |
407 | 407 | */ |
408 | - function getNomUrl($withpicto=0, $maxlen=0, $notooltip=0) |
|
408 | + function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) |
|
409 | 409 | { |
410 | 410 | global $langs; |
411 | 411 | |
412 | - $result=''; |
|
413 | - $label=$langs->trans("ShowTypeCard",$this->label); |
|
412 | + $result = ''; |
|
413 | + $label = $langs->trans("ShowTypeCard", $this->label); |
|
414 | 414 | |
415 | 415 | $linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; |
416 | - $linkend='</a>'; |
|
416 | + $linkend = '</a>'; |
|
417 | 417 | |
418 | 418 | $result .= $linkstart; |
419 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
420 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); |
|
419 | + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
420 | + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); |
|
421 | 421 | $result .= $linkend; |
422 | 422 | |
423 | 423 | return $result; |
@@ -437,13 +437,13 @@ discard block |
||
437 | 437 | // Initialize parameters |
438 | 438 | $this->id = 0; |
439 | 439 | $this->ref = 'ATSPEC'; |
440 | - $this->specimen=1; |
|
440 | + $this->specimen = 1; |
|
441 | 441 | |
442 | - $this->label='ASSET TYPE SPECIMEN'; |
|
443 | - $this->note='This is a note'; |
|
442 | + $this->label = 'ASSET TYPE SPECIMEN'; |
|
443 | + $this->note = 'This is a note'; |
|
444 | 444 | |
445 | 445 | // Assets of this asset type is just me |
446 | - $this->asset=array( |
|
446 | + $this->asset = array( |
|
447 | 447 | $user->id => $user |
448 | 448 | ); |
449 | 449 | } |
@@ -143,15 +143,13 @@ discard block |
||
143 | 143 | { |
144 | 144 | $this->db->commit(); |
145 | 145 | return $this->id; |
146 | - } |
|
147 | - else |
|
146 | + } else |
|
148 | 147 | { |
149 | 148 | dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); |
150 | 149 | $this->db->rollback(); |
151 | 150 | return -2; |
152 | 151 | } |
153 | - } |
|
154 | - else |
|
152 | + } else |
|
155 | 153 | { |
156 | 154 | $this->error=$this->db->lasterror(); |
157 | 155 | $this->db->rollback(); |
@@ -191,9 +189,11 @@ discard block |
||
191 | 189 | $action='update'; |
192 | 190 | |
193 | 191 | // Actions on extra fields |
194 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
192 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
193 | + // For avoid conflicts if trigger used |
|
195 | 194 | { |
196 | 195 | $result=$this->insertExtraFields(); |
196 | + } |
|
197 | 197 | if ($result < 0) |
198 | 198 | { |
199 | 199 | $error++; |
@@ -212,15 +212,13 @@ discard block |
||
212 | 212 | { |
213 | 213 | $this->db->commit(); |
214 | 214 | return 1; |
215 | - } |
|
216 | - else |
|
215 | + } else |
|
217 | 216 | { |
218 | 217 | $this->db->rollback(); |
219 | 218 | dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); |
220 | 219 | return -$error; |
221 | 220 | } |
222 | - } |
|
223 | - else |
|
221 | + } else |
|
224 | 222 | { |
225 | 223 | $this->error=$this->db->lasterror(); |
226 | 224 | $this->db->rollback(); |
@@ -252,8 +250,7 @@ discard block |
||
252 | 250 | |
253 | 251 | $this->db->commit(); |
254 | 252 | return 1; |
255 | - } |
|
256 | - else |
|
253 | + } else |
|
257 | 254 | { |
258 | 255 | $this->db->rollback(); |
259 | 256 | $this->error=$this->db->lasterror(); |
@@ -292,8 +289,7 @@ discard block |
||
292 | 289 | } |
293 | 290 | |
294 | 291 | return 1; |
295 | - } |
|
296 | - else |
|
292 | + } else |
|
297 | 293 | { |
298 | 294 | $this->error=$this->db->lasterror(); |
299 | 295 | return -1; |
@@ -333,8 +329,7 @@ discard block |
||
333 | 329 | $i++; |
334 | 330 | } |
335 | 331 | } |
336 | - } |
|
337 | - else |
|
332 | + } else |
|
338 | 333 | { |
339 | 334 | print $this->db->error(); |
340 | 335 | } |
@@ -360,7 +355,9 @@ discard block |
||
360 | 355 | $sql.= " FROM ".MAIN_DB_PREFIX."asset as a"; |
361 | 356 | $sql.= " WHERE a.entity IN (".getEntity('asset').")"; |
362 | 357 | $sql.= " AND a.fk_asset_type = ".$this->id; |
363 | - if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; |
|
358 | + if (! empty($excludefilter)) { |
|
359 | + $sql.=' AND ('.$excludefilter.')'; |
|
360 | + } |
|
364 | 361 | |
365 | 362 | dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG); |
366 | 363 | $resql = $this->db->query($sql); |
@@ -379,8 +376,9 @@ discard block |
||
379 | 376 | $assetstatic->fetch($obj->rowid); |
380 | 377 | } |
381 | 378 | $ret[$obj->rowid]=$assetstatic; |
379 | + } else { |
|
380 | + $ret[$obj->rowid]=$obj->rowid; |
|
382 | 381 | } |
383 | - else $ret[$obj->rowid]=$obj->rowid; |
|
384 | 382 | } |
385 | 383 | } |
386 | 384 | |
@@ -389,8 +387,7 @@ discard block |
||
389 | 387 | $this->asset=$ret; |
390 | 388 | |
391 | 389 | return $ret; |
392 | - } |
|
393 | - else |
|
390 | + } else |
|
394 | 391 | { |
395 | 392 | $this->error=$this->db->lasterror(); |
396 | 393 | return -1; |
@@ -416,8 +413,12 @@ discard block |
||
416 | 413 | $linkend='</a>'; |
417 | 414 | |
418 | 415 | $result .= $linkstart; |
419 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
420 | - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); |
|
416 | + if ($withpicto) { |
|
417 | + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); |
|
418 | + } |
|
419 | + if ($withpicto != 2) { |
|
420 | + $result.= ($maxlen?dol_trunc($this->label,$maxlen):$this->label); |
|
421 | + } |
|
421 | 422 | $result .= $linkend; |
422 | 423 | |
423 | 424 | return $result; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $search=array(); |
53 | 53 | foreach($object->fields as $key => $val) |
54 | 54 | { |
55 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
55 | + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (empty($action) && empty($id) && empty($ref)) $action='view'; |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | |
83 | 83 | if (empty($reshook)) |
84 | 84 | { |
85 | - $error=0; |
|
85 | + $error=0; |
|
86 | 86 | |
87 | - $permissiontoadd = $user->rights->asset->create; |
|
88 | - $permissiontodelete = $user->rights->asset->delete; |
|
89 | - $backurlforlist = dol_buildpath('/asset/list.php',1); |
|
87 | + $permissiontoadd = $user->rights->asset->create; |
|
88 | + $permissiontodelete = $user->rights->asset->delete; |
|
89 | + $backurlforlist = dol_buildpath('/asset/list.php',1); |
|
90 | 90 | |
91 | - // Actions cancel, add, update or delete |
|
92 | - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; |
|
91 | + // Actions cancel, add, update or delete |
|
92 | + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; |
|
93 | 93 | |
94 | - // Actions when printing a doc from card |
|
95 | - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
|
94 | + // Actions when printing a doc from card |
|
95 | + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
|
96 | 96 | |
97 | - // Actions to send emails |
|
98 | - $trigger_name='ASSET_SENTBYMAIL'; |
|
99 | - $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO'; |
|
100 | - $trackid='asset'.$object->id; |
|
101 | - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; |
|
97 | + // Actions to send emails |
|
98 | + $trigger_name='ASSET_SENTBYMAIL'; |
|
99 | + $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO'; |
|
100 | + $trackid='asset'.$object->id; |
|
101 | + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -136,185 +136,185 @@ discard block |
||
136 | 136 | // Part to create |
137 | 137 | if ($action == 'create') |
138 | 138 | { |
139 | - print load_fiche_titre($langs->trans("NewAsset")); |
|
139 | + print load_fiche_titre($langs->trans("NewAsset")); |
|
140 | 140 | |
141 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
142 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
143 | - print '<input type="hidden" name="action" value="add">'; |
|
144 | - print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
141 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
142 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
143 | + print '<input type="hidden" name="action" value="add">'; |
|
144 | + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
145 | 145 | |
146 | - dol_fiche_head(array(), ''); |
|
146 | + dol_fiche_head(array(), ''); |
|
147 | 147 | |
148 | - print '<table class="border centpercent">'."\n"; |
|
148 | + print '<table class="border centpercent">'."\n"; |
|
149 | 149 | |
150 | - // Common attributes |
|
151 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; |
|
150 | + // Common attributes |
|
151 | + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; |
|
152 | 152 | |
153 | - // Other attributes |
|
154 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; |
|
153 | + // Other attributes |
|
154 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; |
|
155 | 155 | |
156 | - print '</table>'."\n"; |
|
156 | + print '</table>'."\n"; |
|
157 | 157 | |
158 | - dol_fiche_end(); |
|
158 | + dol_fiche_end(); |
|
159 | 159 | |
160 | - print '<div class="center">'; |
|
161 | - print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; |
|
162 | - print ' '; |
|
163 | - print '<input type="'.($backtopage?"submit":"button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage?'':' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage |
|
164 | - print '</div>'; |
|
160 | + print '<div class="center">'; |
|
161 | + print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; |
|
162 | + print ' '; |
|
163 | + print '<input type="'.($backtopage?"submit":"button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage?'':' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage |
|
164 | + print '</div>'; |
|
165 | 165 | |
166 | - print '</form>'; |
|
166 | + print '</form>'; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Part to edit record |
170 | 170 | if (($id || $ref) && $action == 'edit') |
171 | 171 | { |
172 | - print load_fiche_titre($langs->trans("Assets")); |
|
172 | + print load_fiche_titre($langs->trans("Assets")); |
|
173 | 173 | |
174 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
175 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
176 | - print '<input type="hidden" name="action" value="update">'; |
|
177 | - print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
178 | - print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
174 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
175 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
176 | + print '<input type="hidden" name="action" value="update">'; |
|
177 | + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
178 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
179 | 179 | |
180 | - dol_fiche_head(); |
|
180 | + dol_fiche_head(); |
|
181 | 181 | |
182 | - print '<table class="border centpercent">'."\n"; |
|
182 | + print '<table class="border centpercent">'."\n"; |
|
183 | 183 | |
184 | - // Common attributes |
|
185 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; |
|
184 | + // Common attributes |
|
185 | + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; |
|
186 | 186 | |
187 | - // Other attributes |
|
188 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; |
|
187 | + // Other attributes |
|
188 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; |
|
189 | 189 | |
190 | - print '</table>'; |
|
190 | + print '</table>'; |
|
191 | 191 | |
192 | - dol_fiche_end(); |
|
192 | + dol_fiche_end(); |
|
193 | 193 | |
194 | - print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; |
|
195 | - print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
196 | - print '</div>'; |
|
194 | + print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; |
|
195 | + print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
196 | + print '</div>'; |
|
197 | 197 | |
198 | - print '</form>'; |
|
198 | + print '</form>'; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | // Part to show record |
202 | 202 | if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) |
203 | 203 | { |
204 | - $res = $object->fetch_optionals($object->id, $extralabels); |
|
204 | + $res = $object->fetch_optionals($object->id, $extralabels); |
|
205 | 205 | |
206 | - $head = asset_prepare_head($object); |
|
207 | - dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic'); |
|
206 | + $head = asset_prepare_head($object); |
|
207 | + dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic'); |
|
208 | 208 | |
209 | - $formconfirm = ''; |
|
209 | + $formconfirm = ''; |
|
210 | 210 | |
211 | - // Confirmation to delete |
|
212 | - if ($action == 'delete') |
|
213 | - { |
|
214 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); |
|
215 | - } |
|
211 | + // Confirmation to delete |
|
212 | + if ($action == 'delete') |
|
213 | + { |
|
214 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); |
|
215 | + } |
|
216 | 216 | |
217 | - // Confirmation of action xxxx |
|
218 | - if ($action == 'xxx') |
|
219 | - { |
|
220 | - $formquestion=array(); |
|
221 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
222 | - } |
|
217 | + // Confirmation of action xxxx |
|
218 | + if ($action == 'xxx') |
|
219 | + { |
|
220 | + $formquestion=array(); |
|
221 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
222 | + } |
|
223 | 223 | |
224 | - // Call Hook formConfirm |
|
225 | - $parameters = array('lineid' => $lineid); |
|
226 | - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
227 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
228 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
224 | + // Call Hook formConfirm |
|
225 | + $parameters = array('lineid' => $lineid); |
|
226 | + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
227 | + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
228 | + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
229 | 229 | |
230 | - // Print form confirm |
|
231 | - print $formconfirm; |
|
230 | + // Print form confirm |
|
231 | + print $formconfirm; |
|
232 | 232 | |
233 | 233 | |
234 | - // Object card |
|
235 | - // ------------------------------------------------------------ |
|
236 | - $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
234 | + // Object card |
|
235 | + // ------------------------------------------------------------ |
|
236 | + $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
237 | 237 | |
238 | - $morehtmlref='<div class="refidno">'; |
|
239 | - /* |
|
238 | + $morehtmlref='<div class="refidno">'; |
|
239 | + /* |
|
240 | 240 | // Ref bis |
241 | 241 | $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1); |
242 | 242 | $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', null, null, '', 1); |
243 | 243 | // Thirdparty |
244 | 244 | $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); |
245 | 245 | */ |
246 | - $morehtmlref.='</div>'; |
|
247 | - |
|
248 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
249 | - |
|
250 | - print '<div class="fichecenter">'; |
|
251 | - print '<div class="fichehalfleft">'; |
|
252 | - print '<div class="underbanner clearboth"></div>'; |
|
253 | - print '<table class="border centpercent">'."\n"; |
|
254 | - |
|
255 | - // Common attributes |
|
256 | - //$keyforbreak='fieldkeytoswithonsecondcolumn'; |
|
257 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; |
|
258 | - |
|
259 | - // Other attributes |
|
260 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
261 | - |
|
262 | - print '</table>'; |
|
263 | - print '</div>'; |
|
264 | - print '</div>'; |
|
265 | - print '</div>'; |
|
266 | - |
|
267 | - print '<div class="clearboth"></div><br>'; |
|
268 | - |
|
269 | - dol_fiche_end(); |
|
270 | - |
|
271 | - |
|
272 | - // Buttons for actions |
|
273 | - if ($action != 'presend' && $action != 'editline') { |
|
274 | - print '<div class="tabsAction">'."\n"; |
|
275 | - $parameters=array(); |
|
276 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
277 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
278 | - |
|
279 | - if (empty($reshook)) |
|
280 | - { |
|
281 | - // Send |
|
282 | - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; |
|
283 | - |
|
284 | - if ($user->rights->asset->write) |
|
285 | - { |
|
286 | - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; |
|
287 | - } |
|
288 | - else |
|
289 | - { |
|
290 | - print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; |
|
291 | - } |
|
292 | - |
|
293 | - if ($user->rights->asset->delete) |
|
294 | - { |
|
295 | - print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a>'."\n"; |
|
296 | - } |
|
297 | - else |
|
298 | - { |
|
299 | - print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; |
|
300 | - } |
|
301 | - } |
|
302 | - print '</div>'."\n"; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - // Select mail models is same action as presend |
|
307 | - if (GETPOST('modelselected')) { |
|
308 | - $action = 'presend'; |
|
309 | - } |
|
310 | - |
|
311 | - if ($action != 'presend') |
|
312 | - { |
|
313 | - print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
314 | - print '<a name="builddoc"></a>'; // ancre |
|
315 | - |
|
316 | - // Documents |
|
317 | - /*$objref = dol_sanitizeFileName($object->ref); |
|
246 | + $morehtmlref.='</div>'; |
|
247 | + |
|
248 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
249 | + |
|
250 | + print '<div class="fichecenter">'; |
|
251 | + print '<div class="fichehalfleft">'; |
|
252 | + print '<div class="underbanner clearboth"></div>'; |
|
253 | + print '<table class="border centpercent">'."\n"; |
|
254 | + |
|
255 | + // Common attributes |
|
256 | + //$keyforbreak='fieldkeytoswithonsecondcolumn'; |
|
257 | + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; |
|
258 | + |
|
259 | + // Other attributes |
|
260 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
261 | + |
|
262 | + print '</table>'; |
|
263 | + print '</div>'; |
|
264 | + print '</div>'; |
|
265 | + print '</div>'; |
|
266 | + |
|
267 | + print '<div class="clearboth"></div><br>'; |
|
268 | + |
|
269 | + dol_fiche_end(); |
|
270 | + |
|
271 | + |
|
272 | + // Buttons for actions |
|
273 | + if ($action != 'presend' && $action != 'editline') { |
|
274 | + print '<div class="tabsAction">'."\n"; |
|
275 | + $parameters=array(); |
|
276 | + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
277 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
278 | + |
|
279 | + if (empty($reshook)) |
|
280 | + { |
|
281 | + // Send |
|
282 | + print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; |
|
283 | + |
|
284 | + if ($user->rights->asset->write) |
|
285 | + { |
|
286 | + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; |
|
287 | + } |
|
288 | + else |
|
289 | + { |
|
290 | + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; |
|
291 | + } |
|
292 | + |
|
293 | + if ($user->rights->asset->delete) |
|
294 | + { |
|
295 | + print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a>'."\n"; |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; |
|
300 | + } |
|
301 | + } |
|
302 | + print '</div>'."\n"; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + // Select mail models is same action as presend |
|
307 | + if (GETPOST('modelselected')) { |
|
308 | + $action = 'presend'; |
|
309 | + } |
|
310 | + |
|
311 | + if ($action != 'presend') |
|
312 | + { |
|
313 | + print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
314 | + print '<a name="builddoc"></a>'; // ancre |
|
315 | + |
|
316 | + // Documents |
|
317 | + /*$objref = dol_sanitizeFileName($object->ref); |
|
318 | 318 | $relativepath = $comref . '/' . $comref . '.pdf'; |
319 | 319 | $filedir = $conf->asset->dir_output . '/' . $objref; |
320 | 320 | $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; |
@@ -323,29 +323,29 @@ discard block |
||
323 | 323 | print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); |
324 | 324 | */ |
325 | 325 | |
326 | - // Show links to link elements |
|
327 | - $linktoelem = $form->showLinkToObjectBlock($object, null, array('asset')); |
|
328 | - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
326 | + // Show links to link elements |
|
327 | + $linktoelem = $form->showLinkToObjectBlock($object, null, array('asset')); |
|
328 | + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
329 | 329 | |
330 | 330 | |
331 | - print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
331 | + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
332 | 332 | |
333 | - $MAXEVENT = 10; |
|
333 | + $MAXEVENT = 10; |
|
334 | 334 | |
335 | - $morehtmlright = '<a href="'.dol_buildpath('/asset/asset_info.php', 1).'?id='.$object->id.'">'; |
|
336 | - $morehtmlright.= $langs->trans("SeeAll"); |
|
337 | - $morehtmlright.= '</a>'; |
|
335 | + $morehtmlright = '<a href="'.dol_buildpath('/asset/asset_info.php', 1).'?id='.$object->id.'">'; |
|
336 | + $morehtmlright.= $langs->trans("SeeAll"); |
|
337 | + $morehtmlright.= '</a>'; |
|
338 | 338 | |
339 | - // List of actions on element |
|
340 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
341 | - $formactions = new FormActions($db); |
|
342 | - $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); |
|
339 | + // List of actions on element |
|
340 | + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
341 | + $formactions = new FormActions($db); |
|
342 | + $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); |
|
343 | 343 | |
344 | - print '</div></div></div>'; |
|
345 | - } |
|
344 | + print '</div></div></div>'; |
|
345 | + } |
|
346 | 346 | |
347 | - //Select mail models is same action as presend |
|
348 | - /* |
|
347 | + //Select mail models is same action as presend |
|
348 | + /* |
|
349 | 349 | if (GETPOST('modelselected')) $action = 'presend'; |
350 | 350 | |
351 | 351 | // Presend form |
@@ -52,10 +52,14 @@ discard block |
||
52 | 52 | $search=array(); |
53 | 53 | foreach($object->fields as $key => $val) |
54 | 54 | { |
55 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
56 | -} |
|
55 | + if (GETPOST('search_'.$key,'alpha')) { |
|
56 | + $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
57 | + } |
|
58 | + } |
|
57 | 59 | |
58 | -if (empty($action) && empty($id) && empty($ref)) $action='view'; |
|
60 | +if (empty($action) && empty($id) && empty($ref)) { |
|
61 | + $action='view'; |
|
62 | +} |
|
59 | 63 | |
60 | 64 | // Security check - Protection if external user |
61 | 65 | //if ($user->societe_id > 0) access_forbidden(); |
@@ -78,7 +82,9 @@ discard block |
||
78 | 82 | |
79 | 83 | $parameters=array(); |
80 | 84 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
81 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
85 | +if ($reshook < 0) { |
|
86 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
87 | +} |
|
82 | 88 | |
83 | 89 | if (empty($reshook)) |
84 | 90 | { |
@@ -224,8 +230,11 @@ discard block |
||
224 | 230 | // Call Hook formConfirm |
225 | 231 | $parameters = array('lineid' => $lineid); |
226 | 232 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
227 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
228 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
233 | + if (empty($reshook)) { |
|
234 | + $formconfirm.=$hookmanager->resPrint; |
|
235 | + } elseif ($reshook > 0) { |
|
236 | + $formconfirm=$hookmanager->resPrint; |
|
237 | + } |
|
229 | 238 | |
230 | 239 | // Print form confirm |
231 | 240 | print $formconfirm; |
@@ -274,7 +283,9 @@ discard block |
||
274 | 283 | print '<div class="tabsAction">'."\n"; |
275 | 284 | $parameters=array(); |
276 | 285 | $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
277 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
286 | + if ($reshook < 0) { |
|
287 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
288 | + } |
|
278 | 289 | |
279 | 290 | if (empty($reshook)) |
280 | 291 | { |
@@ -284,8 +295,7 @@ discard block |
||
284 | 295 | if ($user->rights->asset->write) |
285 | 296 | { |
286 | 297 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; |
287 | - } |
|
288 | - else |
|
298 | + } else |
|
289 | 299 | { |
290 | 300 | print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; |
291 | 301 | } |
@@ -293,8 +303,7 @@ discard block |
||
293 | 303 | if ($user->rights->asset->delete) |
294 | 304 | { |
295 | 305 | print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a>'."\n"; |
296 | - } |
|
297 | - else |
|
306 | + } else |
|
298 | 307 | { |
299 | 308 | print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; |
300 | 309 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | $backtopage = GETPOST('backtopage', 'alpha'); |
44 | 44 | |
45 | 45 | // Initialize technical objects |
46 | -$object=new Asset($db); |
|
46 | +$object = new Asset($db); |
|
47 | 47 | $extrafields = new ExtraFields($db); |
48 | -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; |
|
49 | -$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array |
|
48 | +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; |
|
49 | +$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array |
|
50 | 50 | // Fetch optionals attributes and labels |
51 | 51 | $extralabels = $extrafields->fetch_name_optionals_label('asset'); |
52 | -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); |
|
52 | +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
|
53 | 53 | |
54 | 54 | // Initialize array of search criterias |
55 | -$search_all=trim(GETPOST("search_all",'alpha')); |
|
56 | -$search=array(); |
|
57 | -foreach($object->fields as $key => $val) |
|
55 | +$search_all = trim(GETPOST("search_all", 'alpha')); |
|
56 | +$search = array(); |
|
57 | +foreach ($object->fields as $key => $val) |
|
58 | 58 | { |
59 | - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); |
|
59 | + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
60 | 60 | } |
61 | 61 | |
62 | -if (empty($action) && empty($id) && empty($ref)) $action='view'; |
|
62 | +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; |
|
63 | 63 | |
64 | 64 | // Security check - Protection if external user |
65 | 65 | //if ($user->societe_id > 0) access_forbidden(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
71 | 71 | |
72 | 72 | // Load object |
73 | -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
73 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | * Put here all code to do according to value of "action" parameter |
81 | 81 | */ |
82 | 82 | |
83 | -$parameters=array(); |
|
84 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
83 | +$parameters = array(); |
|
84 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
85 | 85 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
86 | 86 | |
87 | 87 | if (empty($reshook)) |
88 | 88 | { |
89 | - $error=0; |
|
89 | + $error = 0; |
|
90 | 90 | |
91 | 91 | $permissiontoadd = $user->rights->asset->create; |
92 | 92 | $permissiontodelete = $user->rights->asset->delete; |
93 | - $backurlforlist = dol_buildpath('/asset/list.php',1); |
|
93 | + $backurlforlist = dol_buildpath('/asset/list.php', 1); |
|
94 | 94 | |
95 | 95 | // Actions cancel, add, update or delete |
96 | 96 | include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
100 | 100 | |
101 | 101 | // Actions to send emails |
102 | - $trigger_name='ASSET_SENTBYMAIL'; |
|
103 | - $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO'; |
|
104 | - $trackid='asset'.$object->id; |
|
102 | + $trigger_name = 'ASSET_SENTBYMAIL'; |
|
103 | + $autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO'; |
|
104 | + $trackid = 'asset'.$object->id; |
|
105 | 105 | include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; |
106 | 106 | } |
107 | 107 | |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | * Put here all code to build page |
115 | 115 | */ |
116 | 116 | |
117 | -$form=new Form($db); |
|
118 | -$formfile=new FormFile($db); |
|
117 | +$form = new Form($db); |
|
118 | +$formfile = new FormFile($db); |
|
119 | 119 | |
120 | -$title=$langs->trans("Assets").' - '.$langs->trans("Card"); |
|
121 | -$help_url=''; |
|
122 | -llxHeader('',$title,$help_url); |
|
120 | +$title = $langs->trans("Assets").' - '.$langs->trans("Card"); |
|
121 | +$help_url = ''; |
|
122 | +llxHeader('', $title, $help_url); |
|
123 | 123 | |
124 | 124 | // Example : Adding jquery code |
125 | 125 | print '<script type="text/javascript" language="javascript"> |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | print '<table class="border centpercent">'."\n"; |
153 | 153 | |
154 | 154 | // Common attributes |
155 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; |
|
155 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; |
|
156 | 156 | |
157 | 157 | // Other attributes |
158 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; |
|
158 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; |
|
159 | 159 | |
160 | 160 | print '</table>'."\n"; |
161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | print '<div class="center">'; |
165 | 165 | print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; |
166 | 166 | print ' '; |
167 | - print '<input type="'.($backtopage?"submit":"button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage?'':' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage |
|
167 | + print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage |
|
168 | 168 | print '</div>'; |
169 | 169 | |
170 | 170 | print '</form>'; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | print '<table class="border centpercent">'."\n"; |
187 | 187 | |
188 | 188 | // Common attributes |
189 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; |
|
189 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; |
|
190 | 190 | |
191 | 191 | // Other attributes |
192 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; |
|
192 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; |
|
193 | 193 | |
194 | 194 | print '</table>'; |
195 | 195 | |
@@ -215,21 +215,21 @@ discard block |
||
215 | 215 | // Confirmation to delete |
216 | 216 | if ($action == 'delete') |
217 | 217 | { |
218 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); |
|
218 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAssets'), $langs->trans('ConfirmDeleteAssets'), 'confirm_delete', '', 0, 1); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // Confirmation of action xxxx |
222 | 222 | if ($action == 'xxx') |
223 | 223 | { |
224 | - $formquestion=array(); |
|
225 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
224 | + $formquestion = array(); |
|
225 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Call Hook formConfirm |
229 | 229 | $parameters = array('lineid' => $lineid); |
230 | 230 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
231 | - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; |
|
232 | - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; |
|
231 | + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; |
|
232 | + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; |
|
233 | 233 | |
234 | 234 | // Print form confirm |
235 | 235 | print $formconfirm; |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | |
238 | 238 | // Object card |
239 | 239 | // ------------------------------------------------------------ |
240 | - $linkback = '<a href="' .dol_buildpath('/asset/list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
240 | + $linkback = '<a href="'.dol_buildpath('/asset/list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
241 | 241 | |
242 | - $morehtmlref='<div class="refidno">'; |
|
242 | + $morehtmlref = '<div class="refidno">'; |
|
243 | 243 | /* |
244 | 244 | // Ref bis |
245 | 245 | $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | // Thirdparty |
248 | 248 | $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); |
249 | 249 | */ |
250 | - $morehtmlref.='</div>'; |
|
250 | + $morehtmlref .= '</div>'; |
|
251 | 251 | |
252 | 252 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
253 | 253 | |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | |
259 | 259 | // Common attributes |
260 | 260 | //$keyforbreak='fieldkeytoswithonsecondcolumn'; |
261 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; |
|
261 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; |
|
262 | 262 | |
263 | 263 | // Other attributes |
264 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
264 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
265 | 265 | |
266 | 266 | print '</table>'; |
267 | 267 | print '</div>'; |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | // Buttons for actions |
277 | 277 | if ($action != 'presend' && $action != 'editline') { |
278 | 278 | print '<div class="tabsAction">'."\n"; |
279 | - $parameters=array(); |
|
280 | - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
279 | + $parameters = array(); |
|
280 | + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
281 | 281 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
282 | 282 | |
283 | 283 | if (empty($reshook)) |
284 | 284 | { |
285 | 285 | // Send |
286 | - print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n"; |
|
286 | + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n"; |
|
287 | 287 | |
288 | 288 | if ($user->rights->asset->write) |
289 | 289 | { |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | $MAXEVENT = 10; |
338 | 338 | |
339 | 339 | $morehtmlright = '<a href="'.dol_buildpath('/asset/asset_info.php', 1).'?id='.$object->id.'">'; |
340 | - $morehtmlright.= $langs->trans("SeeAll"); |
|
341 | - $morehtmlright.= '</a>'; |
|
340 | + $morehtmlright .= $langs->trans("SeeAll"); |
|
341 | + $morehtmlright .= '</a>'; |
|
342 | 342 | |
343 | 343 | // List of actions on element |
344 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
344 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; |
|
345 | 345 | $formactions = new FormActions($db); |
346 | 346 | $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); |
347 | 347 |
@@ -34,7 +34,9 @@ |
||
34 | 34 | $action=GETPOST('action','alpha'); |
35 | 35 | |
36 | 36 | // Security check |
37 | -if ($user->societe_id) $socid=$user->societe_id; |
|
37 | +if ($user->societe_id) { |
|
38 | + $socid=$user->societe_id; |
|
39 | +} |
|
38 | 40 | $result = restrictedArea($user, 'asset', $id, ''); |
39 | 41 | |
40 | 42 | $object = new Asset($db); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
29 | 29 | |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | // Load translation files required by the page |
35 | 35 | $langs->loadLangs(array("asset")); |
36 | 36 | |
37 | -$id = GETPOST('id','int'); |
|
38 | -$ref=GETPOST('ref','alpha'); |
|
39 | -$action=GETPOST('action','alpha'); |
|
37 | +$id = GETPOST('id', 'int'); |
|
38 | +$ref = GETPOST('ref', 'alpha'); |
|
39 | +$action = GETPOST('action', 'alpha'); |
|
40 | 40 | |
41 | 41 | // Security check |
42 | -if ($user->societe_id) $socid=$user->societe_id; |
|
42 | +if ($user->societe_id) $socid = $user->societe_id; |
|
43 | 43 | $result = restrictedArea($user, 'asset', $id, ''); |
44 | 44 | |
45 | 45 | $object = new Asset($db); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /* |
53 | 53 | * View |
54 | 54 | */ |
55 | -$title = $langs->trans('Asset') . " - " . $langs->trans('Info'); |
|
55 | +$title = $langs->trans('Asset')." - ".$langs->trans('Info'); |
|
56 | 56 | $helpurl = ""; |
57 | 57 | llxHeader('', $title, $helpurl); |
58 | 58 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | dol_fiche_head($head, 'info', $langs->trans("Asset"), -1, 'generic'); |
66 | 66 | |
67 | 67 | //$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; |
68 | -$linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
68 | +$linkback = '<a href="'.BASE_URI.'?controller=don&method=list'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
69 | 69 | |
70 | -$morehtmlref='<div class="refidno">'; |
|
71 | -$morehtmlref.='</div>'; |
|
70 | +$morehtmlref = '<div class="refidno">'; |
|
71 | +$morehtmlref .= '</div>'; |
|
72 | 72 | |
73 | 73 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
74 | 74 |