Completed
Push — master ( 27415e...e613a5 )
by
unknown
13s
created

ActionsSubtotal::pdf_writelinedesc()   F

Complexity

Conditions 20
Paths 1220

Size

Total Lines 115
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 19
Bugs 1 Features 0
Metric Value
cc 20
eloc 55
c 19
b 1
f 0
nc 1220
nop 3
dl 0
loc 115
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
class ActionsSubtotal
3
{
4
	
5
	function __construct($db)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
6
	{
7
		global $langs;
8
		
9
		$this->db = $db;
0 ignored issues
show
Bug Best Practice introduced by
The property db does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
10
		$langs->load('subtotal@subtotal');
11
		
12
		$this->allow_move_block_lines = true;
0 ignored issues
show
Bug Best Practice introduced by
The property allow_move_block_lines does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13
	}
14
	
15
	function printFieldListSelect($parameters, &$object, &$action, $hookmanager) {
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

15
	function printFieldListSelect($parameters, /** @scrutinizer ignore-unused */ &$object, &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

15
	function printFieldListSelect($parameters, &$object, /** @scrutinizer ignore-unused */ &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

15
	function printFieldListSelect($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
		
17
		global $type_element, $where;
18
		
19
		$contexts = explode(':',$parameters['context']);
20
		
21
		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22
			$mod_num = TSubtotal::$module_number;
23
			
24
			// Not a title (can't use TSubtotal class methods in sql)
25
			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26
			// Not a subtotal (can't use TSubtotal class methods in sql)
27
			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28
			// Not a free line text (can't use TSubtotal class methods in sql)
29
			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30
			
31
		}
32
		
33
	}
34
	
35
	
36
	function createDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
	function createDictionaryFieldlist($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
	function createDictionaryFieldlist($parameters, /** @scrutinizer ignore-unused */ &$object, &$action, $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

36
	function createDictionaryFieldlist($parameters, &$object, /** @scrutinizer ignore-unused */ &$action, $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
	{
38
		global $conf;
39
40
		if ($parameters['tabname'] == MAIN_DB_PREFIX.'c_subtotal_free_text')
0 ignored issues
show
Bug introduced by
The constant MAIN_DB_PREFIX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
		{
42
			// Merci Dolibarr de remplacer les textarea par un input text
43
			if ((float) DOL_VERSION >= 6.0)
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
			{
45
				$value = '';
46
				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = './** @scrutinizer ignore-call */ GETPOST('rowid');
Loading history...
47
				$resql = $this->db->query($sql);
48
				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
49
			}
50
			
51
			?>
52
			<script type="text/javascript">
53
				$(function() {
54
					
55
					<?php if ((float) DOL_VERSION >= 6.0) { ?>
56
							if ($('input[name=content]').length > 0)
57
							{
58
								$('input[name=content]').each(function(i,item) {
59
									var value = '';
60
									// Le dernier item correspond à l'édition
61
									if (i == $('input[name=content]').length) value = <?php echo json_encode($value); ?>;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $value does not seem to be defined for all execution paths leading up to this point.
Loading history...
62
									$(item).replaceWith($('<textarea name="content">'+value+'</textarea>'));
63
								});
64
								
65
								<?php if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
66
								$('textarea[name=content]').each(function(i, item) {
67
									CKEDITOR.replace(item, {
68
										toolbar: 'dolibarr_notes'
69
										,customConfig : ckeditorConfig
70
									});
71
								});
72
								<?php } ?>
73
							}
74
					<?php } else { ?>
75
						// <= 5.0
76
						// Le CKEditor est forcé sur la page dictionnaire, pas possible de mettre une valeur custom
77
						// petit js qui supprimer le wysiwyg et affiche le textarea car avant la version 6.0 le wysiwyg sur une page de dictionnaire est inexploitable
78
						<?php if (!empty($conf->fckeditor->enabled)) { ?>
79
							CKEDITOR.on('instanceReady', function(ev) {
80
								var editor = ev.editor;
81
82
								if (editor.name == 'content') // Mon champ en bdd s'appel "content", pas le choix si je veux avoir un textarea sur une page de dictionnaire
83
								{
84
									editor.element.show();
85
									editor.destroy();
86
								}
87
							});
88
						<?php } ?>
89
					<?php } ?>
90
				});
91
			</script>
92
			<?php
93
		}
94
	}
95
	
96
	/** Overloading the doActions function : replacing the parent's function with the one below
97
	 * @param      $parameters  array           meta datas of the hook (context, etc...)
98
	 * @param      $object      CommonObject    the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
99
	 * @param      $action      string          current action (if set). Generally create or edit or null
100
	 * @param      $hookmanager HookManager     current hook manager
101
	 * @return     void
102
	 */
103
    
104
    var $module_number = 104777;
105
    
106
    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
0 ignored issues
show
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

106
    function formObjectOptions($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager) 

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
107
    {
108
      	global $langs,$db,$user, $conf;
109
		
110
		$langs->load('subtotal@subtotal');
111
		
112
		$contexts = explode(':',$parameters['context']);
113
		
114
		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts) || in_array('expeditioncard',$contexts)) {
115
			
116
			$createRight = $user->rights->{$object->element}->creer;
117
			if($object->element == 'facturerec' )
118
			{
119
				$object->statut = 0; // hack for facture rec
120
				$createRight = $user->rights->facture->creer;
121
			} elseif($object->element == 'order_supplier' )
122
			{
123
			    $createRight = $user->rights->fournisseur->commande->creer;
124
			} elseif($object->element == 'invoice_supplier' )
125
			{
126
			    $createRight = $user->rights->fournisseur->facture->creer;
127
			}
128
			elseif($object->element == 'shipping')
129
			{
130
				$createRight = true; // No rights management for shipments
131
			}
132
			
133
			if ($object->statut == 0  && $createRight) {
134
			
135
136
				if($object->element=='facture')$idvar = 'facid';
137
				else $idvar='id';
138
				
139
				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
140
				{
141
					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
					$level = /** @scrutinizer ignore-call */ GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
Loading history...
142
					
143
					if($action=='add_title_line') {
144
						$title = GETPOST('title');
145
						if(empty($title)) $title = $langs->trans('title');
146
						$qty = $level<1 ? 1 : $level ;
147
					}
148
					else if($action=='add_free_text') {
149
						$title = GETPOST('title');
150
151
						if (empty($title)) {
152
							$free_text = GETPOST('free_text', 'int');
153
							if (!empty($free_text)) {
154
								$TFreeText = getTFreeText();
155
								if (!empty($TFreeText[$free_text])) {
156
									$title = $TFreeText[$free_text]->content;
157
								}
158
							}
159
						}
160
						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
161
						$qty = 50;
162
					}
163
					else if($action=='add_subtitle_line') {
164
						$title = GETPOST('title');
165
						if(empty($title)) $title = $langs->trans('subtitle');
166
						$qty = 2;
167
					}
168
					else if($action=='add_subtotal_line') {
169
						$title = $langs->trans('SubSubTotal');
170
						$qty = 98;
171
					}
172
					else {
173
						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174
						$qty = $level ? 100-$level : 99;
175
					}
176
					dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

176
					/** @scrutinizer ignore-call */ 
177
     dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
177
					
178
					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
179
					
180
	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181
				}
182
				else if($action==='ask_deleteallline') {
183
						$form=new Form($db);
0 ignored issues
show
Bug introduced by
The type Form was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
184
185
						$lineid = GETPOST('lineid','integer');
186
						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
187
					
188
						$nbLines = count($TIdForGroup);
189
					
190
						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
191
						print $formconfirm;
192
				}
193
194
				if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE))
195
				{
196
					$this->showSelectTitleToAdd($object);
197
				}
198
199
				
200
				if($object->element != 'shipping' && $action!='editline') {
201
					// New format is for 3.8
202
					$this->printNewFormat($object, $conf, $langs, $idvar);
203
				}
204
			}
205
		}
206
		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
207
		{
208
			?>
209
			<script type="text/javascript">
210
				$(function() {
211
					var tr = $("<tr><td><?php echo $langs->trans('subtotal_add_title_bloc_from_orderstoinvoice'); ?></td><td><input type='checkbox' value='1' name='subtotal_add_title_bloc_from_orderstoinvoice' checked='checked' /></td></tr>")
212
					$("textarea[name=note]").closest('tr').after(tr);
213
				});
214
			</script>
215
			<?php
216
			
217
		}
218
219
		return 0;
220
	}
221
     
222
	function printNewFormat(&$object, &$conf, &$langs, $idvar)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
223
	{
224
		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
225
		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $line seems to be never defined.
Loading history...
226
		?>
227
		 	<script type="text/javascript">
228
				$(document).ready(function() {
229
					$('div.fiche div.tabsAction').append('<br />');
230
					
231
					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
232
					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
233
					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
234
235
236
					function updateAllMessageForms(){
237
				         for (instance in CKEDITOR.instances) {
238
				             CKEDITOR.instances[instance].updateElement();
239
				         }
240
				    }
241
					
242
					function promptSubTotal(action, titleDialog, label, url_to, url_ajax, params, use_textarea, show_free_text, show_under_title) {
243
					     $( "#dialog-prompt-subtotal" ).remove();
244
						 
245
						 var dialog_html = '<div id="dialog-prompt-subtotal" '+(action == 'addSubtotal' ? 'class="center"' : '')+' >';
246
						 
247
						 if (typeof show_under_title != 'undefined' && show_under_title)
248
						 {
249
							 var selectUnderTitle = <?php echo json_encode(getHtmlSelectTitle($object, true)); ?>;
250
							 dialog_html += selectUnderTitle + '<br /><br />';
251
						 }
252
						
253
						if (action == 'addTitle' || action == 'addFreeTxt')
254
						{
255
							if (typeof show_free_text != 'undefined' && show_free_text)
256
							{
257
							   var selectFreeText = <?php echo json_encode(getHtmlSelectFreeText()); ?>;
258
							   dialog_html += selectFreeText + ' <?php echo $langs->transnoentities('subtotalFreeTextOrDesc'); ?><br />';
259
							}
260
						 
261
							if (typeof use_textarea != 'undefined' && use_textarea) dialog_html += '<textarea id="sub-total-title" rows="<?php echo ROWS_8; ?>" cols="80" placeholder="'+label+'"></textarea>';
0 ignored issues
show
Bug introduced by
The constant ROWS_8 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
262
							else dialog_html += '<input id="sub-total-title" size="30" value="" placeholder="'+label+'" />';
263
						}
264
						 
265
						if (action == 'addTitle' || action == 'addSubtotal')
266
						{
267
							if (action == 'addSubtotal') dialog_html += '<input id="sub-total-title" size="30" value="" placeholder="'+label+'" />';
268
							
269
							dialog_html += "&nbsp;<select name='subtotal_line_level'>";
270
							for (var i=1;i<10;i++)
271
							{
272
								dialog_html += "<option value="+i+"><?php echo $langs->trans('Level'); ?> "+i+"</option>";
273
							}
274
							dialog_html += "</select>";
275
						}
276
						 
277
						 dialog_html += '</div>';
278
					    
279
						$('body').append(dialog_html);
280
281
						<?php 
282
						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
283
						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
285
						?>
286
						if (action == 'addTitle' || action == 'addFreeTxt')
287
						{
288
							if (typeof use_textarea != 'undefined' && use_textarea && typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" )
289
							{
290
								 CKEDITOR.replace( 'sub-total-title', {toolbar: 'dolibarr_details', toolbarStartupExpanded: false} );
291
							}
292
						}
293
						<?php } ?>
294
						
295
					     $( "#dialog-prompt-subtotal" ).dialog({
296
	                        resizable: false,
297
							height: 'auto',
298
							width: 'auto',
299
	                        modal: true,
300
	                        title: titleDialog,
301
	                        buttons: {
302
	                            "Ok": function() {
303
	                            	if (typeof use_textarea != 'undefined' && use_textarea && typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" ){ updateAllMessageForms(); }
304
									params.title = params.title = (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && "sub-total-title" in CKEDITOR.instances ? CKEDITOR.instances["sub-total-title"].getData() : $(this).find('#sub-total-title').val());
305
									params.under_title = $(this).find('select[name=under_title]').val();
306
									params.free_text = $(this).find('select[name=free_text]').val();
307
									params.level = $(this).find('select[name=subtotal_line_level]').val();
308
									
309
									$.ajax({
310
										url: url_ajax
311
										,type: 'POST'
312
										,data: params
313
									}).done(function() {
314
										document.location.href=url_to;
315
									});
316
									
317
                                    $( this ).dialog( "close" );
318
	                            },
319
	                            "<?php echo $langs->trans('Cancel') ?>": function() {
320
	                                $( this ).dialog( "close" );
321
	                            }
322
	                        }
323
	                     });
324
					}
325
					
326
					$('a[rel=add_title_line]').click(function() 
327
					{
328
						promptSubTotal('addTitle'
329
							 , "<?php echo $langs->trans('YourTitleLabel') ?>"
330
							 , "<?php echo $langs->trans('title'); ?>"
331
							 , '?<?php echo $idvar ?>=<?php echo $object->id; ?>'
332
							 , '<?php echo $_SERVER['PHP_SELF']; ?>'
333
							 , {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_title_line'}
334
						);
335
					});
336
					
337
					$('a[rel=add_total_line]').click(function()
338
					{
339
						promptSubTotal('addSubtotal'
340
							, '<?php echo $langs->trans('YourSubtotalLabel') ?>'
341
							, '<?php echo $langs->trans('subtotal'); ?>'
342
							, '?<?php echo $idvar ?>=<?php echo $object->id; ?>'
343
							, '<?php echo $_SERVER['PHP_SELF']; ?>'
344
							, {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_total_line'}
345
							/*,false,false, <?php echo !empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) ? 'true' : 'false'; ?>*/
346
						);
347
					});
348
					
349
					$('a[rel=add_free_text]').click(function() 
350
					{
351
						promptSubTotal('addFreeTxt'
352
							, "<?php echo $langs->transnoentitiesnoconv('YourTextLabel') ?>"
353
							, "<?php echo $langs->trans('subtotalAddLineDescription'); ?>"
354
							, '?<?php echo $idvar ?>=<?php echo $object->id; ?>'
355
							, '<?php echo $_SERVER['PHP_SELF']; ?>'
356
							, {<?php echo $idvar; ?>: <?php echo (int) $object->id; ?>, action:'add_free_text'}
357
							, true
358
							, true
359
							, <?php echo !empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) ? 'true' : 'false'; ?>
360
						);
361
					});
362
				});
363
		 	</script>
364
		 <?php
365
	}	 
366
	 
367
	function showSelectTitleToAdd(&$object)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
368
	{
369
		global $langs;
370
		
371
		dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

371
		/** @scrutinizer ignore-call */ 
372
  dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
372
		dol_include_once('/subtotal/lib/subtotal.lib.php');
373
		$TTitle = TSubtotal::getAllTitleFromDocument($object);
0 ignored issues
show
Unused Code introduced by
The assignment to $TTitle is dead and can be removed.
Loading history...
374
		
375
		?>
376
		<script type="text/javascript">
377
			$(function() {
378
				var add_button = $("#addline");
379
				
380
				if (add_button.length > 0)
381
				{
382
					add_button.closest('tr').prev('tr.liste_titre').children('td:last').addClass('center').text("<?php echo $langs->trans('subtotal_title_to_add_under_title'); ?>");
383
					var select_title = $(<?php echo json_encode(getHtmlSelectTitle($object)); ?>);
384
					
385
					add_button.before(select_title);
386
				}
387
			});
388
		</script>
389
		<?php
390
	}
391
	
392
	
393
	function formBuilddocOptions($parameters, &$object) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
394
	/* Réponse besoin client */		
395
			
396
		global $conf, $langs, $bc;
397
			
398
		$action = GETPOST('action');	
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

398
		$action = /** @scrutinizer ignore-call */ GETPOST('action');	
Loading history...
399
		$TContext = explode(':',$parameters['context']);
400
		if (
401
				in_array('invoicecard',$TContext)
402
		        || in_array('invoicesuppliercard',$TContext)
403
				|| in_array('propalcard',$TContext)
404
				|| in_array('ordercard',$TContext)
405
		        || in_array('ordersuppliercard',$TContext)
406
				|| in_array('invoicereccard',$TContext)
407
			)
408
	        {	
409
	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412
				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413
				
414
				$var=false;
415
		     	$out.= '<tr '.$bc[$var].'>
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $out seems to be never defined.
Loading history...
416
		     			<td colspan="4" align="right">
417
		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418
		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
419
		     			</td>
420
		     			</tr>';
421
				
422
		     	$var=!$var;
0 ignored issues
show
introduced by
The condition $var is always false.
Loading history...
423
		     	$out.= '<tr '.$bc[$var].'>
424
		     			<td colspan="4" align="right">
425
		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426
		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
427
		     			</td>
428
		     			</tr>';
429
		     	
430
		     	$var=!$var;
0 ignored issues
show
introduced by
The condition $var is always true.
Loading history...
431
		     	$out.= '<tr '.$bc[$var].'>
432
		     			<td colspan="4" align="right">
433
		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434
		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
435
		     			</td>
436
		     			</tr>';
437
		     	
438
		     	
439
				 
440
				if ( 
441
					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
447
				)
448
				{
449
					$var=!$var;
0 ignored issues
show
introduced by
The condition $var is always false.
Loading history...
450
					$out.= '
451
						<tr '.$bc[$var].'>
452
							<td colspan="4" align="right">
453
								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
454
								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
455
							</td>
456
						</tr>';
457
				}
458
				
459
				
460
				$this->resprints = $out;	
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
461
			}
462
			
463
		
464
        return 1;
465
	} 
466
	 
467
    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

467
    function formEditProductOptions($parameters, /** @scrutinizer ignore-unused */ &$object, &$action, $hookmanager) 

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

467
    function formEditProductOptions($parameters, &$object, /** @scrutinizer ignore-unused */ &$action, $hookmanager) 

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

467
    function formEditProductOptions($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager) 

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
468
    {
469
		
470
    	if (in_array('invoicecard',explode(':',$parameters['context'])))
471
        {
472
        	
473
        }
474
		
475
        return 0;
476
    }
477
	
478
	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

478
	function ODTSubstitutionLine(&$parameters, /** @scrutinizer ignore-unused */ &$object, $action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

478
	function ODTSubstitutionLine(&$parameters, &$object, $action, /** @scrutinizer ignore-unused */ $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
479
		global $conf;
480
		
481
		if($action === 'builddoc') {
482
			
483
			$line = &$parameters['line'];
484
			$object = &$parameters['object'];
485
			$substitutionarray = &$parameters['substitutionarray'];
486
			
487
			if($line->product_type == 9 && $line->special_code == $this->module_number) {
488
				$substitutionarray['line_modsubtotal'] = 1;	
489
				
490
				$substitutionarray['line_price_ht']
491
					 = $substitutionarray['line_price_vat'] 
492
					 = $substitutionarray['line_price_ttc']
493
					 = $substitutionarray['line_vatrate']
494
					 = $substitutionarray['line_qty']
495
					 = $substitutionarray['line_up'] 
496
					 = '';
497
				
498
				if($line->qty>90) {
499
					$substitutionarray['line_modsubtotal_total'] = true;
500
					
501
					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
502
					
503
					$substitutionarray['line_price_ht'] = $total;
504
					$substitutionarray['line_price_vat'] = $total_tva;
505
					$substitutionarray['line_price_ttc'] = $total_ttc;
506
				} else {
507
					$substitutionarray['line_modsubtotal_title'] = true;
508
				}
509
				
510
				
511
			}	
512
			else{
513
				$substitutionarray['line_not_modsubtotal'] = true;
514
				$substitutionarray['line_modsubtotal'] = 0;
515
			}
516
			
517
		}
518
		
519
	}
520
	
521
	function createFrom($parameters, &$object, $action, $hookmanager) {
0 ignored issues
show
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

521
	function createFrom($parameters, &$object, $action, /** @scrutinizer ignore-unused */ $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

521
	function createFrom($parameters, &$object, /** @scrutinizer ignore-unused */ $action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
522
	
523
		if (
524
				in_array('invoicecard',explode(':',$parameters['context']))
525
		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
526
				|| in_array('propalcard',explode(':',$parameters['context']))
527
		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
528
				|| in_array('ordercard',explode(':',$parameters['context']))
529
		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
530
				|| in_array('invoicereccard',explode(':',$parameters['context']))
531
		) {
532
			
533
			global $db;
534
			
535
			$objFrom = $parameters['objFrom'];
536
			
537
			foreach($objFrom->lines as $k=> &$lineOld) {
538
				
539
					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
540
							
541
							$line = & $object->lines[$k];
542
				
543
							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
544
				
545
							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
0 ignored issues
show
Bug introduced by
The constant MAIN_DB_PREFIX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
546
							SET info_bits=".(int)$lineOld->info_bits."
547
							WHERE rowid = ".$idLine."
548
							");
549
						
550
					}
551
				
552
				
553
			}
554
			
555
			
556
		}
557
		
558
	}
559
	
560
	function doActions($parameters, &$object, $action, $hookmanager)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

560
	function doActions($parameters, &$object, $action, /** @scrutinizer ignore-unused */ $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
561
	{
562
		global $db, $conf, $langs,$user;
563
		
564
		dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

564
		/** @scrutinizer ignore-call */ 
565
  dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
565
		dol_include_once('/subtotal/lib/subtotal.lib.php');
566
		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
0 ignored issues
show
Bug introduced by
The constant DOL_DOCUMENT_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
567
		
568
		$showBlockExtrafields = GETPOST('showBlockExtrafields');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

568
		$showBlockExtrafields = /** @scrutinizer ignore-call */ GETPOST('showBlockExtrafields');
Loading history...
569
		
570
		if($object->element=='facture') $idvar = 'facid';
571
		else $idvar = 'id';
572
			
573
		if ($action == 'updateligne' || $action == 'updateline')
574
		{
575
			$found = false;
576
			$lineid = GETPOST('lineid', 'int');
577
			foreach ($object->lines as &$line)
578
			{
579
				
580
				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
581
				{
582
					$found = true;
583
					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
584
						$extrafieldsline = new ExtraFields($db);
0 ignored issues
show
Bug introduced by
The type ExtraFields was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
585
						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
586
						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
587
					}
588
					_updateSubtotalLine($object, $line);
589
					_updateSubtotalBloc($object, $line);
590
					
591
					TSubtotal::generateDoc($object);
592
					break;
593
				}
594
			}
595
			
596
			if ($found)
597
			{
598
				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
599
				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
600
			}
601
		}
602
		else if($action === 'builddoc') {
603
			
604
			if (
605
				in_array('invoicecard',explode(':',$parameters['context']))
606
				|| in_array('propalcard',explode(':',$parameters['context']))
607
				|| in_array('ordercard',explode(':',$parameters['context']))
608
			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
609
			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
610
			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
611
			)
612
	        {								
613
				if(in_array('invoicecard',explode(':',$parameters['context']))) {
614
					$sessname = 'subtotal_hideInnerLines_facture';	
615
					$sessname2 = 'subtotal_hidedetails_facture';
616
					$sessname3 = 'subtotal_hideprices_facture';
617
				}
618
				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
619
				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
620
				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
621
				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
622
				}
623
				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
624
					$sessname = 'subtotal_hideInnerLines_propal';
625
					$sessname2 = 'subtotal_hidedetails_propal';	
626
					$sessname3 = 'subtotal_hideprices_propal';
627
				}
628
				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
629
				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
630
				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
631
				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
632
				}
633
				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
634
					$sessname = 'subtotal_hideInnerLines_commande';
635
					$sessname2 = 'subtotal_hidedetails_commande';	
636
					$sessname3 = 'subtotal_hideprices_commande';
637
				}
638
				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
639
				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
640
				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
641
				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
642
				}
643
				else {
644
					$sessname = 'subtotal_hideInnerLines_unknown';
645
					$sessname2 = 'subtotal_hidedetails_unknown';
646
					$sessname3 = 'subtotal_hideprices_unknown';
647
				}
648
					
649
				global $hideprices;
650
				
651
				$hideInnerLines = (int)GETPOST('hideInnerLines');
652
				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
653
				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
654
				
655
				$hidedetails= (int)GETPOST('hidedetails');
656
				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
657
				$_SESSION[$sessname2][$object->id] = $hidedetails;
658
				
659
				$hideprices= (int)GETPOST('hideprices');
660
				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
661
				$_SESSION[$sessname3][$object->id] = $hideprices;
662
				
663
				foreach($object->lines as &$line) {
664
					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
665
					    
666
                        if($line->qty>=90) {
667
                            $line->modsubtotal_total = 1;
668
                        }
669
                        else{
670
                            $line->modsubtotal_title = 1;
671
                        }
672
                        
673
						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
674
					}
675
	        	}
676
	        }
