Completed
Branch develop (b66a18)
by
unknown
14:24
created
htdocs/product/stock/productlot_note.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 
34 34
 // Get parameters
35 35
 $id = GETPOST('id', 'int');
36
-$ref        = GETPOST('ref', 'alpha');
36
+$ref = GETPOST('ref', 'alpha');
37 37
 $action = GETPOST('action', 'aZ09');
38 38
 
39 39
 // Initialize technical objects
Please login to merge, or discard this patch.
htdocs/product/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -341,9 +341,9 @@
 block discarded – undo
341 341
 				$product_static->status_buy = $objp->tobuy;
342 342
 				$product_static->status_batch = $objp->tobatch;
343 343
 
344
-				$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'read');
344
+				$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'read');
345 345
 				if ($product_static->isService()) {
346
-					$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'read');
346
+					$usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'read');
347 347
 				}
348 348
 
349 349
 				// Multilangs
Please login to merge, or discard this patch.
htdocs/bookcal/booking_card.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 // Get parameters
88 88
 $id = GETPOST('id', 'int');
89 89
 $ref = GETPOST('ref', 'alpha');
90
-$lineid   = GETPOST('lineid', 'int');
90
+$lineid = GETPOST('lineid', 'int');
91 91
 
92 92
 $action = GETPOST('action', 'aZ09');
93 93
 $confirm = GETPOST('confirm', 'alpha');
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 			}
535 535
 
536 536
 			// Clone
537
-			print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
537
+			print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&token='.newToken(), '', $permissiontoadd);
538 538
 
539 539
 			/*
540 540
 			if ($permissiontoadd) {
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,8 +97,12 @@  discard block
 block discarded – undo
97 97
 //if ($user->socid > 0) $socid = $user->socid;
98 98
 //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
99 99
 //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
100
-if (!isModEnabled('bookcal')) accessforbidden();
101
-if (!$permissiontoread) accessforbidden();
100
+if (!isModEnabled('bookcal')) {
101
+	accessforbidden();
102
+}
103
+if (!$permissiontoread) {
104
+	accessforbidden();
105
+}
102 106
 
103 107
 
104 108
 /*
@@ -434,9 +438,12 @@  discard block
 block discarded – undo
434 438
 
435 439
 				$parameters = array();
436 440
 				$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
437
-				if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
438
-				if (empty($reshook))
439
-					$object->formAddObjectLine(1, $mysoc, $soc);
441
+				if ($reshook < 0) {
442
+					setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
443
+				}
444
+				if (empty($reshook)) {
445
+									$object->formAddObjectLine(1, $mysoc, $soc);
446
+				}
440 447
 			}
441 448
 		}
442 449
 
Please login to merge, or discard this patch.
htdocs/bookcal/class/availabilities.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
103 103
 	 */
104
-	public $fields=array(
104
+	public $fields = array(
105 105
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
106 106
 		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"),
107 107
 		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 				$this->date_creation     = $this->db->jdate($obj->datec);
890 890
 				$this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
891 891
 				if (!empty($obj->datev)) {
892
-					$this->date_validation   = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
892
+					$this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
893 893
 				}
894 894
 			}
895 895
 
Please login to merge, or discard this patch.
htdocs/accountancy/bookkeeping/card.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		if ($mode != "_tmp") {
548 548
 			// Date document export
549 549
 			print '<tr>';
550
-			print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>';
550
+			print '<td class="titlefield">'.$langs->trans("DateExport").'</td>';
551 551
 			print '<td>';
552 552
 			print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
553 553
 			print '</td>';
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
 			// Date document validation
557 557
 			print '<tr>';
558
-			print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>';
558
+			print '<td class="titlefield">'.$langs->trans("DateValidation").'</td>';
559 559
 			print '<td>';
560 560
 			print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;';
561 561
 			print '</td>';
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 
613 613
 		print '<br>';
614 614
 
615
-		$result = $object->fetchAllPerMvt($piece_num, $mode);	// This load $object->linesmvt
615
+		$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
616 616
 
617 617
 		if ($result < 0) {
618 618
 			setEventMessages($object->error, $object->errors, 'errors');
@@ -708,14 +708,14 @@  discard block
 block discarded – undo
708 708
 							if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
709 709
 								print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
710 710
 							} else {
711
-								print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
711
+								print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
712 712
 							}
713
-							print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
713
+							print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
714 714
 							print '</td>';
715
-							print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $label_operation . '"/></td>';
715
+							print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
716 716
 							print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
717 717
 							print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
718
-							print '<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '"></td>';
718
+							print '<td class="center"><input type="submit" class="button small" name="save" value="'.$langs->trans("Add").'"></td>';
719 719
 						}
720 720
 					} else {
721 721
 						print '<!-- td columns in display mode -->';
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
 						print '<td class="center nowraponall">';
740 740
 						if (empty($line->date_export) && empty($line->date_validation)) {
741
-							print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">';
741
+							print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
742 742
 							print img_edit('', 0, 'class="marginrightonly"');
743 743
 							print '</a> &nbsp;';
744 744
 						} else {
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 								$actiontodelete = 'confirm_delete';
754 754
 							}
755 755
 
756
-							print '<a href="' . $_SERVER["PHP_SELF"] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">';
756
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
757 757
 							print img_delete();
758 758
 							print '</a>';
759 759
 						} else {
Please login to merge, or discard this patch.
htdocs/accountancy/supplier/list.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 $search_date_endday = GETPOST('search_date_endday', 'int');
71 71
 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
72 72
 $search_date_endyear = GETPOST('search_date_endyear', 'int');
73
-$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);	// Use tzserver
73
+$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
74 74
 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
75 75
 $search_country = GETPOST('search_country', 'alpha');
76 76
 $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
@@ -261,20 +261,20 @@  discard block
 block discarded – undo
261 261
 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
262 262
 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
263 263
 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
264
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
264
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = ".((int) $conf->entity);
265 265
 }
266 266
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
267 267
 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
268 268
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
269 269
 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
270
-	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
270
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = ".((int) $conf->entity);
271 271
 }
272 272
 $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe";
273 273
 $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe";
274
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa  ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number         AND aa.active = 1  AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
275
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number  AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
276
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
277
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number        AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity;
274
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa  ON ".$alias_product_perentity.".accountancy_code_buy = aa.account_number         AND aa.active = 1  AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
275
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON ".$alias_product_perentity.".accountancy_code_buy_intra = aa2.account_number  AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
276
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON ".$alias_product_perentity.".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
277
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON ".$alias_societe_perentity.".accountancy_code_buy = aa4.account_number        AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity;
278 278
 $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
279 279
 $sql .= " AND l.product_type <= 2";
280 280
 // Define begin binding date
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
469 469
 
470 470
 	if ($massaction == 'set_default_account') {
471
-		$formquestion[]=array('type' => 'other',
471
+		$formquestion[] = array('type' => 'other',
472 472
 				'name' => 'set_default_account',
473 473
 				'label' => $langs->trans("AccountancyCode"),
474 474
 				'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'));
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 		$thirdpartystatic->email = $objp->email;
571 571
 		$thirdpartystatic->country_code = $objp->country_code;
572 572
 		$thirdpartystatic->tva_intra = $objp->tva_intra;
573
-		$thirdpartystatic->code_compta_product = $objp->company_code_buy;		// The accounting account for product stored on thirdparty object (for level3 suggestion)
573
+		$thirdpartystatic->code_compta_product = $objp->company_code_buy; // The accounting account for product stored on thirdparty object (for level3 suggestion)
574 574
 
575 575
 		$product_static->ref = $objp->product_ref;
576 576
 		$product_static->id = $objp->product_id;
@@ -612,16 +612,16 @@  discard block
 block discarded – undo
612 612
 
613 613
 		$suggestedid = 0;
614 614
 
615
-		$return=$accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facturefourn_static, $facturefourn_static_det, $accountingAccountArray, 'supplier');
616
-		if (!is_array($return) && $return<0) {
615
+		$return = $accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facturefourn_static, $facturefourn_static_det, $accountingAccountArray, 'supplier');
616
+		if (!is_array($return) && $return < 0) {
617 617
 			setEventMessage($accountingAccount->error, 'errors');
618 618
 		} else {
619
-			$suggestedid=$return['suggestedid'];
620
-			$suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor'];
621
-			$suggestedaccountingaccountbydefaultfor=$return['suggestedaccountingaccountbydefaultfor'];
622
-			$code_buy_l=$return['code_l'];
623
-			$code_buy_p=$return['code_p'];
624
-			$code_buy_t=$return['code_t'];
619
+			$suggestedid = $return['suggestedid'];
620
+			$suggestedaccountingaccountfor = $return['suggestedaccountingaccountfor'];
621
+			$suggestedaccountingaccountbydefaultfor = $return['suggestedaccountingaccountbydefaultfor'];
622
+			$code_buy_l = $return['code_l'];
623
+			$code_buy_p = $return['code_p'];
624
+			$code_buy_t = $return['code_t'];
625 625
 		}