677
			
678
		}
679
		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
680
			
681
			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
682
			
683
			foreach($Tab as $idLine) {
684
				/**
685
				 * @var $object Facture
686
				 */
687
				if($object->element=='facture') $object->deleteline($idLine);
688
				/**
689
				 * @var $object Facture fournisseur
690
				 */
691
				else if($object->element=='invoice_supplier')
692
				{
693
				    $object->deleteline($idLine);
694
				}
695
				/**
696
				 * @var $object Propal
697
				 */
698
				else if($object->element=='propal') $object->deleteline($idLine);
699
				/**
700
				 * @var $object Propal Fournisseur
701
				 */
702
				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
703
				/**
704
				 * @var $object Commande
705
				 */
706
				else if($object->element=='commande') 
707
				{
708
					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
709
					else $object->deleteline($idLine);
710
				}
711
				/**
712
				 * @var $object Commande fournisseur
713
				 */
714
				else if($object->element=='order_supplier')
715
				{
716
				    $object->deleteline($idLine);
717
				}
718
				/**
719
				 * @var $object Facturerec
720
				 */
721
				else if($object->element=='facturerec') $object->deleteline($idLine);
722
				/**
723
				 * @var $object Expedition
724
				 */
725
				else if($object->element=='shipping') $object->deleteline($user, $idLine);
726
			}
727
			
728
			header('location:?id='.$object->id);
729
			exit;
730
			
731
		}
732
		else if ($action == 'duplicate')
733
		{
734
			$lineid = GETPOST('lineid', 'int');
735
			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
736
			
737
			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
0 ignored issues
show
Bug introduced by
The function setEventMessage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

737
			if ($nbDuplicate > 0) /** @scrutinizer ignore-call */ setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
Loading history...
738
			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $nbDuplicate of type integer|null to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
739
			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
740
			
741
			header('Location: ?id='.$object->id);
742
			exit;
743
		}
744
		
745
		return 0;
746
	}
747
	
748
	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

748
	function formAddObjectLine ($parameters, /** @scrutinizer ignore-unused */ &$object, &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

748
	function formAddObjectLine (/** @scrutinizer ignore-unused */ $parameters, &$object, &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

748
	function formAddObjectLine ($parameters, &$object, /** @scrutinizer ignore-unused */ &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

748
	function formAddObjectLine ($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
749
		return 0;
750
	}
751
	
752
	function changeRoundingMode($parameters, &$object, &$action, $hookmanager)
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

752
	function changeRoundingMode($parameters, &$object, /** @scrutinizer ignore-unused */ &$action, $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

752
	function changeRoundingMode($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
753
	{
754
		global $conf;
755
		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
756
		{
757
			if ($object->element == 'commande')
758
				$obj = new OrderLine($object->db);
0 ignored issues
show
Bug introduced by
The type OrderLine was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
759
			if ($object->element == 'propal')
760
				$obj = new PropaleLigne($object->db);
0 ignored issues
show
Bug introduced by
The type PropaleLigne was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
761
			if ($object->element == 'facture')
762
				$obj = new FactureLigne($object->db);
0 ignored issues
show
Bug introduced by
The type FactureLigne was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
763
			if (!empty($parameters['fk_element']))
764
			{
765
				
766
				if($obj->fetch($parameters['fk_element'])){
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $obj does not seem to be defined for all execution paths leading up to this point.
Loading history...
767
					$obj->id= $obj->rowid;
768
					if (empty($obj->array_options))
769
						$obj->fetch_optionals();
770
					if (!empty($obj->array_options['options_subtotal_nc']))
771
						return 1;
772
				}
773
			}
774
		}
775
776
		return 0;
777
	}
778
779
	function getArrayOfLineForAGroup(&$object, $lineid) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
780
		$rang = $line->rang;
0 ignored issues
show
Unused Code introduced by
The assignment to $rang is dead and can be removed.
Loading history...
Comprehensibility Best Practice introduced by
The variable $line does not exist. Did you maybe mean $lineid?
Loading history...
781
		$qty_line = $line->qty;
0 ignored issues
show
Unused Code introduced by
The assignment to $qty_line is dead and can be removed.
Loading history...
782
		
783
		$qty_line = 0;
784
		
785
		$found = false;
786
787
		$Tab= array();
788
		
789
		foreach($object->lines as $l) {
790
		
791
		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
792
			if($lid == $lineid) {
793
794
				$found = true;
795
				$qty_line = $l->qty;
796
			}
797
			
798
			if($found) {
799
				
800
			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
801
				
802
				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
803
					break; // end of story
804
				}
805
			}
806
			
807
			
808
		}
809
		
810
		
811
		return $Tab;
812
		
813
	}
814
815
	/**
816
	 *  TODO le calcul est faux dans certains cas,  exemple :
817
	 *	T1
818
	 *		|_ l1 => 50 €
819
	 *		|_ l2 => 40 €
820
	 *		|_ T2
821
	 *			|_l3 => 100 €
822
	 *		|_ ST2
823
	 *		|_ l4 => 23 €
824
	 *	|_ ST1
825
	 * 
826
	 * On obtiens ST2 = 100 ET ST1 = 123 €
827
	 * Alors qu'on devrais avoir ST2 = 100 ET ST1 = 213 €
828
	 * 
829
	 * @param	$use_level		isn't used anymore
0 ignored issues
show
Documentation Bug introduced by
The doc comment isn't at position 0 could not be parsed: Unknown type name 'isn't' at position 0 in isn't.
Loading history...
830
	 */
831
	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
0 ignored issues
show
Unused Code introduced by
The parameter $use_level is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

831
	function getTotalLineFromObject(&$object, &$line, /** @scrutinizer ignore-unused */ $use_level=false, $return_all=0) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
832
		global $conf;
833
		
834
		$rang = $line->rang;
835
		$qty_line = $line->qty;
836
		
837
		$total = 0;
838
		$total_tva = 0;
839
		$total_ttc = 0;
840
		$TTotal_tva = array();
841
		
842
		$sign=1;
843
		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
844
		
845
		if (GETPOST('action') == 'builddoc') $builddoc = true;
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

845
		if (/** @scrutinizer ignore-call */ GETPOST('action') == 'builddoc') $builddoc = true;
Loading history...
846
		else $builddoc = false;
847
		
848
		dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

848
		/** @scrutinizer ignore-call */ 
849
  dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
849
		foreach($object->lines as $l) {
850
			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
851
			if($l->rang>=$rang) {
852
				//echo 'return!<br>';
853
				if (!$return_all) return $total;
854
				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
855
			}
856
			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
857
		  	{
858
				$total = 0;
859
				$total_tva = 0;
860
				$total_ttc = 0;
861
				$TTotal_tva = array();
862
			}
863
			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
864
				
865
				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
866
				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
0 ignored issues
show
Bug introduced by
The type Facture was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
867
				{
868
					if ($l->situation_percent > 0)
869
					{
870
						$prev_progress = 0;
871
						$progress = 1;
872
						if (method_exists($l, 'get_prev_progress'))
873
						{
874
							$prev_progress = $l->get_prev_progress($object->id);
875
							$progress = ($l->situation_percent - $prev_progress) / 100;
876
						}
877
						
878
						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
879
						$total+= $result;
880
						// TODO check si les 3 lignes du dessous sont corrects
881
						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
882
						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
883
						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
884
					}
885
				}
886
				else
887
				{
888
					$total += $l->total_ht;
889
					$total_tva += $l->total_tva;
890
					$TTotal_tva[$l->tva_tx] += $l->total_tva;
891
					$total_ttc += $l->total_ttc;
892
				}
893
			}
894
			
895
		}
896
		if (!$return_all) return $total;
897
		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
898
	}
899
900
	/**
901
	 * @param $pdf          TCPDF               PDF object
0 ignored issues
show
Bug introduced by
The type TCPDF was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
902
	 * @param $object       CommonObject        dolibarr object
0 ignored issues
show
Bug introduced by
The type CommonObject was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
903
	 * @param $line         CommonObjectLine    dolibarr object line
0 ignored issues
show
Bug introduced by
The type CommonObjectLine was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
904
	 * @param $label        string
905
	 * @param $description  string
906
	 * @param $posx         float               horizontal position
907
	 * @param $posy         float               vertical position
908
	 * @param $w            float               width
909
	 * @param $h            float               height
910
	 */
911
	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
0 ignored issues
show
Unused Code introduced by
The parameter $description is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

911
	function pdf_add_total(&$pdf,&$object, &$line, $label, /** @scrutinizer ignore-unused */ $description,$posx, $posy, $w, $h) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
912
		global $conf,$subtotal_last_title_posy;
913
914
		$hideInnerLines = (int)GETPOST('hideInnerLines');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

914
		$hideInnerLines = (int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines');
Loading history...
915
		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
916
		{
917
			$posy = $subtotal_last_title_posy;
918
			$subtotal_last_title_posy = null;
919
		}
920
		
921
		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
922
923
		if($object->element == 'shipping' || $object->element == 'delivery')
924
		{
925
			$hidePriceOnSubtotalLines = 1;
926
		}
927
		
928
		$set_pagebreak_margin = false;
929
		if(method_exists('Closure','bind')) {
930
			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
931
			$sweetsThief = function ($pdf) {
932
		    		return $pdf->bMargin ;
933
			};
934
			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
935
	
936
			$bMargin  = $sweetsThief($pdf);
937
	
938
			$pdf->SetAutoPageBreak( false );
939
940
			$set_pagebreak_margin = true;			
941
		}
942
		
943
			
944
		if($line->qty==99)
945
			$pdf->SetFillColor(220,220,220);
946
		elseif ($line->qty==98)
947
			$pdf->SetFillColor(230,230,230);
948
		else
949
			$pdf->SetFillColor(240,240,240);
950
		
951
		$style = 'B';
952
		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
953
		
954
		$pdf->SetFont('', $style, 9);
955
		
956
		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
957
//		var_dump($bMargin);
958
		$pageAfter = $pdf->getPage();
0 ignored issues
show
Unused Code introduced by
The assignment to $pageAfter is dead and can be removed.
Loading history...
959
		
960
		//Print background
961
		$cell_height = $pdf->getStringHeight($w, $label);
962
		$pdf->SetXY($posx, $posy);
963
		$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite, $cell_height, '', 0, '', 1);
964
		
965
		if (!$hidePriceOnSubtotalLines) {
966
			$total_to_print = price($line->total);
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

966
			$total_to_print = /** @scrutinizer ignore-call */ price($line->total);
Loading history...
967
			
968
			if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
969
			{
970
				$TTitle = TSubtotal::getAllTitleFromLine($line);
971
				foreach ($TTitle as &$line_title)
972
				{
973
					if (!empty($line_title->array_options['options_subtotal_nc']))
974
					{
975
						$total_to_print = ''; // TODO Gestion "Compris/Non compris", voir si on affiche une annotation du genre "NC"
976
						break;
977
					}
978
				}
979
			}
980
			
981
			
982
			
983
			
984
			if($total_to_print !== '') {
985
				
986
				if (GETPOST('hideInnerLines'))
987
				{
988
					// Dans le cas des lignes cachés, le calcul est déjà fait dans la méthode beforePDFCreation et les lignes de sous-totaux sont déjà renseignés
989
//					$line->TTotal_tva
990
//					$line->total_ht
991
//					$line->total_tva
992
//					$line->total
993
//					$line->total_ttc
994
				}
995
				else
996
				{
997
					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
998
					$total_to_print = price($total);
999
					
1000
                    $line->total_ht = $total;
1001
					$line->total = $total;
1002
					$line->total_tva = $total_tva;
1003
					$line->total_ttc = $total_ttc;
1004
				}
1005
			}
1006
1007
			$pdf->SetXY($pdf->postotalht, $posy);
1008
			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $bMargin does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $pageBreakOriginalValue does not seem to be defined for all execution paths leading up to this point.
Loading history...
1009
			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1010
		}
1011
		else{
1012
			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1013
		}
1014
		
1015
		$posy = $posy + $cell_height;
1016
		$pdf->SetXY($posx, $posy); 
1017
			
1018
		
1019
	}
1020
1021
	/**
1022
	 * @param $pdf          TCPDF               PDF object
1023
	 * @param $object       CommonObject        dolibarr object
1024
	 * @param $line         CommonObjectLine    dolibarr object line
1025
	 * @param $label        string
1026
	 * @param $description  string
1027
	 * @param $posx         float               horizontal position
1028
	 * @param $posy         float               vertical position
1029
	 * @param $w            float               width
1030
	 * @param $h            float               height
1031
	 */
1032
	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1032
	function pdf_add_title(&$pdf,/** @scrutinizer ignore-unused */ &$object, &$line, $label, $description,$posx, $posy, $w, $h) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1033
		
1034
		global $db,$conf,$subtotal_last_title_posy;
1035
		
1036
		$subtotal_last_title_posy = $posy;
1037
		$pdf->SetXY ($posx, $posy);
1038
		
1039
		$hideInnerLines = (int)GETPOST('hideInnerLines');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1039
		$hideInnerLines = (int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines');
Loading history...
1040
		
1041
		
1042
 
1043
		$style = ($line->qty==1) ? 'BU' : 'BUI';
1044
		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1045
		
1046
		if($hideInnerLines) {
1047
			if($line->qty==1)$pdf->SetFont('', $style, 9);
1048
			else 
1049
			{
1050
				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1051
				$pdf->SetFont('', $style, 9);
1052
			}
1053
		}
1054
		else {
1055
1056
			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1057
			else $pdf->SetFont('', $style, 9);
1058
			
1059
		}
1060
		
1061
		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
0 ignored issues
show
Bug introduced by
The function dol_html_entity_decode was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1061
		if ($label === strip_tags($label) && $label === /** @scrutinizer ignore-call */ dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
Loading history...
1062
		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1063
		
1064
		if($description && !$hidedesc) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $hidedesc seems to be never defined.
Loading history...
1065
			$posy = $pdf->GetY();
1066
			
1067
			$pdf->SetFont('', '', 8);
1068
			
1069
			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1070
1071
		}
1072
		
1073
	}
1074
1075
	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1076
	// ultimate PDF hook O_o
1077
		
1078
		return $this->pdf_writelinedesc($parameters,$object,$action);
1079
		
1080
	}
1081
1082
	function isModSubtotalLine(&$parameters, &$object) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1083
		