626 626
 		//var_dump($return);
627 627
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 		//if ($objp->vat_tx_l != $objp->vat_tx_p && price2num($objp->vat_tx_p) && price2num($objp->vat_tx_l)) {	// Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export
694 694
 		//	$code_vat_differ = 'warning bold';
695 695
 		//}
696
-		print '<td class="right'.($code_vat_differ?' '.$code_vat_differ:'').'">';
696
+		print '<td class="right'.($code_vat_differ ? ' '.$code_vat_differ : '').'">';
697 697
 		print vatrate($facturefourn_static_det->tva_tx.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : ''), false, 0, 0, 1);
698 698
 		print '</td>';
699 699
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		if (!empty($toselect)) {
768 768
 			$ischecked = 0;
769 769
 			if (in_array($objp->rowid."_".$i, $toselect)) {
770
-				$ischecked=1;
770
+				$ischecked = 1;
771 771
 			}
772 772
 		}
773 773
 
Please login to merge, or discard this patch.
htdocs/accountancy/expensereport/lines.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 $search_date_endday = GETPOST('search_date_endday', 'int');
56 56
 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
57 57
 $search_date_endyear = GETPOST('search_date_endyear', 'int');
58
-$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);	// Use tzserver
58
+$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
59 59
 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
60 60
 
61 61
 // Load variable for pagination
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		$i++;
429 429
 	}
430 430
 	if ($num_lines == 0) {
431
-		$colspan=10;
431
+		$colspan = 10;
432 432
 		if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
433 433
 			$colspan++;
434 434
 		}
Please login to merge, or discard this patch.
htdocs/accountancy/class/lettering.class.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 		$lettre = 'AAA';
292 292
 
293 293
 		$sql = "SELECT DISTINCT ab2.lettering_code";
294
-		$sql .=	" FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
295
-		$sql .=	" LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account";
296
-		$sql .=	" WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")";
297
-		$sql .=	" AND ab2.lettering_code != ''";
298
-		$sql .=	" ORDER BY ab2.lettering_code DESC";
299
-		$sql .=	" LIMIT 1 ";
294
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab";
295
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab2 ON ab2.subledger_account = ab.subledger_account";
296
+		$sql .= " WHERE ab.rowid IN (".$this->db->sanitize(implode(',', $ids)).")";
297
+		$sql .= " AND ab2.lettering_code != ''";
298
+		$sql .= " ORDER BY ab2.lettering_code DESC";
299
+		$sql .= " LIMIT 1 ";
300 300
 
301 301
 		$resqla = $this->db->query($sql);