1084
		if(is_array($parameters)) {
1085
			$i = & $parameters['i'];	
1086
		}
1087
		else {
1088
			$i = (int)$parameters;
1089
		}
1090
1091
		$line = $object->lines[$i];
1092
1093
		if($object->element == 'shipping' || $object->element == 'delivery')
1094
		{
1095
			dol_include_once('/commande/class/commande.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1095
			/** @scrutinizer ignore-call */ 
1096
   dol_include_once('/commande/class/commande.class.php');
Loading history...
1096
			$line = new OrderLine($object->db);
1097
			$line->fetch($object->lines[$i]->fk_origin_line);
1098
		}
1099
		
1100
1101
		if($line->special_code == $this->module_number && $line->product_type == 9) {
1102
			return true;
1103
		}
1104
		
1105
		return false;
1106
		
1107
	}
1108
1109
	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1109
	function pdf_getlineqty($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action='') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1110
		global $conf,$hideprices;
1111
1112
		if($this->isModSubtotalLine($parameters,$object) ){
1113
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1114
			
1115
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1116
				return '';
1117
			}
1118
			else if((float)DOL_VERSION>=3.8) {
1119
				return 1;
1120
			}
1121
			
1122
		}
1123
		elseif(!empty($hideprices)) {
1124
			$this->resprints = $object->lines[$parameters['i']]->qty;
1125
			return 1;
1126
		}
1127
		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1128
		{
1129
			$hideInnerLines = (int)GETPOST('hideInnerLines');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1129
			$hideInnerLines = (int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines');
Loading history...
1130
			$hidedetails = (int)GETPOST('hidedetails');
1131
			if (empty($hideInnerLines) && !empty($hidedetails))
1132
			{
1133
				$this->resprints = $object->lines[$parameters['i']]->qty;
1134
			}
1135
		}
1136
		
1137
		if(is_array($parameters)) $i = & $parameters['i'];
1138
		else $i = (int)$parameters;
1139
1140
		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1141
		
1142
		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1143
1144
		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1145
		{
1146
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1147
			{
1148
				$this->resprints = ' ';
1149
				return 1;
1150
			}
1151
		}
1152
		
1153
		return 0;
1154
	}
1155
	
1156
	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1157
	    global $conf, $hideprices, $hookmanager;
1158
		
1159
		if(is_array($parameters)) $i = & $parameters['i'];
1160
		else $i = (int)$parameters;
1161
			
1162
		if($this->isModSubtotalLine($parameters,$object) ){
1163
			
1164
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1165
			
1166
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1167
				return '';
1168
			}
1169
			else if((float)DOL_VERSION>=3.8) {
1170
				return 1;
1171
			}
1172
			
1173
		}
1174
		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1175
		{
1176
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1177
			{
1178
				if (!empty($object->lines[$i]->array_options['options_subtotal_nc'])) 
1179
				{
1180
					$this->resprints = ' ';
1181
					return 1;
1182
				}
1183
1184
				$TTitle = TSubtotal::getAllTitleFromLine($object->lines[$i]);
1185
				foreach ($TTitle as &$line_title)
1186
				{
1187
					if (!empty($line_title->array_options['options_subtotal_nc']))
1188
					{
1189
						$this->resprints = ' ';
1190
						return 1;
1191
					}
1192
				}
1193
			}
1194
		}
1195
		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1195
		if ((int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
Loading history...
1196
		    $this->resprints = price($object->lines[$i]->total_ht);
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1196
		    $this->resprints = /** @scrutinizer ignore-call */ price($object->lines[$i]->total_ht);
Loading history...
1197
		}
1198
		
1199
		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
1200
		if ( 
1201
			!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && 
1202
			(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) 
1203
		)
1204
		{
1205
			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1206
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1207
			{
1208
				$this->resprints = ' ';
1209
				
1210
				// currentcontext à modifier celon l'appel
1211
				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinetotalexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1212
				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1213
			}
1214
		}
1215
		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1216
		else if (!empty($hideprices))
1217
		{
1218
			// Check if a title exist for this line && if the title have subtotal
1219
			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1220
			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
0 ignored issues
show
Bug introduced by
It seems like $lineTitle can also be of type false; however, parameter $title_line of TSubtotal::titleHasTotalLine() does only seem to accept FactureLigne|OrderLine|PropaleLigne, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1220
			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, /** @scrutinizer ignore-type */ $lineTitle, true))
Loading history...
1221
			{
1222
1223
				$this->resprints = ' ';
1224
				
1225
				// currentcontext à modifier celon l'appel
1226
				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinetotalexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1227
				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1228
			}
1229
		}
1230
        
1231
		return 0;
1232
	}
1233
	
1234
	/**
1235
	 * Remplace le retour de la méthode qui l'appelle par un standard 1 ou autre chose celon le hook
1236
	 * @return int 1, 0, -1
1237
	 */
1238
	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1239
	{
1240
		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1241
		if ($reshook < 0)
1242
		{
1243
			$this->error = $hookmanager->error;
0 ignored issues
show
Bug Best Practice introduced by
The property error does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1244
			$this->errors = $hookmanager->errors;
0 ignored issues
show
Bug Best Practice introduced by
The property errors does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1245
			return -1;
1246
		}
1247
		elseif (empty($reshook))
1248
		{
1249
			$this->resprints .= $hookmanager->resprints;
1250
		}
1251
		else
1252
		{
1253
			$this->resprints = $hookmanager->resprints;
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1254
1255
			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1256
			if(isset($hookmanager->resArray['overrideReturn']))
1257
			{
1258
				return $hookmanager->resArray['overrideReturn'];
1259
			}
1260
		}
1261
1262
		return $defaultReturn;
1263
	}
1264
	
1265
	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1265
	function pdf_getlinetotalwithtax($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action='') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1266
		global $conf;
1267
		
1268
		if($this->isModSubtotalLine($parameters,$object) ){
1269
			
1270
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1271
		
1272
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1273
				return '';
1274
			}
1275
			else if((float)DOL_VERSION>=3.8) {
1276
				return 1;
1277
			}
1278
		}
1279
		
1280
		if(is_array($parameters)) $i = & $parameters['i'];
1281
		else $i = (int)$parameters;
1282
		
1283
		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1284
		{
1285
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1286
			{
1287
				$this->resprints = ' ';
1288
				return 1;
1289
			}
1290
		}
1291
		
1292
		return 0;
1293
	}
1294
	
1295
	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1295
	function pdf_getlineunit($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action='') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1296
		global $conf;
1297
		
1298
		if($this->isModSubtotalLine($parameters,$object) ){
1299
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1300
		
1301
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1302
				return '';
1303
			}
1304
			else if((float)DOL_VERSION>=3.8) {
1305
				return 1;
1306
			}
1307
		}
1308
		
1309
		if(is_array($parameters)) $i = & $parameters['i'];
1310
		else $i = (int)$parameters;
1311
			
1312
		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1313
		{
1314
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1315
			{
1316
				$this->resprints = ' ';
1317
				return 1;
1318
			}
1319
		}
1320
		
1321
		return 0;
1322
	}
1323
	
1324
	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1325
	    global $conf,$hideprices,$hookmanager;
1326
1327
		if(is_array($parameters)) $i = & $parameters['i'];
1328
		else $i = (int)$parameters;
1329
1330
		if($this->isModSubtotalLine($parameters,$object) ) {
1331
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1332
1333
            $line = $object->lines[$i];
1334
1335
            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1336
            if(TSubtotal::isSubtotal($line)) {
1337
                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1338
1339
                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1340
                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1341
                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1342
                    $this->resprints = price($TTotal['total_subprice']);
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1342
                    $this->resprints = /** @scrutinizer ignore-call */ price($TTotal['total_subprice']);
Loading history...
1343
                }
1344
            }
1345
		
1346
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1347
				return '';
1348
			}
1349
			else if((float)DOL_VERSION>=3.8) {
1350
				return 1;
1351
			}
1352
		}
1353
		
1354
		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
1355
		if (
1356
		!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) &&
1357
		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1358
		)
1359
		{
1360
		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1361
		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1362
		    {
1363
		        $this->resprints = ' ';
1364
		        
1365
		        // currentcontext à modifier celon l'appel
1366
		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1367
		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1368
		        
1369
		    }
1370
		}
1371
		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1372
		else if (!empty($hideprices))
1373
		{
1374
		    
1375
		    // Check if a title exist for this line && if the title have subtotal
1376
		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1377
		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
0 ignored issues
show
Bug introduced by
It seems like $lineTitle can also be of type false; however, parameter $title_line of TSubtotal::titleHasTotalLine() does only seem to accept FactureLigne|OrderLine|PropaleLigne, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1377
		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, /** @scrutinizer ignore-type */ $lineTitle, true))
Loading history...
1378
		    {
1379
		        
1380
		        $this->resprints = ' ';
1381
		        
1382
		        // currentcontext à modifier celon l'appel
1383
		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1384
		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1385
		    }
1386
		}
1387
		
1388
		return 0;
1389
	}
1390
	
1391
	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1391
	function pdf_getlineremisepercent($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action='') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1392
	    global $conf,$hideprices,$hookmanager;
1393
1394
        if(is_array($parameters)) $i = & $parameters['i'];
1395
        else $i = (int) $parameters;
1396
1397
		if($this->isModSubtotalLine($parameters,$object) ) {
1398
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1399
1400
            $line = $object->lines[$i];
1401
1402
            // Affichage de la remise 
1403
            if(TSubtotal::isSubtotal($line)) {
1404
                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1405
1406
                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1407
                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1408
                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1409
                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1409
                    $this->resprints = /** @scrutinizer ignore-call */ price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
Loading history...
1410
                }
1411
            }
1412
		
1413
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1414
				return '';
1415
			}
1416
			else if((float)DOL_VERSION>=3.8) {
1417
				return 1;
1418
			}
1419
		}
1420
		elseif (!empty($hideprices)
1421
		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1422
		        )
1423
		    {
1424
		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1425
		        {
1426
		            $this->resprints = ' ';
1427
		            return 1;
1428
		        }
1429
		    }
1430
		
1431
		return 0;
1432
	}
1433
	
1434
	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1434
	function pdf_getlineupwithtax($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action='') {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1435
		global $conf,$hideprices;
1436
		
1437
		if($this->isModSubtotalLine($parameters,$object) ){
1438
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1439
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1440
				return '';
1441
			}
1442
			else if((float)DOL_VERSION>=3.8) {
1443
				return 1;
1444
			}
1445
		}
1446
		
1447
		if(is_array($parameters)) $i = & $parameters['i'];
1448
		else $i = (int)$parameters;
1449
			
1450
		if (!empty($hideprices)
1451
				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1452
		)
1453
		{
1454
			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1455
			{
1456
				$this->resprints = ' ';
1457
				return 1;
1458
			}
1459
		}
1460
		
1461
		return 0;
1462
	}
1463
	
1464
	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1465
	    global $conf,$hideprices,$hookmanager;
1466
	    
1467
		if($this->isModSubtotalLine($parameters,$object) ){
1468
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1469
			
1470
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1471
				return '';
1472
			}
1473
			else if((float)DOL_VERSION>=3.8) {
1474
				return 1;
1475
			}
1476
		}
1477
		
1478
		if(is_array($parameters)) $i = & $parameters['i'];
1479
		else $i = (int)$parameters;
1480
		
1481
		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1482
1483
		$object->lines[$i]->fetch_optionals();
1484
		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
1485
		if (
1486
		!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) &&
1487
		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1488
		)
1489
		{
1490
		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1491
		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1492
		    {
1493
		        $this->resprints = ' ';
1494
		        
1495
		        // currentcontext à modifier celon l'appel
1496
		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1497
		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1498
		    }
1499
		}
1500
		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1501
		else if (!empty($hideprices))
1502
		{
1503
		    
1504
		    // Check if a title exist for this line && if the title have subtotal
1505
		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1506
		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
0 ignored issues
show
Bug introduced by
It seems like $lineTitle can also be of type false; however, parameter $title_line of TSubtotal::titleHasTotalLine() does only seem to accept FactureLigne|OrderLine|PropaleLigne, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1506
		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, /** @scrutinizer ignore-type */ $lineTitle, true))
Loading history...
1507
		    {
1508
		        
1509
		        $this->resprints = ' ';
1510
		        
1511
		        // currentcontext à modifier celon l'appel
1512
		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1513
		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1514
		    }
1515
		}
1516
		
1517
		return 0;
1518
	}
1519
		
1520
	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1520
	function pdf_getlineprogress($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1521
		global $conf;
1522
		
1523
		if($this->isModSubtotalLine($parameters,$object) ){
1524
			$this->resprints = ' ';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1525
			if((float)DOL_VERSION<=3.6) {
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1526
				return '';
1527
			}
1528
			else if((float)DOL_VERSION>=3.8) {
1529
				return 1;
1530
			}
1531
		}
1532
		
1533
		if(is_array($parameters)) $i = & $parameters['i'];
1534
		else $i = (int)$parameters;
1535
			
1536
		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1537
		{
1538
			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1539
			{
1540
				$this->resprints = ' ';
1541
				return 1;
1542
			}
1543
		}
1544
		
1545
		return 0;
1546
	}
1547
	
1548
	function add_numerotation(&$object) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1549
		global $conf;
1550
		
1551
		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1552
		
1553
			$TLevelTitre = array();
0 ignored issues
show
Unused Code introduced by
The assignment to $TLevelTitre is dead and can be removed.
Loading history...
1554
			$prevlevel = 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $prevlevel is dead and can be removed.
Loading history...
1555
		
1556
			foreach($object->lines as $k=>&$line) 
1557
			{
1558
				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1559
				{
1560
					$TLineTitle[] = &$line;
1561
				}
1562
			}
1563
			
1564
			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
0 ignored issues
show
Unused Code introduced by
The assignment to $TTitleNumeroted is dead and can be removed.
Loading history...
1565
		}
1566
		
1567
	}
1568
1569
	// TODO ne gère pas encore la numération des lignes "Totaux"
1570
	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1571
	{
1572
		$TTitle = array();
1573
		
1574
		$i=1;
1575
		$j=0;
1576
		foreach ($TLineTitle as $k => &$line)
1577
		{
1578
			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1579
			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1580
			
1581
			if ($line->qty == $level)
1582
			{
1583
				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1584
				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1585
				if (empty($line->label) && (float)DOL_VERSION < 6)
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1586
				{
1587
					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1588
					$line->desc = $line->description = '';
1589
				}
1590
				
1591
				$line->label = $TTitle[$j]['numerotation'].' '.$line->label;
1592
				$TTitle[$j]['line'] = &$line;
1593
				
1594
				$deep_level = $line->qty;
1595
				do {
1596
					$deep_level++;
1597
					$TTitle[$j]['children'] = $this->formatNumerotation($TLineTitle, $line, $deep_level, $TTitle[$j]['numerotation']);
1598
				} while (empty($TTitle[$j]['children']) && $deep_level <= 10); // Exemple si un bloc Titre lvl 1 contient pas de sous lvl 2 mais directement un sous lvl 5
1599
				// Rappel on peux avoir jusqu'a 10 niveau de titre
1600
				
1601
				$i++;
1602
				$j++;
1603
			}
1604
		}
1605
1606
		return $TTitle;
1607
	}
1608
	
1609
	function setDocTVA(&$pdf, &$object) {
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1609
	function setDocTVA(&$pdf, /** @scrutinizer ignore-unused */ &$object) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $pdf is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1609
	function setDocTVA(/** @scrutinizer ignore-unused */ &$pdf, &$object) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1610
		
1611
		$hidedetails = (int)GETPOST('hidedetails');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1611
		$hidedetails = (int)/** @scrutinizer ignore-call */ GETPOST('hidedetails');
Loading history...
1612
		
1613
		if(empty($hidedetails)) return false;
1614
		
1615
		// TODO can't add VAT to document without lines... :-/
1616
		
1617
		return true;
1618
	}
1619
	
1620
	function beforePDFCreation($parameters=array(), &$object, &$action)
0 ignored issues
show
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1620
	function beforePDFCreation($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1621
	{
1622
		/**
1623
		 * @var $pdf    TCPDF
1624
		 */
1625
		global $pdf,$conf, $langs;
1626
1627
		// var_dump($object->lines);
1628
		dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1628
		/** @scrutinizer ignore-call */ 
1629
  dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
1629
1630
		foreach($parameters as $key=>$value) {
1631
			${$key} = $value;
1632
		}
1633
		
1634
		$this->setDocTVA($pdf, $object);
1635
		
1636
		$this->add_numerotation($object);	
1637
		
1638
        foreach($object->lines as $k => &$l) {
1639
            if(TSubtotal::isSubtotal($l)) {
1640
                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1641
                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1642
                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1643
                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1644
                }
1645
            }
1646
1647
1648
            // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1649
            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1650
			{
1651
				$l->qty = $l->qty_asked;
1652
				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1653
			}
1654
        }
1655
1656
		$hideInnerLines = (int)GETPOST('hideInnerLines');
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1656
		$hideInnerLines = (int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines');
Loading history...
1657
		$hidedetails = (int)GETPOST('hidedetails');
1658
1659
		if ($hideInnerLines) { // si c une ligne de titre
1660
	    	$fk_parent_line=0;
0 ignored issues
show
Unused Code introduced by
The assignment to $fk_parent_line is dead and can be removed.
Loading history...
1661
			$TLines =array();
1662
		
1663
			$original_count=count($object->lines);
0 ignored issues
show
Unused Code introduced by
The assignment to $original_count is dead and can be removed.
Loading history...
1664
		    $TTvas = array(); // tableau de tva
1665
		    
1666
			foreach($object->lines as $k=>&$line) 
1667
			{
1668
			    
1669
				if($line->product_type==9 && $line->rowid>0) 
1670
				{
1671
					$fk_parent_line = $line->rowid;
1672
					
1673
					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme
1674
					if(TSubtotal::isSubtotal($line)) 
1675
					{
1676
						/*$total = $this->getTotalLineFromObject($object, $line, '');
1677
						
1678
						$line->total_ht = $total;
1679
						$line->total = $total;
1680
						*/
1681
						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1682
						
1683
						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1684
						$line->total_ht = $total;
1685
						$line->total_tva = $total_tva;
1686
						$line->total = $line->total_ht;
1687
						$line->total_ttc = $total_ttc;
1688
1689
//                        $TTitle = TSubtotal::getParentTitleOfLine($object, $k);
1690
//                        $parentTitle = array_shift($TTitle);
1691
//                        if(! empty($parentTitle->id) && ! empty($parentTitle->array_option['options_show_total_ht'])) {
1692
//                            exit('la?');
1693
//                            $line->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1694
//                            $line->update();
1695
//                        }
1696
					} 
1697
//                    if(TSub)
1698
						
1699
				} 
1700
			
1701
				if ($hideInnerLines)
1702
				{
1703
				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1704
				    {
1705
				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1706
				            
1707
    				        // on remplit le tableau de tva pour substituer les lignes cachées
1708
    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1709
    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1710
    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1711
    				    }
1712
    					if($line->product_type==9 && $line->rowid>0)
1713
    					{
1714
    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1715
    					    // génère des lignes d'affichage des montants HT soumis à tva
1716
    					    $nbtva = count($TTvas);
1717
    					    if(!empty($nbtva)){
1718
    					        foreach ($TTvas as $tx =>$val){
1719
    					            $l = clone $line;
1720
    					            $l->product_type = 1;
1721
    					            $l->special_code = '';
1722
    					            $l->qty = 1;
1723
    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1723
    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), /** @scrutinizer ignore-call */ price($tx));
Loading history...
1724
    					            $l->tva_tx = $tx;
1725
    					            $l->total_ht = $val['total_ht'];
1726
    					            $l->total_tva = $val['total_tva'];
1727
    					            $l->total = $line->total_ht;
1728
    					            $l->total_ttc = $val['total_ttc'];
1729
    					            $TLines[] = $l;
1730
    					            array_shift($TTvas);
1731
    					       }
1732
    					    }
1733
    					    
1734
    					    // ajoute la ligne de sous-total
1735
    					    $TLines[] = $line; 
1736
    					}
1737
				    } else {
1738
				        
1739
				        if($line->product_type==9 && $line->rowid>0)
1740
				        {
1741
				            // ajoute la ligne de sous-total
1742
				            $TLines[] = $line; 
1743
				        }
1744
				    }
1745
				    
1746
					
1747
				}
1748
				elseif ($hidedetails)
1749
				{
1750
					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1751
				}
1752
				
1753
				if ($line->product_type != 9) { // jusqu'au prochain titre ou total
1754
					//$line->fk_parent_line = $fk_parent_line;
1755
					
1756
				}
1757
			
1758
				/*if($hideTotal) {
1759
					$line->total = 0;
1760
					$line->subprice= 0;
1761
				}*/
1762
				
1763
			}
1764
			
1765
			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1766
			$nbtva = count($TTvas);
1767
			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1768
			{
1769
			    foreach ($TTvas as $tx =>$val){
1770
			        $l = clone $line;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $line seems to be defined by a foreach iteration on line 1666. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
1771
			        $l->product_type = 1;
1772
			        $l->special_code = '';
1773
			        $l->qty = 1;
1774
			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1775
			        $l->tva_tx = $tx;
1776
			        $l->total_ht = $val['total_ht'];
1777
			        $l->total_tva = $val['total_tva'];
1778
			        $l->total = $line->total_ht;
1779
			        $l->total_ttc = $val['total_ttc'];
1780
			        $TLines[] = $l;
1781
			        array_shift($TTvas);
1782
			    }
1783
			}
1784
			
1785
			global $nblignes;
1786
			$nblignes=count($TLines);
1787
1788
			$object->lines = $TLines;
1789
			
1790
			if($i>count($object->lines)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $i seems to be never defined.
Loading history...
1791
				$this->resprints = '';
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1792
				return 0;
1793
			}
1794
	    }
1795
		
1796
		return 0;
1797
	}
1798
1799
	function pdf_writelinedesc($parameters=array(), &$object, &$action)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1799
	function pdf_writelinedesc($parameters=array(), &$object, /** @scrutinizer ignore-unused */ &$action)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1800
	{
1801
		/**
1802
		 * @var $pdf    TCPDF
1803
		 */
1804
		global $pdf,$conf;
1805
1806
		foreach($parameters as $key=>$value) {
1807
			${$key} = $value;
1808
		}
1809
		
1810
		$hideInnerLines = (int)GETPOST('hideInnerLines');
0 ignored issues
show
Unused Code introduced by
The assignment to $hideInnerLines is dead and can be removed.
Loading history...
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1810
		$hideInnerLines = (int)/** @scrutinizer ignore-call */ GETPOST('hideInnerLines');
Loading history...
1811
		$hidedetails = (int)GETPOST('hidedetails');
0 ignored issues
show
Unused Code introduced by
The assignment to $hidedetails is dead and can be removed.
Loading history...
1812
		
1813
		if($this->isModSubtotalLine($parameters,$object) ){			
1814
		
1815
				global $hideprices;
1816
				
1817
				if(!empty($hideprices)) {
1818
					foreach($object->lines as &$line) {
1819
						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1820
					}
1821
				}
1822
			
1823
				$line = &$object->lines[$i];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $i seems to be never defined.
Loading history...
1824
1825
				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1826
1827
				if($line->info_bits>0) { // PAGE BREAK
1828
					$pdf->addPage();
1829
					$posy = $pdf->GetY();
1830
				}
1831
				
1832
				$label = $line->label;
1833
				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $outputlangs seems to be never defined.
Loading history...
1834
				
1835
				if(empty($label)) {
1836
					$label = $description;
1837
					$description='';
1838
				}
1839
1840
				if($line->qty>90) {
1841
					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1842
					
1843
					$pageBefore = $pdf->getPage();
1844
					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $posx seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $h seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $w seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $posy does not seem to be defined for all execution paths leading up to this point.
Loading history...
1845
					$pageAfter = $pdf->getPage();	
1846
1847
					if($pageAfter>$pageBefore) {
1848
						//print "ST $pageAfter>$pageBefore<br>";
1849
						$pdf->rollbackTransaction(true);
1850
						$pdf->addPage('', '', true);
1851
						$posy = $pdf->GetY();
1852
						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1853
						$posy = $pdf->GetY();
0 ignored issues
show
Unused Code introduced by
The assignment to $posy is dead and can be removed.
Loading history...
1854
						//print 'add ST'.$pdf->getPage().'<br />';
1855
					}
1856
1857
					// On delivery PDF, we don't want quantities to appear and there are no hooks => setting text color to background color;
1858
					if($object->element == 'delivery')
1859
					{
1860
						switch($line->qty)
1861
						{
1862
							case 99:
1863
								$grey = 220;
1864
								break;
1865
1866
							case 98:
1867
								$grey = 230;
1868
								break;
1869
1870
							default:
1871
								$grey = 240;
1872
						}
1873
1874
						$pdf->SetTextColor($grey, $grey, $grey);
1875
					}
1876
				
1877
					$posy = $pdf->GetY();
1878
					return 1;
1879
				}	
1880
				else if ($line->qty < 10) {
1881
					$pageBefore = $pdf->getPage();
0 ignored issues
show
Unused Code introduced by
The assignment to $pageBefore is dead and can be removed.
Loading history...
1882
1883
					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1884
					$pageAfter = $pdf->getPage();	
0 ignored issues
show
Unused Code introduced by
The assignment to $pageAfter is dead and can be removed.
Loading history...
1885
1886
					
1887
					/*if($pageAfter>$pageBefore) {
1888
						print "T $pageAfter>$pageBefore<br>";
1889
						$pdf->rollbackTransaction(true);
1890
						$pdf->addPage('','', true);
1891
						print 'add T'.$pdf->getPage().' '.$line->rowid.' '.$pdf->GetY().' '.$posy.'<br />';
1892
						
1893
						$posy = $pdf->GetY();
1894
						$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1895
						$posy = $pdf->GetY();
1896
					}
1897
				*/
1898
1899
					if($object->element == 'delivery')
1900
					{
1901
						$pdf->SetTextColor(255,255,255);
1902
					}
1903
1904
					$posy = $pdf->GetY();
1905
					return 1;
1906
				}
1907
//	if($line->rowid==47) exit;
1908
			
1909
			return 0;
1910
		}
1911
		elseif (empty($object->lines[$parameters['i']]))
1912
		{
1913
			$this->resprints = -1;
0 ignored issues
show
Bug Best Practice introduced by
The property resprints does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1914
		}
1915
1916
		/* TODO je desactive parce que je comprends pas PH Style, mais à test
1917
		else {
1918
			
1919
			if($hideInnerLines) {
1920
				$pdf->rollbackTransaction(true);
1921
			}
1922
			else {
1923
				$labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1924
				$pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1);
1925
			}
1926
			
1927
		}*/
1928
1929
1930
		
1931
	}