302 302
 		if ($resqla) {
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	public function bookkeepingLetteringAll($bookkeeping_ids, $unlettering = false)
402 402
 	{
403
-		dol_syslog(__METHOD__ . " - ", LOG_DEBUG);
403
+		dol_syslog(__METHOD__." - ", LOG_DEBUG);
404 404
 
405 405
 		$error = 0;
406 406
 		$errors = array();
@@ -517,25 +517,25 @@  discard block
 block discarded – undo
517 517
 
518 518
 		// Get all bookkeeping lines
519 519
 		$sql = "SELECT DISTINCT ab.doc_type, ab.fk_doc";
520
-		$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
521
-		$sql .= " WHERE ab.entity IN (" . getEntity('accountancy') . ")";
520
+		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab";
521
+		$sql .= " WHERE ab.entity IN (".getEntity('accountancy').")";
522 522
 		$sql .= " AND ab.fk_doc > 0";
523 523
 		if (!empty($bookkeeping_ids)) {
524 524
 			// Get all bookkeeping lines of piece number
525 525
 			$sql .= " AND EXISTS (";
526 526
 			$sql .= "  SELECT rowid";
527
-			$sql .= "  FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS pn";
528
-			$sql .= "  WHERE pn.entity IN (" . getEntity('accountancy') . ")";
529
-			$sql .= "  AND pn.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")";
527
+			$sql .= "  FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS pn";
528
+			$sql .= "  WHERE pn.entity IN (".getEntity('accountancy').")";
529
+			$sql .= "  AND pn.rowid IN (".$this->db->sanitize(implode(',', $bookkeeping_ids)).")";
530 530
 			$sql .= "  AND pn.piece_num = ab.piece_num";
531 531
 			$sql .= " )";
532 532
 		}
533 533
 		if ($only_has_subledger_account) $sql .= " AND ab.subledger_account != ''";
534 534
 
535
-		dol_syslog(__METHOD__ . " - Get all bookkeeping lines", LOG_DEBUG);
535
+		dol_syslog(__METHOD__." - Get all bookkeeping lines", LOG_DEBUG);
536 536
 		$resql = $this->db->query($sql);
537 537
 		if (!$resql) {
538
-			$this->errors[] = "Error " . $this->db->lasterror();
538
+			$this->errors[] = "Error ".$this->db->lasterror();
539 539
 			return -1;
540 540
 		}
541 541
 
@@ -582,34 +582,34 @@  discard block
 block discarded – undo
582 582
 
583 583
 				// Get all bookkeeping lines linked
584 584
 				$sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.debit, ab.credit, ab.lettering_code";
585
-				$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab";
586
-				$sql .= " WHERE ab.entity IN (" . getEntity('accountancy') . ")";
585
+				$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS ab";
586
+				$sql .= " WHERE ab.entity IN (".getEntity('accountancy').")";
587 587
 				$sql .= " AND (";
588 588
 				if (!empty($bank_ids)) {
589 589
 					$sql .= " EXISTS (";
590 590
 					$sql .= "  SELECT bpn.rowid";
591
-					$sql .= "  FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS bpn";
592
-					$sql .= "  WHERE bpn.entity IN (" . getEntity('accountancy') . ")";
591
+					$sql .= "  FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS bpn";
592
+					$sql .= "  WHERE bpn.entity IN (".getEntity('accountancy').")";
593 593
 					$sql .= "  AND bpn.doc_type = 'bank'";
594
-					$sql .= "  AND bpn.fk_doc IN (" . $this->db->sanitize(implode(',', $bank_ids)) . ")";
594
+					$sql .= "  AND bpn.fk_doc IN (".$this->db->sanitize(implode(',', $bank_ids)).")";
595 595
 					$sql .= "  AND bpn.piece_num = ab.piece_num";
596 596
 					$sql .= " ) OR ";
597 597
 				}
598 598
 				$sql .= " EXISTS (";
599 599
 				$sql .= "  SELECT dpn.rowid";
600
-				$sql .= "  FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS dpn";
601
-				$sql .= "  WHERE dpn.entity IN (" . getEntity('accountancy') . ")";
602
-				$sql .= "  AND dpn.doc_type = '" . $this->db->escape($doc_type) . "'";
603
-				$sql .= "  AND dpn.fk_doc IN (" . $this->db->sanitize(implode(',', $doc_ids)) . ")";
600
+				$sql .= "  FROM ".MAIN_DB_PREFIX."accounting_bookkeeping AS dpn";
601
+				$sql .= "  WHERE dpn.entity IN (".getEntity('accountancy').")";
602
+				$sql .= "  AND dpn.doc_type = '".$this->db->escape($doc_type)."'";
603
+				$sql .= "  AND dpn.fk_doc IN (".$this->db->sanitize(implode(',', $doc_ids)).")";
604 604
 				$sql .= "  AND dpn.piece_num = ab.piece_num";
605 605
 				$sql .= " )";
606 606
 				$sql .= ")";
607 607
 				if ($only_has_subledger_account) $sql .= " AND ab.subledger_account != ''";
608 608
 
609
-				dol_syslog(__METHOD__ . " - Get all bookkeeping lines linked", LOG_DEBUG);
609
+				dol_syslog(__METHOD__." - Get all bookkeeping lines linked", LOG_DEBUG);
610 610
 				$resql = $this->db->query($sql);
611 611
 				if (!$resql) {
612
-					$this->errors[] = "Error " . $this->db->lasterror();
612
+					$this->errors[] = "Error ".$this->db->lasterror();
613 613
 					return -1;
614 614
 				}
615 615
 
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 */
641 641
 	public function getDocTypeAndFkDocFromBankLines($bank_ids)
642 642
 	{
643
-		dol_syslog(__METHOD__ . " - bank_ids=".json_encode($bank_ids), LOG_DEBUG);
643
+		dol_syslog(__METHOD__." - bank_ids=".json_encode($bank_ids), LOG_DEBUG);
644 644
 
645 645
 		// Clean parameters
646 646
 		$bank_ids = is_array($bank_ids) ? $bank_ids : array();
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 		$bookkeeping_lines_by_type = array();
653 653
 		foreach (self::$doc_type_infos as $doc_type => $doc_type_info) {
654 654
 			// Get all fk_doc by doc_type from bank ids
655
-			$sql = "SELECT DISTINCT dp." . $doc_type_info['doc_payment_table_fk_doc'] . " AS fk_doc";
656
-			$sql .= " FROM " . MAIN_DB_PREFIX . $doc_type_info['payment_table'] . " AS p";
657
-			$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $doc_type_info['doc_payment_table'] . " AS dp ON dp." . $doc_type_info['doc_payment_table_fk_payment'] . " = p.rowid";
658
-			$sql .= " WHERE p." . $doc_type_info['payment_table_fk_bank'] . " IN (" . $this->db->sanitize(implode(',', $bank_ids)) . ")";
659
-			$sql .= " AND dp." . $doc_type_info['doc_payment_table_fk_doc'] . " > 0";
655
+			$sql = "SELECT DISTINCT dp.".$doc_type_info['doc_payment_table_fk_doc']." AS fk_doc";
656
+			$sql .= " FROM ".MAIN_DB_PREFIX.$doc_type_info['payment_table']." AS p";
657
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$doc_type_info['doc_payment_table']." AS dp ON dp.".$doc_type_info['doc_payment_table_fk_payment']." = p.rowid";
658
+			$sql .= " WHERE p.".$doc_type_info['payment_table_fk_bank']." IN (".$this->db->sanitize(implode(',', $bank_ids)).")";
659
+			$sql .= " AND dp.".$doc_type_info['doc_payment_table_fk_doc']." > 0";
660 660
 
661
-			dol_syslog(__METHOD__ . " - Get all fk_doc by doc_type from list of bank ids for '" . $doc_type . "'", LOG_DEBUG);
661
+			dol_syslog(__METHOD__." - Get all fk_doc by doc_type from list of bank ids for '".$doc_type."'", LOG_DEBUG);
662 662
 			$resql = $this->db->query($sql);
663 663
 			if (!$resql) {
664
-				$this->errors[] = "Error " . $this->db->lasterror();
664
+				$this->errors[] = "Error ".$this->db->lasterror();
665 665
 				return -1;
666 666
 			}
667 667
 
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 	{
686 686
 		global $langs;
687 687
 
688
-		dol_syslog(__METHOD__ . " - bank_ids=".json_encode($document_ids) . ", doc_type=$doc_type", LOG_DEBUG);
688
+		dol_syslog(__METHOD__." - bank_ids=".json_encode($document_ids).", doc_type=$doc_type", LOG_DEBUG);
689 689
 
690 690
 		// Clean parameters
691 691
 		$document_ids = is_array($document_ids) ? $document_ids : array();
@@ -704,16 +704,16 @@  discard block
 block discarded – undo
704 704
 		$bank_ids = array();
705 705
 
706 706
 		// Get all fk_doc by doc_type from bank ids
707
-		$sql = "SELECT DISTINCT p." . $doc_type_info['payment_table_fk_bank'] . " AS fk_doc";
708
-		$sql .= " FROM " . MAIN_DB_PREFIX . $doc_type_info['payment_table'] . " AS p";
709
-		$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $doc_type_info['doc_payment_table'] . " AS dp ON dp." . $doc_type_info['doc_payment_table_fk_payment'] . " = p.rowid";
710
-		$sql .= " WHERE dp." . $doc_type_info['doc_payment_table_fk_doc'] . " IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")";
711
-		$sql .= " AND p." . $doc_type_info['payment_table_fk_bank'] . " > 0";
707
+		$sql = "SELECT DISTINCT p.".$doc_type_info['payment_table_fk_bank']." AS fk_doc";
708
+		$sql .= " FROM ".MAIN_DB_PREFIX.$doc_type_info['payment_table']." AS p";
709
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$doc_type_info['doc_payment_table']." AS dp ON dp.".$doc_type_info['doc_payment_table_fk_payment']." = p.rowid";
710
+		$sql .= " WHERE dp.".$doc_type_info['doc_payment_table_fk_doc']." IN (".$this->db->sanitize(implode(',', $document_ids)).")";
711
+		$sql .= " AND p.".$doc_type_info['payment_table_fk_bank']." > 0";
712 712
 
713
-		dol_syslog(__METHOD__ . " - Get all bank ids from list of document ids of a type '" . $doc_type . "'", LOG_DEBUG);
713
+		dol_syslog(__METHOD__." - Get all bank ids from list of document ids of a type '".$doc_type."'", LOG_DEBUG);
714 714
 		$resql = $this->db->query($sql);
715 715
 		if (!$resql) {
716
-			$this->errors[] = "Error " . $this->db->lasterror();
716
+			$this->errors[] = "Error ".$this->db->lasterror();
717 717
 			return -1;
718 718
 		}
719 719
 
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 		$link_by_element = array();
757 757
 		$element_by_link = array();
758 758
 		foreach ($doc_type_info['linked_info'] as $linked_info) {
759
-			$sql = "SELECT DISTINCT tl2." . $linked_info['fk_link'] . " AS fk_link, tl2." . $linked_info['fk_doc'] . " AS fk_doc";
760
-			$sql .= " FROM " . MAIN_DB_PREFIX . $linked_info['table'] . " AS tl";
761
-			$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $linked_info['table'] . " AS tl2 ON tl2." . $linked_info['fk_link'] . " = tl." . $linked_info['fk_link'];
762
-			$sql .= " WHERE tl." . $linked_info['fk_doc'] . " IN (" . $this->db->sanitize(implode(',', $document_ids)) . ")";
759
+			$sql = "SELECT DISTINCT tl2.".$linked_info['fk_link']." AS fk_link, tl2.".$linked_info['fk_doc']." AS fk_doc";
760
+			$sql .= " FROM ".MAIN_DB_PREFIX.$linked_info['table']." AS tl";
761
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$linked_info['table']." AS tl2 ON tl2.".$linked_info['fk_link']." = tl.".$linked_info['fk_link'];
762
+			$sql .= " WHERE tl.".$linked_info['fk_doc']." IN (".$this->db->sanitize(implode(',', $document_ids)).")";
763 763
 
764
-			dol_syslog(__METHOD__ . " - Get document lines", LOG_DEBUG);
764
+			dol_syslog(__METHOD__." - Get document lines", LOG_DEBUG);
765 765
 			$resql = $this->db->query($sql);
766 766
 			if (!$resql) {
767
-				$this->errors[] = "Error " . $this->db->lasterror();
767
+				$this->errors[] = "Error ".$this->db->lasterror();
768 768
 				return -1;
769 769
 			}
770 770
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 			while ($obj = $this->db->fetch_object($resql)) {
773 773
 				$current_document_ids[$obj->fk_doc] = $obj->fk_doc;
774 774
 
775
-				$link_key = $linked_info['prefix'] . $obj->fk_link;
775
+				$link_key = $linked_info['prefix'].$obj->fk_link;
776 776
 				$element_by_link[$link_key][$obj->fk_doc] = $obj->fk_doc;
777 777
 				$link_by_element[$obj->fk_doc][$link_key] = $link_key;
778 778
 				if ($is_fk_link_is_also_fk_doc) {
Please login to merge, or discard this patch.
Braces   +26 added lines, -9 removed lines patch added patch discarded remove patch
@@ -468,9 +468,15 @@  discard block
 block discarded – undo
468 468
 						$group_error++;
469 469
 						break;
470 470
 					}
471
-					if (!isset($lettering_code)) $lettering_code = (string) $line_infos['lettering_code'];
472
-					if (!empty($line_infos['lettering_code'])) $do_it = true;
473
-				} elseif (!empty($line_infos['lettering_code'])) $do_it = false;
471
+					if (!isset($lettering_code)) {
472
+						$lettering_code = (string) $line_infos['lettering_code'];
473
+					}
474
+					if (!empty($line_infos['lettering_code'])) {
475
+						$do_it = true;
476
+					}
477
+				} elseif (!empty($line_infos['lettering_code'])) {
478
+					$do_it = false;
479
+				}
474 480
 			}
475 481
 
476 482
 			// Check balance amount
@@ -481,8 +487,11 @@  discard block
 block discarded – undo
481 487
 
482 488
 			// Lettering/Unlettering the group of bookkeeping lines
483 489
 			if (!$group_error && $do_it) {
484
-				if ($unlettering) $result = $this->deleteLettering($bookkeeping_lines);
485
-				else $result = $this->updateLettering($bookkeeping_lines);
490
+				if ($unlettering) {
491
+					$result = $this->deleteLettering($bookkeeping_lines);
492
+				} else {
493
+					$result = $this->updateLettering($bookkeeping_lines);
494
+				}
486 495
 				if ($result < 0) {
487 496
 					$group_error++;
488 497
 				} elseif ($result > 0) {
@@ -533,7 +542,9 @@  discard block
 block discarded – undo
533 542
 			$sql .= "  AND pn.piece_num = ab.piece_num";
534 543
 			$sql .= " )";
535 544
 		}
536
-		if ($only_has_subledger_account) $sql .= " AND ab.subledger_account != ''";
545
+		if ($only_has_subledger_account) {
546
+			$sql .= " AND ab.subledger_account != ''";
547
+		}
537 548
 
538 549
 		dol_syslog(__METHOD__ . " - Get all bookkeeping lines", LOG_DEBUG);
539 550
 		$resql = $this->db->query($sql);
@@ -607,7 +618,9 @@  discard block
 block discarded – undo
607 618
 				$sql .= "  AND dpn.piece_num = ab.piece_num";
608 619
 				$sql .= " )";
609 620
 				$sql .= ")";
610
-				if ($only_has_subledger_account) $sql .= " AND ab.subledger_account != ''";
621
+				if ($only_has_subledger_account) {
622
+					$sql .= " AND ab.subledger_account != ''";
623
+				}
611 624
 
612 625
 				dol_syslog(__METHOD__ . " - Get all bookkeeping lines linked", LOG_DEBUG);
613 626
 				$resql = $this->db->query($sql);
@@ -628,7 +641,9 @@  discard block
 block discarded – undo
628 641
 				}
629 642
 				$this->db->free($resql);
630 643
 
631
-				if (!empty($group)) $grouped_lines[] = $group;
644
+				if (!empty($group)) {
645
+					$grouped_lines[] = $group;
646
+				}
632 647
 			}
633 648
 		}
634 649
 
@@ -830,7 +845,9 @@  discard block
 block discarded – undo
830 845
 
831 846
 			foreach ($element_ids as $element_id) {
832 847
 				// Continue if element id in not found
833
-				if (!isset($link_by_element[$element_id])) continue;
848
+				if (!isset($link_by_element[$element_id])) {
849
+					continue;
850
+				}
834 851
 
835 852
 				// Set the element in the current group
836 853
 				$current_group[$element_id] = $element_id;
Please login to merge, or discard this patch.
htdocs/fichinter/stats/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -288,7 +288,7 @@
 block discarded – undo
288 288
 	print '<tr class="oddeven" height="24">';
289 289
 	print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
290 290
 	print '<td class="right">'.$val['nb'].'</td>';
291
-	print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%</td>';
291
+	print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']) : "0").'%</td>';
292 292
 	print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
293 293
 	print '<td class="right opacitylow" style="'.((!isset($val['total_diff']) || $val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%</td>';
294 294
 	print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
Please login to merge, or discard this patch.