1932
1933
	/**
1934
	 * Permet de récupérer le titre lié au sous-total
1935
	 * 
1936
	 * @return string
1937
	 */
1938
	function getTitle(&$object, &$currentLine)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1939
	{
1940
		$res = '';
1941
		
1942
		foreach ($object->lines as $line)
1943
		{
1944
			if ($line->id == $currentLine->id) break;
1945
			
1946
			$qty_search = 100 - $currentLine->qty;
1947
			
1948
			if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search) 
1949
			{
1950
				$res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc);
1951
			}
1952
		}
1953
		
1954
		return $res;
1955
	}
1956
	
1957
	/**
1958
	 * @param $parameters   array
1959
	 * @param $object       CommonObject
1960
	 * @param $action       string
1961
	 * @param $hookmanager  HookManager
0 ignored issues
show
Bug introduced by
The type HookManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
1962
	 * @return int
1963
	 */
1964
	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1965
		
1966
		global $conf,$langs,$user,$db,$bc;
1967
		
1968
		$num = &$parameters['num'];
1969
		$line = &$parameters['line'];
1970
		$i = &$parameters['i'];
1971
		
1972
		$var = &$parameters['var'];
1973
1974
		$contexts = explode(':',$parameters['context']);
1975
1976
		$originline = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $originline is dead and can be removed.
Loading history...
1977
1978
		$createRight = $user->rights->{$object->element}->creer;
1979
		if($object->element == 'facturerec' )
1980
		{
1981
			$object->statut = 0; // hack for facture rec
1982
			$createRight = $user->rights->facture->creer;
1983
		}
1984
		elseif($object->element == 'order_supplier' )
1985
		{
1986
		    $createRight = $user->rights->fournisseur->commande->creer;
1987
		}
1988
		elseif($object->element == 'invoice_supplier' )
1989
		{
1990
		    $createRight = $user->rights->fournisseur->facture->creer;
1991
		}
1992
		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1993
		{
1994
			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1995
			$line->id = $line->rowid;
1996
			$line->product_type = $line->type;
1997
		}
1998
		elseif($object->element == 'shipping' || $object->element == 'delivery')
1999
		{
2000
			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2001
			{
2002
				$line->origin_line_id = $line->fk_origin_line;
2003
			}
2004
2005
			$originline = new OrderLine($db);
2006
			$originline->fetch($line->fk_origin_line);
2007
2008
			foreach(get_object_vars($line) as $property => $value)
2009
			{
2010
				if(empty($originline->{ $property }))
2011
				{
2012
					$originline->{ $property } = $value;
2013
				}
2014
			}
2015
2016
			$line = $originline;
2017
		}
2018
2019
		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2020
			null;
2021
		}
2022
		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
2023
        {
2024
			if($object->element=='facture')$idvar = 'facid';
2025
			else $idvar='id';
2026
2027
			if((float)DOL_VERSION <= 3.4)
0 ignored issues
show
Bug introduced by
The constant DOL_VERSION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
2028
			{
2029
				?>
2030
				<script type="text/javascript">
2031
					$(document).ready(function() {
2032
						$('#tablelines tr[rel=subtotal]').mouseleave(function() {
2033
2034
							id_line =$(this).attr('id');
2035
2036
							$(this).find('td[rel=subtotal_total]').each(function() {
2037
								$.get(document.location.href, function(data) {
2038
									var total = $(data).find('#tablelines tr#'+id_line+' td[rel=subtotal_total]').html();
2039
2040
									$('#tablelines tr#'+id_line+' td[rel=subtotal_total]').html(total);
2041
2042
								});
2043
							});
2044
						});
2045
					});
2046
2047
				</script>
2048
				<?php
2049
			}
2050
			
2051
			if(empty($line->description)) $line->description = $line->desc;
2052
			
2053
			$colspan = 5;
2054
			if($object->element == 'facturerec' ) $colspan = 3;
2055
			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2056
			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2057
			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2058
			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2059
				$colspan++; // Colonne PU Devise
2060
			}
2061
			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2062
			if(!empty($conf->margin->enabled)) $colspan++;
2063
			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2064
			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2065
			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2066
			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2067
					
2068
			/* Titre */
2069
			//var_dump($line);
2070
            
2071
			// HTML 5 data for js
2072
            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2073
            
2074
			
2075
			?>
2076
			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2077
					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2078
					{
2079
						if($line->qty==99) print 'background:#adadcf';
2080
						else if($line->qty==98) print 'background:#ddddff;';
2081
						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2082
						else if($line->qty==1) print 'background:#adadcf;';
2083
						else if($line->qty==2) print 'background:#ddddff;';
2084
						else if($line->qty==50) print '';
2085
						else print 'background:#eeeeff;';
2086
2087
						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2088
					}
2089
					else 
2090
					{
2091
						if($line->qty==99) print 'background:#ddffdd';
2092
						else if($line->qty==98) print 'background:#ddddff;';
2093
						else if($line->qty==2) print 'background:#eeeeff; ';
2094
						else if($line->qty==50) print '';
2095
						else print 'background:#eeffee;' ;
2096
					}
2097
2098
			?>;">
2099
2100
				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2101
				<td class="linecolnum"><?php echo $i + 1; ?></td>
2102
				<?php } ?>
2103
2104
				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2105
					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2105
					if($action=='editline' && /** @scrutinizer ignore-call */ GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
Loading history...
2106
2107
						$params=array('line'=>$line);
2108
						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
0 ignored issues
show
Unused Code introduced by
The assignment to $reshook is dead and can be removed.
Loading history...
2109
						
2110
						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2111
						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
2112
						echo '<input id="product_type" type="hidden" value="'.$line->product_type.'" name="type">';
2113
						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2114
						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2115
2116
						$isFreeText=false;
2117
						if (TSubtotal::isTitle($line))
2118
						{
2119
							$qty_displayed = $line->qty;
2120
							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
0 ignored issues
show
Bug introduced by
The function img_picto was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2120
							print /** @scrutinizer ignore-call */ img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
Loading history...
2121
							
2122
						}
2123
						else if (TSubtotal::isSubtotal($line))
2124
						{
2125
							$qty_displayed = 100 - $line->qty;
2126
							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2127
						}
2128
						else
2129
						{
2130
							$isFreeText = true;
2131
						}
2132
						
2133
						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2134
						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2135
						    $line->description = '';
2136
						}
2137
						$newlabel = $line->label;
2138
						if($line->label=='' && !$isFreeText) {
2139
							if(TSubtotal::isSubtotal($line)) {
2140
								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2141
								$line->description='';
2142
							} elseif( (float)DOL_VERSION < 6 ) {
2143
								$newlabel= $line->description;
2144
								$line->description='';
2145
							}
2146
						}
2147
2148
						$readonlyForSituation = '';
2149
						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2150
						
2151
						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2152
						
2153
						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2154
						{
2155
							$select = '<select name="subtotal_level">';
2156
							for ($j=1; $j<10; $j++)
2157
							{
2158
								if (!empty($readonlyForSituation)) {
2159
									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $qty_displayed does not seem to be defined for all execution paths leading up to this point.
Loading history...
2160
								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2161
							}
2162
							$select .= '</select>&nbsp;';
2163
2164
							echo $select;
2165
						}
2166
						
2167
2168
						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2169
                        echo '<div>';
2170
                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2171
                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2172
                        echo '</div>';
2173
2174
                        if (TSubtotal::isTitle($line))
2175
                        {
2176
                            $form = new Form($db);
2177
                            echo '<div>';
2178
                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2179
                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2180
                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2181
                            echo '</select>';
2182
                            echo '</div>';
2183
2184
                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2185
                            {
2186
                                echo '<div>';
2187
                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2188
                                echo '</div>';
2189
                            }
2190
                            echo '<div>';
2191
                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2192
                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2193
                            echo '</div>';
2194
2195
                            echo '<div>';
2196
                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2197
                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2198
                            echo '</div>';
2199
                        }
2200
                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2201
						echo '</div>';
2202
2203
						if($line->qty<10) {
2204
							// WYSIWYG editor
2205
							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
0 ignored issues
show
Bug introduced by
The constant DOL_DOCUMENT_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
2206
							$nbrows = ROWS_2;
0 ignored issues
show
Bug introduced by
The constant ROWS_2 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
2207
							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2208
							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
2209
								$nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
2210
							}
2211
							$toolbarname = 'dolibarr_details';
2212
							if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
2213
								$toolbarname = 'dolibarr_notes';
2214
							}
2215
							$doleditor = new DolEditor('line-description', $line->description, '', 100, $toolbarname, '',
0 ignored issues
show
Bug introduced by
The type DolEditor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
2216
								false, true, $cked_enabled, $nbrows, '98%', (bool) $readonlyForSituation);
2217
							$doleditor->Create();
2218
						}
2219
						
2220
					}
2221
					else {
2222
2223
						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2224
						 {
2225
							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2226
							{
2227
								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2228
								
2229
								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2230
								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2231
							}
2232
						 }
2233
						 else 
2234
						 {
2235
							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2236
							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2237
						 }
2238
						 
2239
						 
2240
						 // Get display styles and apply them
2241
						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2242
						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2243
						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2244
						 
2245
						 if (empty($line->label)) {
2246
							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2247
							else print  $line->description;
2248
						 } 
2249
						 else {
2250
2251
							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2252
								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
0 ignored issues
show
Bug introduced by
The function dol_htmlentitiesbr was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2252
								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'./** @scrutinizer ignore-call */ dol_htmlentitiesbr($line->description).'</div>';
Loading history...
2253
							}
2254
							else{
2255
								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2256
							}
2257
2258
						 } 
2259
						if($line->qty>90) print ' : ';
2260
						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2261
2262
						 
2263
2264
2265
					}
2266
			?></td>
2267
					 
2268
			<?php
2269
				if($line->qty>90) {
2270
					/* Total */
2271
					$total_line = $this->getTotalLineFromObject($object, $line, '');
2272
					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
0 ignored issues
show
Bug introduced by
The function price was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2272
					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'./** @scrutinizer ignore-call */ price($total_line).'</td>';
Loading history...
2273
					if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2274
						echo '<td class="linecoltotalht_currency">&nbsp;</td>';
2275
					}
2276
				} else {
2277
					echo '<td class="linecolht movetitleblock">&nbsp;</td>';
2278
					if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2279
						echo '<td class="linecoltotalht_currency">&nbsp;</td>';
2280
					}
2281
				}	
2282
			?>
2283
					
2284
			<td align="center" class="nowrap linecoledit">
2285
				<?php
2286
				if ($action != 'selectlines') {
2287
				
2288
					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2289
						?>
2290
						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2291
						<br />
2292
						<input class="button" type="button" name="cancelEditlinetitle" value="<?php echo $langs->trans('Cancel') ?>" />
2293
						<script type="text/javascript">
2294
							$(document).ready(function() {
2295
								$('input[name=cancelEditlinetitle]').click(function () {
2296
									document.location.href="<?php echo '?'.$idvar.'='.$object->id ?>";
2297
								});
2298
							});
2299
2300
						</script>
2301
						<?php
2302
						
2303
					}
2304
					else{
2305
						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2306
						{
2307
							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2308
						}
2309
2310
						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2311
						{
2312
							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
0 ignored issues
show
Bug introduced by
The function img_edit was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2312
							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'./** @scrutinizer ignore-call */ img_edit().'</a>';
Loading history...
2313
						}								
2314
					}
2315
					
2316
				}
2317
					
2318
				?>
2319
			</td>
2320
2321
			<td align="center" class="nowrap linecoldelete">	
2322
				<?php
2323
2324
				if ($action != 'editline' && $action != 'selectlines') {
2325
						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2326
						{
2327
2328
							if ($line->fk_prev_id === null)
2329
							{
2330
								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
0 ignored issues
show
Bug introduced by
The function img_delete was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2330
								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'./** @scrutinizer ignore-call */ img_delete().'</a>';
Loading history...
2331
							}
2332
2333
							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2334
							{
2335
								if ((float) DOL_VERSION >= 8.0) {
2336
									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2337
								} elseif ((float) DOL_VERSION >= 3.8) {
2338
									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2339
								} else {
2340
									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2341
								}
2342
2343
								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
2344
2345
								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2346
								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2347
								 */
2348
								if((float) DOL_VERSION >= 8.0) {
2349
								?>
2350
								<script>
2351
									$(document).ready(function () {
2352
										$("#row-<?php echo $line->id; ?> td.linecoldelete span.fa.fa-trash.pictodeleteallline").css({"color": "#be3535"});
2353
									});
2354
								</script>
2355
								<?php
2356
								}
2357
							}
2358
						}
2359
					}
2360
				?>
2361
			</td>
2362
			
2363
			<?php 
2364
			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2365
			{
2366
				echo '<td class="subtotal_nc">';
2367
				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
2368
				echo '</td>';
2369
			}
2370
			
2371
			if ($num > 1 && empty($conf->browser->phone)) { ?>
2372
			<td align="center" class="linecolmove tdlineupdown">
2373
			</td>
2374
			<?php } else { ?>
2375
			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2376
			<?php } ?>
2377
2378
2379
			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2380
			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2381
			<?php } ?>
2382
2383
			</tr>
2384
			<?php
2385
			
2386
			
2387
			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2388
			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2389
				
2390
				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2391
				
2392
				// Extrafields
2393
				$extrafieldsline = new ExtraFields($db);
2394
				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
0 ignored issues
show
Unused Code introduced by
The assignment to $extralabelsline is dead and can be removed.
Loading history...
2395
				
2396
				$colspan+=3; $mode = 'view';
2397
				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2398
				
2399
				$ex_element = $line->element;
2400
				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2401
				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2402
				$isExtraSelected = false;
2403
				foreach($line->array_options as $option) {
2404
					if(!empty($option) && $option != "-1") {
2405
						$isExtraSelected = true;
2406
						break;
2407
					}
2408
				}
2409
				
2410
				if($mode === 'edit') {
2411
					?>
2412
					<script>
2413
						$(document).ready(function(){
2414
2415
							var all_tr_extrafields = $("tr.tr_extrafield_title");
2416
							<?php 
2417
							// Si un extrafield est rempli alors on affiche directement les extrafields
2418
							if(!$isExtraSelected) {
2419
								echo 'all_tr_extrafields.hide();';
2420
								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2421
								echo 'var extra = 0;';
2422
							} else {
2423
								echo 'all_tr_extrafields.show();';
2424
								echo 'var trad = "'.$langs->trans('hideExtrafields').'";';
2425
								echo 'var extra = 1;';
2426
							}
2427
							?>
2428
							
2429
							$("div .subtotal_underline").append(
2430
									'<a id="printBlocExtrafields" onclick="return false;" href="#">' + trad + '</a>'
2431
									+ '<input type="hidden" name="showBlockExtrafields" id="showBlockExtrafields" value="'+ extra +'" />');
2432
2433
							$(document).on('click', "#printBlocExtrafields", function() {
2434
								var btnShowBlock = $("#showBlockExtrafields");
2435
								var val = btnShowBlock.val();
2436
								if(val == '0') {
2437
									btnShowBlock.val('1');
2438
									$("#printBlocExtrafields").html("<?php print $langs->trans('hideExtrafields'); ?>");
2439
									$(all_tr_extrafields).show();
2440
								} else {
2441
									btnShowBlock.val('0');
2442
									$("#printBlocExtrafields").html("<?php print $langs->trans('showExtrafields'); ?>");
2443
									$(all_tr_extrafields).hide();
2444
								}
2445
							});
2446
						});
2447
					</script>
2448
					<?php
2449
				}
2450
				$line->element = $ex_element;
2451
				
2452
			}
2453
			
2454
			return 1;	
2455
			
2456
		}
2457
		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2458
		{
2459
			$colspan = 4;
2460
2461
			// HTML 5 data for js
2462
			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2463
?>
2464
			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2465
					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2466
					{
2467
						if($line->qty==99) print 'background:#adadcf';
2468
						else if($line->qty==98) print 'background:#ddddff;';
2469
						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2470
						else if($line->qty==1) print 'background:#adadcf;';
2471
						else if($line->qty==2) print 'background:#ddddff;';
2472
						else if($line->qty==50) print '';
2473
						else print 'background:#eeeeff;';
2474
2475
						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2476
					}
2477
					else
2478
					{
2479
						if($line->qty==99) print 'background:#ddffdd';
2480
						else if($line->qty==98) print 'background:#ddddff;';
2481
						else if($line->qty==2) print 'background:#eeeeff; ';
2482
						else if($line->qty==50) print '';
2483
						else print 'background:#eeffee;' ;
2484
					}
2485
2486
			?>;">
2487
2488
				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2489
2490
2491
						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2492
						 {
2493
							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2494
							{
2495
								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2496
2497
								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2498
								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2499
							}
2500
						 }
2501
						 else
2502
						 {
2503
							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2504
							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2505
						 }
2506
2507
2508
						 // Get display styles and apply them
2509
						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2510
						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2511
						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2512
2513
						 if (empty($line->label)) {
2514
							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2515
							else print  $line->description;
2516
						 }
2517
						 else {
2518
2519
							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2520
								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2521
							}
2522
							else{
2523
								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2524
							}
2525
2526
						 }
2527
						//if($line->qty>90) print ' : ';
2528
						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2529
2530
			?>
2531
				</td>
2532
				 <td colspan="<?php echo $colspan; ?>">
2533
<?php
2534
						if(in_array('expeditioncard', $contexts) && $action == 'create')
2535
						{
2536
							$fk_entrepot = GETPOST('entrepot_id', 'int');
2537
?>
2538
2539
						<input type="hidden" name="idl<?php echo $i; ?>" value="<?php echo $line->id; ?>" />
2540
						<input type="hidden" name="qtyasked<?php echo $i; ?>" value="<?php echo $line->qty; ?>" />
2541
						<input type="hidden" name="qdelivered<?php echo $i; ?>" value="0" />
2542
						<input type="hidden" name="qtyl<?php echo $i; ?>" value="<?php echo $line->qty; ?>" />
2543
						<input type="hidden" name="entl<?php echo $i; ?>" value="<?php echo $fk_entrepot; ?>" />
2544
<?php
2545
						}
2546
?>
2547
					 </td>
2548
			</tr>
2549
<?php
2550
			return 1;
2551
		}
2552
		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2553
		{
2554
			global $form;
2555
2556
			$alreadysent = $parameters['alreadysent'];
0 ignored issues
show
Unused Code introduced by
The assignment to $alreadysent is dead and can be removed.
Loading history...
2557
2558
			$shipment_static = new Expedition($db);
0 ignored issues
show
Bug introduced by
The type Expedition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Unused Code introduced by
The assignment to $shipment_static is dead and can be removed.
Loading history...
2559
			$warehousestatic = new Entrepot($db);
0 ignored issues
show
Unused Code introduced by
The assignment to $warehousestatic is dead and can be removed.
Loading history...
Bug introduced by
The type Entrepot was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
2560
			$extrafieldsline = new ExtraFields($db);
2561
			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2562
2563
			$colspan = 4;
2564
			if($object->origin && $object->origin_id > 0) $colspan++;
2565
			if(! empty($conf->stock->enabled)) $colspan++;
2566
			if(! empty($conf->productbatch->enabled)) $colspan++;
2567
			if($object->statut == 0) $colspan++;
2568
			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2569
2570
			if($object->element == 'delivery') $colspan = 2;
2571
2572
			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2573
2574
			// HTML 5 data for js
2575
			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2576
			?>
2577
			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2578
					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2579
					{
2580
						if($line->qty==99) print 'background:#adadcf';
2581
						else if($line->qty==98) print 'background:#ddddff;';
2582
						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2583
						else if($line->qty==1) print 'background:#adadcf;';
2584
						else if($line->qty==2) print 'background:#ddddff;';
2585
						else if($line->qty==50) print '';
2586
						else print 'background:#eeeeff;';
2587
2588
						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2589
					}
2590
					else 
2591
					{
2592
						if($line->qty==99) print 'background:#ddffdd';
2593
						else if($line->qty==98) print 'background:#ddddff;';
2594
						else if($line->qty==2) print 'background:#eeeeff; ';
2595
						else if($line->qty==50) print '';
2596
						else print 'background:#eeffee;' ;
2597
					}
2598
2599
			?>;">
2600
2601
			<?php
2602
			// #
2603
			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2604
			{
2605
				print '<td align="center">'.($i+1).'</td>';
2606
			}
2607
			?>
2608
2609
			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2610
2611
2612
			if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2613
			{
2614
				if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2615
				{
2616
					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2617
2618
					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2619
					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2620
				}
2621
			}
2622
			else
2623
			{
2624
				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2625
				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2626
			}
2627
2628
2629
			// Get display styles and apply them
2630
			$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2631
			$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2632
			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2633
2634
			if (empty($line->label)) {
2635
				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2636
				else print  $line->description;
2637
			}
2638
			else {
2639
				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2640
					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2641
				}
2642
				else{
2643
					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2644
				}
2645
			}
2646
			//if($line->qty>90) print ' : ';
2647
			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2648
2649
			?>
2650
				</td>
2651
				<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
2652
			<?php
2653
2654
			if ($object->element == 'shipping' && $object->statut == 0 && ! empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2655
			{
2656
				print '<td class="linecoldelete nowrap" width="10">';
2657
2658
				if ($line->fk_prev_id === null)
2659
				{
2660
					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$line->id.'">'.img_delete().'</a>';
2661
				}
2662
2663
				if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2664
				{
2665
					if ((float) DOL_VERSION >= 8.0) {
2666
						$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2667
					} elseif ((float) DOL_VERSION >= 3.8) {
2668
						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2669
					} else {
2670
						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2671
					}
2672
2673
					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=ask_deleteallline&amp;lineid='.$line->id.'">'.$img_delete.'</a>';
2674
2675
					/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2676
					 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2677
					 */
2678
					if((float) DOL_VERSION >= 8.0) {
2679
						?>
2680
							<script>
2681
								$(document).ready(function () {
2682
									$("#row-<?php echo $line->id; ?> td.linecoldelete span.fa.fa-trash.pictodeleteallline").css({"color": "#be3535"});
2683
								});
2684
							</script>
2685
							<?php
2686
					}
2687
				}
2688
2689
2690
				print '</td>';
2691
			}
2692
2693
			print "</tr>";
2694
2695
			// Display lines extrafields
2696
			if ($object->element == 'shipping' && ! empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines)>0) {
2697
				$line = new ExpeditionLigne($db);
0 ignored issues
show
Bug introduced by
The type ExpeditionLigne was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
2698
				$line->fetch_optionals($line->id);
2699
				print '<tr class="oddeven">';
2700
				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
2701
			}
2702
2703
			return 1;
2704
		}
2705
2706
		return 0;
2707
2708
	}
2709
2710
	
2711
	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
0 ignored issues
show
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2711
	function addMoreActionsButtons($parameters, &$object, &$action, /** @scrutinizer ignore-unused */ $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2711
	function addMoreActionsButtons(/** @scrutinizer ignore-unused */ $parameters, &$object, &$action, $hookmanager) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2712
		global $conf,$langs;
2713
		 
2714
		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2715
		{
2716
		    
2717
		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2718
		    {
2719
		        foreach ($object->lines as $line)
2720
		        {
2721
		            // fetch optionals attributes and labels
2722
		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
0 ignored issues
show
Bug introduced by
The constant DOL_DOCUMENT_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
2723
		            $extrafields=new ExtraFields($this->db);
2724
		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2725
		            $line->fetch_optionals($line->id,$extralabels);
2726
		        }
2727
		    }
2728
		    
2729
			$TSubNc = array();
2730
			foreach ($object->lines as &$l)
2731
			{
2732
				$TSubNc[$l->id] = (int) $l->array_options['options_subtotal_nc'];
2733
			}
2734
			
2735
			$form = new Form($db);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $db seems to be never defined.
Loading history...
2736
			?>
2737
			<script type="text/javascript">
2738
				$(function() {
2739
					var subtotal_TSubNc = <?php echo json_encode($TSubNc); ?>;
2740
					$("#tablelines tbody > tr").each(function(i, item) {
2741
						if ($(item).children('.subtotal_nc').length == 0)
2742
						{
2743
							var id = $(item).attr('id');
2744
							
2745
							if ((typeof id != 'undefined' && id.indexOf('row-') >= 0) || $(item).hasClass('liste_titre'))
2746
							{
2747
								$(item).children('td:last-child').before('<td class="subtotal_nc"></td>');
2748
								
2749
								if ($(item).attr('rel') != 'subtotal' && typeof $(item).attr('id') != 'undefined')
2750
								{
2751
									var idSplit = $(item).attr('id').split('-');
2752
									$(item).children('td.subtotal_nc').append($('<input type="checkbox" id="subtotal_nc-'+idSplit[1]+'" class="subtotal_nc_chkbx" data-lineid="'+idSplit[1]+'" value="1" '+(typeof subtotal_TSubNc[idSplit[1]] != 'undefined' && subtotal_TSubNc[idSplit[1]] == 1 ? 'checked="checked"' : '')+' />'));
2753
								}
2754
							}
2755
							else 
2756
							{
2757
								$(item).append('<td class="subtotal_nc"></td>');
2758
							}
2759
						}
2760
					});
2761
					
2762
					$('#tablelines tbody tr.liste_titre:first .subtotal_nc').html(<?php echo json_encode($form->textwithtooltip($langs->trans('subtotal_nc_title'), $langs->trans('subtotal_nc_title_help'))); ?>);
2763
					
2764
					function callAjaxUpdateLineNC(set, lineid, subtotal_nc)
2765
					{
2766
						$.ajax({
2767
							url: '<?php echo dol_buildpath('/subtotal/script/interface.php', 1); ?>'
0 ignored issues
show
Bug introduced by
The function dol_buildpath was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2767
							url: '<?php echo /** @scrutinizer ignore-call */ dol_buildpath('/subtotal/script/interface.php', 1); ?>'
Loading history...
2768
							,type: 'POST'
2769
							,data: {
2770
								json:1
2771
								,set: set
2772
								,element: '<?php echo $object->element; ?>'
2773
								,elementid: <?php echo (int) $object->id; ?>
2774
								,lineid: lineid
2775
								,subtotal_nc: subtotal_nc
2776
							}
2777
						}).done(function(response) {
2778
							window.location.href = window.location.pathname + '?id=<?php echo $object->id; ?>&page_y=' + window.pageYOffset;
2779
						});
2780
					}
2781
					
2782
					$(".subtotal_nc_chkbx").change(function(event) {
2783
						var lineid = $(this).data('lineid');
2784
						var subtotal_nc = 0 | $(this).is(':checked'); // Renvoi 0 ou 1 
2785
						
2786
						callAjaxUpdateLineNC('updateLineNC', lineid, subtotal_nc);
2787
					});
2788
					
2789
				});
2790
2791
			</script>
2792
			<?php
2793
		}
2794
		
2795
		$this->_ajax_block_order_js($object);
2796
	}
2797
	
2798
	function afterPDFCreation($parameters, &$pdf, &$action, $hookmanager)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $hookmanager is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2798
	function afterPDFCreation($parameters, &$pdf, &$action, /** @scrutinizer ignore-unused */ $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

2798
	function afterPDFCreation($parameters, &$pdf, /** @scrutinizer ignore-unused */ &$action, $hookmanager)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
2799
	{
2800
		global $conf;
2801
		
2802
		$object = $parameters['object'];
2803
		
2804
		if ((!empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP) && $object->element == 'propal') || (!empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP) && $object->element == 'commande') || (!empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP) && $object->element == 'facture'))
2805
		{
2806
			if (GETPOST('subtotal_add_recap')) {
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2806
			if (/** @scrutinizer ignore-call */ GETPOST('subtotal_add_recap')) {
Loading history...
2807
				dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2807
				/** @scrutinizer ignore-call */ 
2808
    dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
2808
				TSubtotal::addRecapPage($parameters, $pdf);
2809
			}
2810
		}
2811
	}
2812
	
2813
	// HTML 5 data for js
2814
	private function _getHtmlData($parameters, &$object, &$action, $hookmanager)
2815
	{
2816
		dol_include_once('/subtotal/class/subtotal.class.php');
0 ignored issues
show
Bug introduced by
The function dol_include_once was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2816
		/** @scrutinizer ignore-call */ 
2817
  dol_include_once('/subtotal/class/subtotal.class.php');
Loading history...
2817
2818
	    $line = &$parameters['line'];
2819
	    
2820
	    $ThtmlData['data-id']           = $line->id;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$ThtmlData was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ThtmlData = array(); before regardless.
Loading history...
2821
	    $ThtmlData['data-product_type'] = $line->product_type;
2822
	    $ThtmlData['data-qty']          = 0; //$line->qty;
2823
	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2824
	    
2825
	    if(TSubtotal::isTitle($line)){
2826
	        $ThtmlData['data-issubtotal'] = 'title';
2827
	    }elseif(TSubtotal::isSubtotal($line)){
2828
	        $ThtmlData['data-issubtotal'] = 'subtotal';
2829
	    }
2830
	    else{
2831
	        $ThtmlData['data-issubtotal'] = 'freetext';
2832
	    }
2833
	    
2834
	    
2835
	    // Change or add data  from hooks
2836
	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2837
	    
2838
	    // hook 
2839
	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2840
	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
0 ignored issues
show
Bug introduced by
The function setEventMessages was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2840
	    if ($reshook < 0) /** @scrutinizer ignore-call */ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Loading history...
2841
	    if ($reshook>0)
2842
	    {
2843
	        $ThtmlData = $hookmanager->resArray;
2844
	    }
2845
2846
	    return $this->implodeHtmlData($ThtmlData);
2847
	
2848
	}
2849
	
2850
	
2851
	function implodeHtmlData($ThtmlData = array())
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2852
	{
2853
	    $data = '';
2854
	    foreach($ThtmlData as $k => $h )
2855
	    {
2856
	        if(is_array($h))
2857
	        {
2858
	            $h = json_encode($h);
2859
	        }
2860
	        
2861
	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
0 ignored issues
show
Bug introduced by
The function dol_htmlentities was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2861
	        $data .= $k . '="'./** @scrutinizer ignore-call */ dol_htmlentities($h, ENT_QUOTES).'" ';
Loading history...
2862
	    }
2863
	    
2864
	    return $data;
2865
	}
2866
	
2867
	function _ajax_block_order_js($object)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
2868
	{
2869
	    global $conf,$tagidfortablednd,$filepath,$langs;
2870
	    
2871
	    /*
2872
	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2873
	     * for compatibility reasons we don't use tableDnD but jquery sortable
2874
	     */
2875
	    
2876
	    $id=$object->id;
0 ignored issues
show
Unused Code introduced by
The assignment to $id is dead and can be removed.
Loading history...
2877
	    $nboflines=(isset($object->lines)?count($object->lines):0);
2878
	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
0 ignored issues
show
Unused Code introduced by
The assignment to $forcereloadpage is dead and can be removed.
Loading history...
2879
	    
2880
	    $id=$object->id;
2881
	    $fk_element=$object->fk_element;
2882
	    $table_element_line=$object->table_element_line;
2883
	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2884
	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2885
	    $filepath=(empty($filepath)?'':$filepath);
2886
	    
2887
	    
2888
	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
0 ignored issues
show
Bug introduced by
The function GETPOST was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2888
	    if (/** @scrutinizer ignore-call */ GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
Loading history...
2889
	    {
2890
	        
2891
	        ?>
2892
		
2893
		
2894
			<script type="text/javascript">
2895
			$(document).ready(function(){
2896
2897
				// target some elements
2898
				var titleRow = $('tr[data-issubtotal="title"]');
2899
				var lastTitleCol = titleRow.find('td:last-child');
2900
				var moveBlockCol= titleRow.find('td.linecolht');
2901
2902
				
2903
				moveBlockCol.disableSelection(); // prevent selection
2904
<?php if ($object->statut == 0) { ?>
2905
				// apply some graphical stuff
2906
				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
0 ignored issues
show
Bug introduced by
The function dol_buildpath was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

2906
				moveBlockCol.css("background-image",'url(<?php echo /** @scrutinizer ignore-call */ dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
Loading history...
2907
				moveBlockCol.css("background-repeat","no-repeat");
2908
				moveBlockCol.css("background-position","center center");
2909
				moveBlockCol.css("cursor","move");
2910
				titleRow.attr('title', '<?php echo html_entity_decode($langs->trans('MoveTitleBlock')); ?>');
2911
			
2912
2913
 				$( "#<?php echo $tagidfortablednd; ?>" ).sortable({
2914
			    	  cursor: "move",
2915
			    	  handle: ".movetitleblock",
2916
			    	  items: 'tr:not(.nodrag,.nodrop,.noblockdrop)',
2917
			    	  delay: 150, //Needed to prevent accidental drag when trying to select
2918
			    	  opacity: 0.8,
2919
			    	  axis: "y", // limit y axis
2920
			    	  placeholder: "ui-state-highlight",
2921
			    	  start: function( event, ui ) {
2922
			    	      //console.log('X:' + e.screenX, 'Y:' + e.screenY);
2923
			    		  //console.log(ui.item);
2924
			    		  var colCount = ui.item.children().length;
2925
   						  ui.placeholder.html('<td colspan="'+colCount+'">&nbsp;</td>');
2926
   		
2927
			    		  var TcurrentChilds = getSubtotalTitleChilds(ui.item);
2928
			    		  ui.item.data('childrens',TcurrentChilds); // store data
2929
				    		
2930
			    		  for (var key in TcurrentChilds) {
2931
			    			  $('#'+ TcurrentChilds[key]).addClass('noblockdrop');//'#row-'+ 
2932
			    			  $('#'+ TcurrentChilds[key]).fadeOut();//'#row-'+ 
2933
			    		  }
2934
2935
			    		  $(this).sortable("refresh");	// "refresh" of source sortable is required to make "disable" work!
2936
			    	      
2937
			    	    },
2938
				    	stop: function (event, ui) {
2939
							// call we element is droped
2940
				    	  	$('.noblockdrop').removeClass('noblockdrop');
2941
2942
				    	  	var TcurrentChilds = ui.item.data('childrens'); // reload child list from data and not attr to prevent load error
2943
2944
							for (var i =TcurrentChilds.length ; i >= 0; i--) {
2945
				    			  $('#'+ TcurrentChilds[i]).insertAfter(ui.item); //'#row-'+ 
2946
				    			  $('#'+ TcurrentChilds[i]).fadeIn(); //'#row-'+ 
2947
							}
2948
							console.log('onstop');
2949
							console.log(cleanSerialize($(this).sortable('serialize')));
2950
							
2951
							$.ajax({
2952
			    	            data: {
2953
									objet_id: <?php print $object->id; ?>,
2954
							    	roworder: cleanSerialize($(this).sortable('serialize')),
2955
									table_element_line: "<?php echo $table_element_line; ?>",
2956
									fk_element: "<?php echo $fk_element; ?>",
2957
									element_id: "<?php echo $id; ?>",
2958
									filepath: "<?php echo urlencode($filepath); ?>"
2959
								},
2960
			    	            type: 'POST',
2961
			    	            url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/row.php',
0 ignored issues
show
Bug introduced by
The constant DOL_URL_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
2962
			    	            success: function(data) {
2963
			    	                console.log(data);
2964
			    	            },
2965
			    	        });
2966
			    	        
2967
			    	  },
2968
			    	  update: function (event, ui) {
2969
				    	  
2970
			    	        // POST to server using $.post or $.ajax
2971
				    	  	$('.noblockdrop').removeClass('noblockdrop');
2972
							//console.log('onupdate');
2973
			    	        //console.log(cleanSerialize($(this).sortable('serialize')));
2974
			    	    }
2975
			    });
2976
 				<?php } ?>
2977
2978
				function getSubtotalTitleChilds(item)
2979
				{
2980
		    		var TcurrentChilds = []; // = JSON.parse(item.attr('data-childrens'));
2981
		    		var level = item.data('level');
2982
2983
		    		var indexOfFirstSubtotal = -1;
2984
		    		var indexOfFirstTitle = -1;
2985
		    		
2986
		    		item.nextAll('[id^="row-"]').each(function(index){
2987
2988
						var dataLevel = $(this).attr('data-level');
2989
						var dataIsSubtotal = $(this).attr('data-issubtotal');
2990
						
2991
						if(dataIsSubtotal != 'undefined' && dataLevel != 'undefined' )
2992
						{
2993
2994
							if(dataLevel <=  level && indexOfFirstSubtotal < 0 && dataIsSubtotal == 'subtotal' )
2995
							{
2996
								indexOfFirstSubtotal = index;
2997
								if(indexOfFirstTitle < 0)
2998
								{
2999
									TcurrentChilds.push($(this).attr('id'));
3000
								}
3001
							}
3002
							
3003
							if(dataLevel <=  level && indexOfFirstSubtotal < 0 && indexOfFirstTitle < 0 && dataIsSubtotal == 'title' )
3004
							{
3005
								indexOfFirstTitle = index;
3006
							}
3007
						}
3008
3009
						if(indexOfFirstTitle < 0 && indexOfFirstSubtotal < 0)
3010
						{
3011
							TcurrentChilds.push($(this).attr('id'));
3012
3013
							// Add extraffield support for dolibarr > 7
3014
							var thisId = $(this).attr('data-id');
3015
							var thisElement = $(this).attr('data-element');
3016
							if(thisId != undefined && thisElement != undefined )
3017
							{
3018
								$('[data-targetid="' + thisId + '"][data-element="extrafield"][data-targetelement="'+ thisElement +'"]').each(function(index){
3019
									TcurrentChilds.push($(this).attr('id'));
3020
								});
3021
							}
3022
							
3023
						}
3024
3025
		    		});
3026
		    		return TcurrentChilds;
3027
				}
3028
				
3029
			});
3030
			</script>
3031
			<style type="text/css" >
3032
         
3033
            tr.ui-state-highlight td{
3034
            	border: 1px solid #dad55e;
3035
            	background: #fffa90;
3036
            	color: #777620;
3037
            }
3038
            </style>
3039
		<?php
3040
		
3041
		} 
3042
	
3043
		
3044
		
3045
	}
3046
	
3047
}
3048