Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/htdocs/expedition/document.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
33 33
 require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35
-require_once DOL_DOCUMENT_ROOT .'/expedition/class/expedition.class.php';
36
-if (! empty($conf->projet->enabled)) {
37
-	require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
35
+require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
36
+if (!empty($conf->projet->enabled)) {
37
+	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38 38
 }
39 39
 
40 40
 // Load translation files required by the page
41 41
 $langs->loadLangs(array('companies', 'other'));
42 42
 
43
-$action		= GETPOST('action','aZ09');
43
+$action		= GETPOST('action', 'aZ09');
44 44
 $confirm	= GETPOST('confirm');
45
-$id			= GETPOST('id','int');
45
+$id			= GETPOST('id', 'int');
46 46
 $ref		= GETPOST('ref');
47 47
 
48 48
 // Security check
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 {
51 51
 	$socid = $user->societe_id;
52 52
 }
53
-$result=restrictedArea($user,'expedition',$id,'');
53
+$result = restrictedArea($user, 'expedition', $id, '');
54 54
 
55 55
 // Get parameters
56
-$sortfield = GETPOST("sortfield",'alpha');
57
-$sortorder = GETPOST("sortorder",'alpha');
58
-$page = GETPOST("page",'int');
56
+$sortfield = GETPOST("sortfield", 'alpha');
57
+$sortorder = GETPOST("sortorder", 'alpha');
58
+$page = GETPOST("page", 'int');
59 59
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
60 60
 $offset = $conf->liste_limit * $page;
61 61
 $pageprev = $page - 1;
62 62
 $pagenext = $page + 1;
63
-if (! $sortorder) $sortorder="ASC";
64
-if (! $sortfield) $sortfield="name";
63
+if (!$sortorder) $sortorder = "ASC";
64
+if (!$sortfield) $sortfield = "name";
65 65
 
66 66
 $object = new Expedition($db);
67 67
 
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
72 72
 if ($object->fetch($id))
73 73
 {
74 74
 	$object->fetch_thirdparty();
75
-	$upload_dir = $conf->expedition->dir_output . "/sending/" . dol_sanitizeFileName($object->ref);
75
+	$upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref);
76 76
 }
77 77
 
78
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
78
+include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
79 79
 
80 80
 
81 81
 /*
82 82
  * View
83 83
  */
84 84
 
85
-llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
85
+llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
86 86
 
87 87
 $form = new Form($db);
88 88
 
89
-if ($id > 0 || ! empty($ref)){
90
-	if ($object->fetch($id, $ref)){
89
+if ($id > 0 || !empty($ref)) {
90
+	if ($object->fetch($id, $ref)) {
91 91
 		$object->fetch_thirdparty();
92 92
 
93 93
 		$upload_dir = $conf->expedition->dir_output.'/sending/'.dol_sanitizeFileName($object->ref);
@@ -97,50 +97,50 @@  discard block
 block discarded – undo
97 97
 	
98 98
 
99 99
 		// Build file list
100
-		$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
101
-		$totalsize=0;
102
-		foreach($filearray as $key => $file){
103
-		    $totalsize+=$file['size'];
100
+		$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
101
+		$totalsize = 0;
102
+		foreach ($filearray as $key => $file) {
103
+		    $totalsize += $file['size'];
104 104
 		}
105 105
 
106 106
 		// Shipment card
107
-		$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
107
+		$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
108 108
 
109 109
 
110
-		$morehtmlref='<div class="refidno">';
110
+		$morehtmlref = '<div class="refidno">';
111 111
 		// Ref customer
112
-		$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
113
-		$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
112
+		$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
113
+		$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
114 114
 		// Thirdparty
115
-		$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
115
+		$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
116 116
 
117 117
 		// Project
118
-		if (! empty($conf->projet->enabled)) {
118
+		if (!empty($conf->projet->enabled)) {
119 119
 			$langs->load("projects");
120
-			$morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
120
+			$morehtmlref .= '<br>'.$langs->trans('Project').' ';
121 121
 			if (0) {    // Do not change on shipment
122 122
 				if ($action != 'classify') {
123
-					$morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
123
+					$morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
124 124
 				}
125 125
 				if ($action == 'classify') {
126 126
 					// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
127
-					$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
127
+					$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
128 128
 					$morehtmlref .= '<input type="hidden" name="action" value="classin">';
129
-					$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
129
+					$morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
130 130
 					$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
131
-					$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
131
+					$morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
132 132
 					$morehtmlref .= '</form>';
133 133
 				} else {
134
-					$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
134
+					$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
135 135
 				}
136 136
 			} else {
137 137
 				// We don't have project on shipment, so we will use the project or source object instead
138 138
 				// TODO Add project on shipment
139 139
 				$morehtmlref .= ' : ';
140
-				if (! empty($objectsrc->fk_project)) {
140
+				if (!empty($objectsrc->fk_project)) {
141 141
 					$proj = new Project($db);
142 142
 					$proj->fetch($objectsrc->fk_project);
143
-					$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
143
+					$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">';
144 144
 					$morehtmlref .= $proj->ref;
145 145
 					$morehtmlref .= '</a>';
146 146
 				} else {
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 				}
149 149
 			}
150 150
 		}
151
-		$morehtmlref.='</div>';
151
+		$morehtmlref .= '</div>';
152 152
 
153 153
 		// Order card
154 154
 
155
-		$linkback = '<a href="' . DOL_URL_ROOT . '/expedition/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
155
+		$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
156 156
 
157 157
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
158 158
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		print '<table class="border" width="100%">';
163 163
 
164 164
 		print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
165
-		print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>';
165
+		print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
166 166
 
167 167
 		print "</table>\n";
168 168
 
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 		$modulepart = 'expedition';
174 174
 		$permission = $user->rights->expedition->creer;
175 175
 		$permtoedit = $user->rights->expedition->creer;
176
-		$param = '&id=' . $object->id;
177
-		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
176
+		$param = '&id='.$object->id;
177
+		include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
178 178
 	}
179
-	else{
179
+	else {
180 180
 		dol_print_error($db);
181 181
 	}
182 182
 }
183
-else{
183
+else {
184 184
 	header('Location: index.php');
185 185
 	exit;
186 186
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/note.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 require '../main.inc.php';
28 28
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
30
-if (! empty($conf->projet->enabled)) {
30
+if (!empty($conf->projet->enabled)) {
31 31
     require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
32 32
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
33 33
 }
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 // Load translation files required by the page
36 36
 $langs->loadLangs(array('sendings', 'companies', 'bills', 'deliveries', 'orders', 'stocks', 'other', 'propal'));
37 37
 
38
-$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int'));  // For backward compatibility
39
-$ref=GETPOST('ref','alpha');
40
-$action=GETPOST('action','alpha');
38
+$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
39
+$ref = GETPOST('ref', 'alpha');
40
+$action = GETPOST('action', 'alpha');
41 41
 
42 42
 // Security check
43
-$socid='';
44
-if ($user->societe_id) $socid=$user->societe_id;
45
-$result=restrictedArea($user, $origin, $origin_id);
43
+$socid = '';
44
+if ($user->societe_id) $socid = $user->societe_id;
45
+$result = restrictedArea($user, $origin, $origin_id);
46 46
 
47 47
 $object = new Expedition($db);
48
-if ($id > 0 || ! empty($ref))
48
+if ($id > 0 || !empty($ref))
49 49
 {
50 50
     $object->fetch($id, $ref);
51 51
     $object->fetch_thirdparty();
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
     }
59 59
 
60 60
     // Linked documents
61
-    if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
61
+    if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
62 62
     {
63
-        $objectsrc=new Commande($db);
63
+        $objectsrc = new Commande($db);
64 64
         $objectsrc->fetch($object->$typeobject->id);
65 65
     }
66
-    if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
66
+    if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
67 67
     {
68
-        $objectsrc=new Propal($db);
68
+        $objectsrc = new Propal($db);
69 69
         $objectsrc->fetch($object->$typeobject->id);
70 70
     }
71 71
 }
72 72
 
73
-$permissionnote=$user->rights->expedition->creer;	// Used by the include of actions_setnotes.inc.php
73
+$permissionnote = $user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php
74 74
 
75 75
 
76 76
 /*
77 77
  * Actions
78 78
  */
79 79
 
80
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';	// Must be include, not includ_once
80
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
81 81
 
82 82
 
83 83
 /*
@@ -88,49 +88,49 @@  discard block
 block discarded – undo
88 88
 
89 89
 $form = new Form($db);
90 90
 
91
-if ($id > 0 || ! empty($ref))
91
+if ($id > 0 || !empty($ref))
92 92
 {
93 93
 
94
-	$head=shipping_prepare_head($object);
94
+	$head = shipping_prepare_head($object);
95 95
 	dol_fiche_head($head, 'note', $langs->trans("Shipment"), -1, 'sending');
96 96
 
97 97
 
98 98
 	// Shipment card
99
-	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
99
+	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
100 100
 
101
-	$morehtmlref='<div class="refidno">';
101
+	$morehtmlref = '<div class="refidno">';
102 102
 	// Ref customer shipment
103
-	$morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
104
-	$morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
103
+	$morehtmlref .= $form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
104
+	$morehtmlref .= $form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
105 105
 	// Thirdparty
106
-	$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
106
+	$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
107 107
     // Project
108
-    if (! empty($conf->projet->enabled)) {
108
+    if (!empty($conf->projet->enabled)) {
109 109
         $langs->load("projects");
110
-        $morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
110
+        $morehtmlref .= '<br>'.$langs->trans('Project').' ';
111 111
         if (0) {    // Do not change on shipment
112 112
             if ($action != 'classify') {
113
-                $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
113
+                $morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
114 114
             }
115 115
             if ($action == 'classify') {
116 116
                 // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
117
-                $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
117
+                $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
118 118
                 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
119
-                $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
119
+                $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120 120
                 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
121
-                $morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
121
+                $morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
122 122
                 $morehtmlref .= '</form>';
123 123
             } else {
124
-                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
124
+                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
125 125
             }
126 126
         } else {
127 127
             // We don't have project on shipment, so we will use the project or source object instead
128 128
             // TODO Add project on shipment
129 129
             $morehtmlref .= ' : ';
130
-            if (! empty($objectsrc->fk_project)) {
130
+            if (!empty($objectsrc->fk_project)) {
131 131
                 $proj = new Project($db);
132 132
                 $proj->fetch($objectsrc->fk_project);
133
-                $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
133
+                $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">';
134 134
                 $morehtmlref .= $proj->ref;
135 135
                 $morehtmlref .= '</a>';
136 136
             } else {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             }
139 139
         }
140 140
     }
141
-    $morehtmlref.='</div>';
141
+    $morehtmlref .= '</div>';
142 142
 
143 143
 
144 144
     dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     print '<div class="underbanner clearboth"></div>';
148 148
 
149
-	$cssclass='titlefield';
149
+	$cssclass = 'titlefield';
150 150
 	include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
151 151
 
152 152
 	dol_fiche_end();
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/index.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
  *	View
35 35
  */
36 36
 
37
-$orderstatic=new Commande($db);
38
-$companystatic=new Societe($db);
39
-$shipment=new Expedition($db);
37
+$orderstatic = new Commande($db);
38
+$companystatic = new Societe($db);
39
+$shipment = new Expedition($db);
40 40
 
41
-$helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
42
-llxHeader('',$langs->trans("Shipment"),$helpurl);
41
+$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
42
+llxHeader('', $langs->trans("Shipment"), $helpurl);
43 43
 
44 44
 print load_fiche_titre($langs->trans("SendingsArea"));
45 45
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 print '<div class="fichecenter"><div class="fichethirdleft">';
48 48
 
49 49
 
50
-if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
50
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is useless due to the global search combo
51 51
 {
52 52
     print '<form method="post" action="list.php">';
53 53
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -64,23 +64,23 @@  discard block
 block discarded – undo
64 64
 $clause = " WHERE ";
65 65
 
66 66
 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
67
-$sql.= " s.nom as name, s.rowid as socid,";
68
-$sql.= " c.ref as commande_ref, c.rowid as commande_id";
69
-$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
70
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
71
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
72
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
67
+$sql .= " s.nom as name, s.rowid as socid,";
68
+$sql .= " c.ref as commande_ref, c.rowid as commande_id";
69
+$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
70
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
71
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
72
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
73 73
 if (!$user->rights->societe->client->voir && !$socid)
74 74
 {
75
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
76
-	$sql.= $clause." sc.fk_user = " .$user->id;
75
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
76
+	$sql .= $clause." sc.fk_user = ".$user->id;
77 77
 	$clause = " AND ";
78 78
 }
79
-$sql.= $clause." e.fk_statut = 0";
80
-$sql.= " AND e.entity IN (".getEntity('expedition').")";
81
-if ($socid) $sql.= " AND c.fk_soc = ".$socid;
79
+$sql .= $clause." e.fk_statut = 0";
80
+$sql .= " AND e.entity IN (".getEntity('expedition').")";
81
+if ($socid) $sql .= " AND c.fk_soc = ".$socid;
82 82
 
83
-$resql=$db->query($sql);
83
+$resql = $db->query($sql);
84 84
 if ($resql)
85 85
 {
86 86
 	$num = $db->num_rows($resql);
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 		{
95 95
 			$obj = $db->fetch_object($resql);
96 96
 
97
-			$shipment->id=$obj->rowid;
98
-			$shipment->ref=$obj->ref;
99
-			$shipment->ref_customer=$obj->ref_customer;
97
+			$shipment->id = $obj->rowid;
98
+			$shipment->ref = $obj->ref;
99
+			$shipment->ref_customer = $obj->ref_customer;
100 100
 
101 101
 			print '<tr class="oddeven"><td class="nowrap">';
102 102
 			print $shipment->getNomUrl(1);
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
  * Commandes a traiter
119 119
  */
120 120
 $sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut, s.nom as name, s.rowid as socid";
121
-$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
122
-$sql.= " ".MAIN_DB_PREFIX."societe as s";
123
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
124
-$sql.= " WHERE c.fk_soc = s.rowid";
125
-$sql.= " AND c.entity = ".$conf->entity;
126
-$sql.= " AND c.fk_statut = 1";
127
-if ($socid) $sql.= " AND c.fk_soc = ".$socid;
128
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
129
-$sql.= " ORDER BY c.rowid ASC";
130
-
131
-$resql=$db->query($sql);
121
+$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
122
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
123
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
124
+$sql .= " WHERE c.fk_soc = s.rowid";
125
+$sql .= " AND c.entity = ".$conf->entity;
126
+$sql .= " AND c.fk_statut = 1";
127
+if ($socid) $sql .= " AND c.fk_soc = ".$socid;
128
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
129
+$sql .= " ORDER BY c.rowid ASC";
130
+
131
+$resql = $db->query($sql);
132 132
 if ($resql)
133 133
 {
134 134
 	$num = $db->num_rows($resql);
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 		{
145 145
 			$obj = $db->fetch_object($resql);
146 146
 
147
-			$orderstatic->id=$obj->rowid;
148
-			$orderstatic->ref=$obj->ref;
149
-			$orderstatic->ref_customer=$obj->ref_customer;
150
-			$orderstatic->statut=$obj->fk_statut;
151
-			$orderstatic->billed=0;
147
+			$orderstatic->id = $obj->rowid;
148
+			$orderstatic->ref = $obj->ref;
149
+			$orderstatic->ref_customer = $obj->ref_customer;
150
+			$orderstatic->statut = $obj->fk_statut;
151
+			$orderstatic->billed = 0;
152 152
 
153
-			$companystatic->name=$obj->name;
154
-			$companystatic->id=$obj->socid;
153
+			$companystatic->name = $obj->name;
154
+			$companystatic->id = $obj->socid;
155 155
 
156 156
 			print '<tr class="oddeven">';
157 157
 			print '<td class="nowrap">';
158 158
 			print $orderstatic->getNomUrl(1);
159 159
 			print '</td>';
160 160
 			print '<td>';
161
-			print $companystatic->getNomUrl(1,'customer',32);
161
+			print $companystatic->getNomUrl(1, 'customer', 32);
162 162
 			print '</td>';
163 163
 			print '<td align="right">';
164 164
 			print $orderstatic->getLibStatut(3);
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
  * Commandes en traitement
180 180
  */
181 181
 $sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid";
182
-$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
183
-$sql.= " ".MAIN_DB_PREFIX."societe as s";
184
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
185
-$sql.= " WHERE c.fk_soc = s.rowid";
186
-$sql.= " AND c.entity = ".$conf->entity;
187
-$sql.= " AND c.fk_statut = 2";
188
-if ($socid) $sql.= " AND c.fk_soc = ".$socid;
189
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
182
+$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
183
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
184
+if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
185
+$sql .= " WHERE c.fk_soc = s.rowid";
186
+$sql .= " AND c.entity = ".$conf->entity;
187
+$sql .= " AND c.fk_statut = 2";
188
+if ($socid) $sql .= " AND c.fk_soc = ".$socid;
189
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
190 190
 
191 191
 $resql = $db->query($sql);
192
-if ( $resql )
192
+if ($resql)
193 193
 {
194 194
 	$langs->load("orders");
195 195
 
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
 		{
205 205
 			$obj = $db->fetch_object($resql);
206 206
 
207
-		    $orderstatic->id=$obj->rowid;
208
-			$orderstatic->ref=$obj->ref;
209
-			$orderstatic->ref_customer=$obj->ref_customer;
210
-			$orderstatic->statut=$obj->status;
211
-            $orderstatic->billed=$obj->billed;
207
+		    $orderstatic->id = $obj->rowid;
208
+			$orderstatic->ref = $obj->ref;
209
+			$orderstatic->ref_customer = $obj->ref_customer;
210
+			$orderstatic->statut = $obj->status;
211
+            $orderstatic->billed = $obj->billed;
212 212
 
213
-            $companystatic->name=$obj->name;
214
-			$companystatic->id=$obj->socid;
213
+            $companystatic->name = $obj->name;
214
+			$companystatic->id = $obj->socid;
215 215
 
216 216
 			print '<tr class="oddeven"><td>';
217 217
 			print $orderstatic->getNomUrl(1);
218 218
 			print '</td>';
219 219
 			print '<td>';
220
-			print $companystatic->getNomUrl(1,'customer');
220
+			print $companystatic->getNomUrl(1, 'customer');
221 221
 			print '</td>';
222 222
             print '<td align="right">';
223 223
             print $orderstatic->getLibStatut(3);
@@ -235,19 +235,19 @@  discard block
 block discarded – undo
235 235
  * Last shipments
236 236
  */
237 237
 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
238
-$sql.= " s.nom as name, s.rowid as socid,";
239
-$sql.= " c.ref as commande_ref, c.rowid as commande_id";
240
-$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
241
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
242
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
243
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
244
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
245
-$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
246
-if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
247
-$sql.= " AND e.fk_statut = 1";
248
-if ($socid) $sql.= " AND c.fk_soc = ".$socid;
249
-$sql.= " ORDER BY e.date_delivery DESC";
250
-$sql.= $db->plimit(5, 0);
238
+$sql .= " s.nom as name, s.rowid as socid,";
239
+$sql .= " c.ref as commande_ref, c.rowid as commande_id";
240
+$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
241
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
242
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
243
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
244
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
245
+$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
246
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
247
+$sql .= " AND e.fk_statut = 1";
248
+if ($socid) $sql .= " AND c.fk_soc = ".$socid;
249
+$sql .= " ORDER BY e.date_delivery DESC";
250
+$sql .= $db->plimit(5, 0);
251 251
 
252 252
 $resql = $db->query($sql);
253 253
 if ($resql)
@@ -263,19 +263,19 @@  discard block
 block discarded – undo
263 263
 		{
264 264
 			$obj = $db->fetch_object($resql);
265 265
 
266
-			$shipment->id=$obj->rowid;
267
-			$shipment->ref=$obj->ref;
268
-			$shipment->ref_customer=$obj->ref_customer;
266
+			$shipment->id = $obj->rowid;
267
+			$shipment->ref = $obj->ref;
268
+			$shipment->ref_customer = $obj->ref_customer;
269 269
 
270 270
 			print '<tr class="oddeven"><td>';
271 271
 			print $shipment->getNomUrl(1);
272 272
 			print '</td>';
273
-			print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
273
+			print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
274 274
 			print '<td>';
275 275
 			if ($obj->commande_id > 0)
276 276
 			{
277
-				$orderstatic->id=$obj->commande_id;
278
-				$orderstatic->ref=$obj->commande_ref;
277
+				$orderstatic->id = $obj->commande_id;
278
+				$orderstatic->ref = $obj->commande_ref;
279 279
 				print $orderstatic->getNomUrl(1);
280 280
 			}
281 281
 			else print '&nbsp;';
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/contact.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32
-if (! empty($conf->projet->enabled)) {
32
+if (!empty($conf->projet->enabled)) {
33 33
     require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 34
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
35 35
 }
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 // Load translation files required by the page
38 38
 $langs->loadLangs(array('orders', 'sendings', 'companies'));
39 39
 
40
-$id=GETPOST('id','int');
41
-$ref=GETPOST('ref','alpha');
42
-$action=GETPOST('action','alpha');
40
+$id = GETPOST('id', 'int');
41
+$ref = GETPOST('ref', 'alpha');
42
+$action = GETPOST('action', 'alpha');
43 43
 
44 44
 // Security check
45
-if ($user->societe_id) $socid=$user->societe_id;
46
-$result = restrictedArea($user, 'expedition', $id,'');
45
+if ($user->societe_id) $socid = $user->societe_id;
46
+$result = restrictedArea($user, 'expedition', $id, '');
47 47
 
48 48
 $object = new Expedition($db);
49
-if ($id > 0 || ! empty($ref))
49
+if ($id > 0 || !empty($ref))
50 50
 {
51 51
     $object->fetch($id, $ref);
52 52
     $object->fetch_thirdparty();
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
     }
60 60
 
61 61
     // Linked documents
62
-    if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
62
+    if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
63 63
     {
64
-        $objectsrc=new Commande($db);
64
+        $objectsrc = new Commande($db);
65 65
         $objectsrc->fetch($object->$typeobject->id);
66 66
     }
67
-    if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
67
+    if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
68 68
     {
69
-        $objectsrc=new Propal($db);
69
+        $objectsrc = new Propal($db);
70 70
         $objectsrc->fetch($object->$typeobject->id);
71 71
     }
72 72
 }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 // bascule du statut d'un contact
106 106
 else if ($action == 'swapstatut' && $user->rights->expedition->creer)
107 107
 {
108
-    $result=$objectsrc->swapContactStatus(GETPOST('ligne'));
108
+    $result = $objectsrc->swapContactStatus(GETPOST('ligne'));
109 109
 }
110 110
 
111 111
 // Efface un contact
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
  * View
136 136
  */
137 137
 
138
-llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
138
+llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes');
139 139
 
140 140
 $form = new Form($db);
141 141
 $formcompany = new FormCompany($db);
142 142
 $formother = new FormOther($db);
143
-$contactstatic=new Contact($db);
144
-$userstatic=new User($db);
143
+$contactstatic = new Contact($db);
144
+$userstatic = new User($db);
145 145
 
146 146
 
147 147
 /* *************************************************************************** */
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 /*                                                                             */
151 151
 /* *************************************************************************** */
152 152
 
153
-if ($id > 0 || ! empty($ref))
153
+if ($id > 0 || !empty($ref))
154 154
 {
155 155
 	$langs->trans("OrderCard");
156 156
 
@@ -159,41 +159,41 @@  discard block
 block discarded – undo
159 159
 
160 160
 
161 161
 	// Shipment card
162
-	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">'.$langs->trans("BackToList").'</a>';
162
+	$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
163 163
 
164
-	$morehtmlref='<div class="refidno">';
164
+	$morehtmlref = '<div class="refidno">';
165 165
 	// Ref customer shipment
166
-	$morehtmlref.=$form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
167
-	$morehtmlref.=$form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
166
+	$morehtmlref .= $form->editfieldkey("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1);
167
+	$morehtmlref .= $form->editfieldval("RefCustomer", '', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
168 168
 	// Thirdparty
169
-    $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
169
+    $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
170 170
     // Project
171
-    if (! empty($conf->projet->enabled)) {
171
+    if (!empty($conf->projet->enabled)) {
172 172
         $langs->load("projects");
173
-        $morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
173
+        $morehtmlref .= '<br>'.$langs->trans('Project').' ';
174 174
         if (0) {    // Do not change on shipment
175 175
             if ($action != 'classify') {
176
-                $morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
176
+                $morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
177 177
             }
178 178
             if ($action == 'classify') {
179 179
                 // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
180
-                $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '">';
180
+                $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
181 181
                 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
182
-                $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
182
+                $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
183 183
                 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
184
-                $morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
184
+                $morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
185 185
                 $morehtmlref .= '</form>';
186 186
             } else {
187
-                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
187
+                $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
188 188
             }
189 189
         } else {
190 190
             // We don't have project on shipment, so we will use the project or source object instead
191 191
             // TODO Add project on shipment
192 192
             $morehtmlref .= ' : ';
193
-            if (! empty($objectsrc->fk_project)) {
193
+            if (!empty($objectsrc->fk_project)) {
194 194
                 $proj = new Project($db);
195 195
                 $proj->fetch($objectsrc->fk_project);
196
-                $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
196
+                $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">';
197 197
                 $morehtmlref .= $proj->ref;
198 198
                 $morehtmlref .= '</a>';
199 199
             } else {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             }
202 202
         }
203 203
     }
204
-	$morehtmlref.='</div>';
204
+	$morehtmlref .= '</div>';
205 205
 
206 206
 
207 207
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -214,25 +214,25 @@  discard block
 block discarded – undo
214 214
     print '<table class="border centpercent">';
215 215
 
216 216
     // Linked documents
217
-	if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
217
+	if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
218 218
 	{
219 219
 	    print '<tr><td class="titlefield">';
220
-	    $objectsrc=new Commande($db);
220
+	    $objectsrc = new Commande($db);
221 221
 	    $objectsrc->fetch($object->$typeobject->id);
222 222
 	    print $langs->trans("RefOrder").'</td>';
223 223
 	    print '<td colspan="3">';
224
-	    print $objectsrc->getNomUrl(1,'commande');
224
+	    print $objectsrc->getNomUrl(1, 'commande');
225 225
 	    print "</td>\n";
226 226
 	    print '</tr>';
227 227
 	}
228
-	if ($typeobject == 'propal' && $object->$typeobject->id && ! empty($conf->propal->enabled))
228
+	if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled))
229 229
 	{
230 230
 	    print '<tr><td class="titlefield">';
231
-	    $objectsrc=new Propal($db);
231
+	    $objectsrc = new Propal($db);
232 232
 	    $objectsrc->fetch($object->$typeobject->id);
233 233
 	    print $langs->trans("RefProposal").'</td>';
234 234
 	    print '<td colspan="3">';
235
-	    print $objectsrc->getNomUrl(1,'expedition');
235
+	    print $objectsrc->getNomUrl(1, 'expedition');
236 236
 	    print "</td>\n";
237 237
 	    print '</tr>';
238 238
 	}
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	echo '<br>';
260 260
 
261 261
 	// Contacts lines (modules that overwrite templates must declare this into descriptor)
262
-	$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
263
-	foreach($dirtpls as $reldir)
262
+	$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
263
+	foreach ($dirtpls as $reldir)
264 264
 	{
265
-	    $res=@include dol_buildpath($reldir.'/contacts.tpl.php');
265
+	    $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
266 266
 	    if ($res) break;
267 267
 	}
268 268
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/list.php 1 patch
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -31,43 +31,43 @@  discard block
 block discarded – undo
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32 32
 
33 33
 // Load translation files required by the page
34
-$langs->loadLangs(array("sendings","deliveries",'companies','bills'));
34
+$langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills'));
35 35
 
36
-$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'shipmentlist';   // To manage different context of search
36
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search
37 37
 
38
-$socid=GETPOST('socid','int');
38
+$socid = GETPOST('socid', 'int');
39 39
 // Security check
40
-$expeditionid = GETPOST('id','int');
41
-if ($user->societe_id) $socid=$user->societe_id;
42
-$result = restrictedArea($user, 'expedition',$expeditionid,'');
40
+$expeditionid = GETPOST('id', 'int');
41
+if ($user->societe_id) $socid = $user->societe_id;
42
+$result = restrictedArea($user, 'expedition', $expeditionid, '');
43 43
 
44
-$diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
44
+$diroutputmassaction = $conf->expedition->dir_output.'/temp/massgeneration/'.$user->id;
45 45
 
46 46
 $search_ref_exp = GETPOST("search_ref_exp", 'alpha');
47 47
 $search_ref_liv = GETPOST('search_ref_liv', 'alpha');
48 48
 $search_ref_customer = GETPOST('search_ref_customer', 'alpha');
49 49
 $search_company = GETPOST("search_company", 'alpha');
50
-$search_town=GETPOST('search_town','alpha');
51
-$search_zip=GETPOST('search_zip','alpha');
52
-$search_state=trim(GETPOST("search_state"));
53
-$search_country=GETPOST("search_country",'int');
54
-$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
55
-$search_billed=GETPOST("search_billed",'int');
56
-$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
57
-$optioncss = GETPOST('optioncss','alpha');
58
-
59
-$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
60
-$sortfield = GETPOST('sortfield','alpha');
61
-$sortorder = GETPOST('sortorder','alpha');
62
-$page = GETPOST('page','int');
63
-if (! $sortfield) $sortfield="e.ref";
64
-if (! $sortorder) $sortorder="DESC";
50
+$search_town = GETPOST('search_town', 'alpha');
51
+$search_zip = GETPOST('search_zip', 'alpha');
52
+$search_state = trim(GETPOST("search_state"));
53
+$search_country = GETPOST("search_country", 'int');
54
+$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
55
+$search_billed = GETPOST("search_billed", 'int');
56
+$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
57
+$optioncss = GETPOST('optioncss', 'alpha');
58
+
59
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
60
+$sortfield = GETPOST('sortfield', 'alpha');
61
+$sortorder = GETPOST('sortorder', 'alpha');
62
+$page = GETPOST('page', 'int');
63
+if (!$sortfield) $sortfield = "e.ref";
64
+if (!$sortorder) $sortorder = "DESC";
65 65
 if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
66 66
 $offset = $limit * $page;
67 67
 $pageprev = $page - 1;
68 68
 $pagenext = $page + 1;
69 69
 
70
-$viewstatut=GETPOST('viewstatut');
70
+$viewstatut = GETPOST('viewstatut');
71 71
 
72 72
 $object = new Expedition($db);
73 73
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 // fetch optionals attributes and labels
79 79
 $extralabels = $extrafields->fetch_name_optionals_label('expedition');
80
-$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
80
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
81 81
 
82 82
 // List of fields to search into when doing a "search in all"
83 83
 $fieldstosearchall = array(
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 	's.nom'=>"ThirdParty",
86 86
 	'e.note_public'=>'NotePublic',
87 87
 );
88
-if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate";
88
+if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate";
89 89
 
90
-$checkedtypetiers=0;
91
-$arrayfields=array(
90
+$checkedtypetiers = 0;
91
+$arrayfields = array(
92 92
 	'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
93 93
 	'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
94 94
 	's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 	'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
102 102
 	'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
103 103
 	'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
104
-	'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
105
-	'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)),
104
+	'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)),
105
+	'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)),
106 106
 	'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
107 107
 );
108 108
 
109 109
 // Extra fields
110 110
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
111 111
 {
112
-	foreach($extrafields->attribute_label as $key => $val)
112
+	foreach ($extrafields->attribute_label as $key => $val)
113 113
 	{
114
-		if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
114
+		if (!empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key]) != 3 && $extrafields->attribute_perms[$key]));
115 115
 	}
116 116
 }
117 117
 
@@ -120,46 +120,46 @@  discard block
 block discarded – undo
120 120
  * Actions
121 121
  */
122 122
 
123
-if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
124
-if (! GETPOST('confirmmassaction','alpha')) { $massaction=''; }
123
+if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
124
+if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
125 125
 
126
-$parameters=array('socid'=>$socid);
127
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
126
+$parameters = array('socid'=>$socid);
127
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
128 128
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
129 129
 
130 130
 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
131 131
 
132 132
 // Purge search criteria
133
-if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
133
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
134 134
 {
135
-	$search_ref_exp='';
136
-	$search_ref_liv='';
137
-	$search_ref_customer='';
138
-	$search_company='';
139
-	$search_town='';
140
-	$search_zip="";
141
-	$search_state="";
142
-	$search_type='';
143
-	$search_country='';
144
-	$search_type_thirdparty='';
145
-	$search_billed='';
146
-	$viewstatut='';
147
-	$search_array_options=array();
135
+	$search_ref_exp = '';
136
+	$search_ref_liv = '';
137
+	$search_ref_customer = '';
138
+	$search_company = '';
139
+	$search_town = '';
140
+	$search_zip = "";
141
+	$search_state = "";
142
+	$search_type = '';
143
+	$search_country = '';
144
+	$search_type_thirdparty = '';
145
+	$search_billed = '';
146
+	$viewstatut = '';
147
+	$search_array_options = array();
148 148
 }
149 149
 
150 150
 if (empty($reshook))
151 151
 {
152 152
 	// Mass actions. Controls on number of lines checked
153
-	$maxformassaction=1000;
154
-	$numtoselect = (is_array($toselect)?count($toselect):0);
155
-	if (! empty($massaction) && $numtoselect < 1)
153
+	$maxformassaction = 1000;
154
+	$numtoselect = (is_array($toselect) ?count($toselect) : 0);
155
+	if (!empty($massaction) && $numtoselect < 1)
156 156
 	{
157 157
 		$error++;
158 158
 		setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
159 159
 	}
160
-	if (! $error && $numtoselect > $maxformassaction)
160
+	if (!$error && $numtoselect > $maxformassaction)
161 161
 	{
162
-		setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
162
+		setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
163 163
 		$error++;
164 164
 	}
165 165
 }
@@ -171,55 +171,55 @@  discard block
 block discarded – undo
171 171
  * View
172 172
  */
173 173
 
174
-$form=new Form($db);
175
-$companystatic=new Societe($db);
176
-$shipment=new Expedition($db);
177
-$formcompany=new FormCompany($db);
174
+$form = new Form($db);
175
+$companystatic = new Societe($db);
176
+$shipment = new Expedition($db);
177
+$formcompany = new FormCompany($db);
178 178
 
179
-$helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
180
-llxHeader('',$langs->trans('ListOfSendings'),$helpurl);
179
+$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
180
+llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
181 181
 
182 182
 $sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
183
-$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
184
-$sql.= " typent.code as typent_code,";
185
-$sql.= " state.code_departement as state_code, state.nom as state_name,";
186
-$sql.= ' e.date_creation as date_creation, e.tms as date_update';
183
+$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
184
+$sql .= " typent.code as typent_code,";
185
+$sql .= " state.code_departement as state_code, state.nom as state_name,";
186
+$sql .= ' e.date_creation as date_creation, e.tms as date_update';
187 187
 // Add fields from extrafields
188
-foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
188
+foreach ($extrafields->attribute_label as $key => $val) $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
189 189
 // Add fields from hooks
190
-$parameters=array();
191
-$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters);    // Note that $action and $object may have been modified by hook
192
-$sql.=$hookmanager->resPrint;
193
-$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
194
-if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
195
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
196
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
197
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
198
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
199
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
200
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
190
+$parameters = array();
191
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
192
+$sql .= $hookmanager->resPrint;
193
+$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
194
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expedition_extrafields as ef on (e.rowid = ef.fk_object)";
195
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
196
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
197
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
198
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
199
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
200
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target";
201 201
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
202 202
 {
203
-	$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
203
+	$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
204 204
 }
205
-$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
205
+$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
206 206
 if (!$user->rights->societe->client->voir && !$socid)	// Internal user with no permission to see all
207 207
 {
208
-	$sql.= " AND e.fk_soc = sc.fk_soc";
209
-	$sql.= " AND sc.fk_user = " .$user->id;
208
+	$sql .= " AND e.fk_soc = sc.fk_soc";
209
+	$sql .= " AND sc.fk_user = ".$user->id;
210 210
 }
211 211
 if ($socid)
212 212
 {
213
-	$sql.= " AND e.fk_soc = ".$socid;
213
+	$sql .= " AND e.fk_soc = ".$socid;
214 214
 }
215 215
 if ($viewstatut <> '' && $viewstatut >= 0) {
216
-	$sql.= " AND e.fk_statut = ".$viewstatut;
216
+	$sql .= " AND e.fk_statut = ".$viewstatut;
217 217
 }
218
-if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer);
219
-if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed;
220
-if ($search_town)  $sql.= natural_search('s.town', $search_town);
221
-if ($search_zip)   $sql.= natural_search("s.zip",$search_zip);
222
-if ($search_state) $sql.= natural_search("state.nom",$search_state);
218
+if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer);
219
+if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed;
220
+if ($search_town)  $sql .= natural_search('s.town', $search_town);
221
+if ($search_zip)   $sql .= natural_search("s.zip", $search_zip);
222
+if ($search_state) $sql .= natural_search("state.nom", $search_state);
223 223
 if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
224 224
 if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
225 225
 if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
232 232
 
233 233
 // Add where from hooks
234
-$parameters=array();
235
-$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters);    // Note that $action and $object may have been modified by hook
236
-$sql.=$hookmanager->resPrint;
234
+$parameters = array();
235
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
236
+$sql .= $hookmanager->resPrint;
237 237
 
238
-$sql.= $db->order($sortfield,$sortorder);
238
+$sql .= $db->order($sortfield, $sortorder);
239 239
 
240 240
 $nbtotalofrecords = '';
241 241
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -249,39 +249,39 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 }
251 251
 
252
-$sql.= $db->plimit($limit + 1,$offset);
252
+$sql .= $db->plimit($limit + 1, $offset);
253 253
 
254 254
 //print $sql;
255
-$resql=$db->query($sql);
255
+$resql = $db->query($sql);
256 256
 if ($resql)
257 257
 {
258 258
 	$num = $db->num_rows($resql);
259 259
 
260 260
 	$expedition = new Expedition($db);
261 261
 
262
-	$param='';
263
-	if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
264
-	if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
265
-	if ($sall) $param.= "&amp;sall=".urlencode($sall);
266
-	if ($search_ref_exp)  $param.= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267
-	if ($search_ref_liv)  $param.= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268
-	if ($search_ref_customer) $param.= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269
-	if ($search_company)   $param.= "&amp;search_company=".urlencode($search_company);
270
-	if ($search_town)      $param.= '&search_town='.urlencode($search_town);
271
-	if ($search_zip)       $param.= '&search_zip='.urlencode($search_zip);
272
-	if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut);
273
-	if ($optioncss != '')  $param.='&amp;optioncss='.urlencode($optioncss);
262
+	$param = '';
263
+	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
264
+	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
265
+	if ($sall) $param .= "&amp;sall=".urlencode($sall);
266
+	if ($search_ref_exp)  $param .= "&amp;search_ref_exp=".urlencode($search_ref_exp);
267
+	if ($search_ref_liv)  $param .= "&amp;search_ref_liv=".urlencode($search_ref_liv);
268
+	if ($search_ref_customer) $param .= "&amp;search_ref_customer=".urlencode($search_ref_customer);
269
+	if ($search_company)   $param .= "&amp;search_company=".urlencode($search_company);
270
+	if ($search_town)      $param .= '&search_town='.urlencode($search_town);
271
+	if ($search_zip)       $param .= '&search_zip='.urlencode($search_zip);
272
+	if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut);
273
+	if ($optioncss != '')  $param .= '&amp;optioncss='.urlencode($optioncss);
274 274
 	// Add $param from extra fields
275 275
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
276 276
 
277 277
 	//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
278 278
 
279
-	$newcardbutton='';
279
+	$newcardbutton = '';
280 280
 	if ($user->rights->expedition->creer)
281 281
 	{
282
-		$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
283
-		$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
284
-		$newcardbutton.= '</a>';
282
+		$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/expedition/card.php?action=create2"><span class="valignmiddle">'.$langs->trans('NewSending').'</span>';
283
+		$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
284
+		$newcardbutton .= '</a>';
285 285
 	}
286 286
 
287 287
 	$i = 0;
@@ -294,92 +294,92 @@  discard block
 block discarded – undo
294 294
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
295 295
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
296 296
 
297
-	print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
297
+	print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
298 298
 
299 299
 	if ($sall)
300 300
 	{
301
-		foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
302
-		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
301
+		foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
302
+		print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
303 303
 	}
304 304
 
305
-	$moreforfilter='';
306
-	if (! empty($moreforfilter))
305
+	$moreforfilter = '';
306
+	if (!empty($moreforfilter))
307 307
 	{
308 308
 		print '<div class="liste_titre liste_titre_bydiv centpercent">';
309 309
 		print $moreforfilter;
310
-		$parameters=array('type'=>$type);
311
-		$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters);    // Note that $action and $object may have been modified by hook
310
+		$parameters = array('type'=>$type);
311
+		$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
312 312
 		print $hookmanager->resPrint;
313 313
 		print '</div>';
314 314
 	}
315 315
 
316
-	$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
317
-	$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);	// This also change content of $arrayfields
316
+	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
317
+	$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
318 318
 
319 319
 	print '<div class="div-table-responsive">';
320
-	print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
320
+	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
321 321
 
322 322
 	// Lignes des champs de filtre
323 323
 	print '<tr class="liste_titre_filter">';
324 324
 	// Ref
325
-	if (! empty($arrayfields['e.ref']['checked']))
325
+	if (!empty($arrayfields['e.ref']['checked']))
326 326
 	{
327 327
 		print '<td class="liste_titre">';
328 328
 		print '<input class="flat" size="6" type="text" name="search_ref_exp" value="'.$search_ref_exp.'">';
329 329
 		print '</td>';
330 330
 	}
331 331
 	// Ref customer
332
-	if (! empty($arrayfields['e.ref_customer']['checked']))
332
+	if (!empty($arrayfields['e.ref_customer']['checked']))
333 333
 	{
334 334
 		print '<td class="liste_titre">';
335 335
 		print '<input class="flat" size="6" type="text" name="search_ref_customer" value="'.$search_ref_customer.'">';
336 336
 		print '</td>';
337 337
 	}
338 338
 	// Thirdparty
339
-	if (! empty($arrayfields['s.nom']['checked']))
339
+	if (!empty($arrayfields['s.nom']['checked']))
340 340
 	{
341 341
 		print '<td class="liste_titre" align="left">';
342 342
 		print '<input class="flat" type="text" size="8" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
343 343
 		print '</td>';
344 344
 	}
345 345
 	// Town
346
-	if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
346
+	if (!empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
347 347
 	// Zip
348
-	if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
348
+	if (!empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
349 349
 	// State
350
-	if (! empty($arrayfields['state.nom']['checked']))
350
+	if (!empty($arrayfields['state.nom']['checked']))
351 351
 	{
352 352
 		print '<td class="liste_titre">';
353 353
 		print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
354 354
 		print '</td>';
355 355
 	}
356 356
 	// Country
357
-	if (! empty($arrayfields['country.code_iso']['checked']))
357
+	if (!empty($arrayfields['country.code_iso']['checked']))
358 358
 	{
359 359
 		print '<td class="liste_titre" align="center">';
360
-		print $form->select_country($search_country,'search_country','',0,'maxwidth100');
360
+		print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth100');
361 361
 		print '</td>';
362 362
 	}
363 363
 	// Company type
364
-	if (! empty($arrayfields['typent.code']['checked']))
364
+	if (!empty($arrayfields['typent.code']['checked']))
365 365
 	{
366 366
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
367
-		print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
367
+		print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
368 368
 		print '</td>';
369 369
 	}
370 370
 	// Date delivery planned
371
-	if (! empty($arrayfields['e.date_delivery']['checked']))
371
+	if (!empty($arrayfields['e.date_delivery']['checked']))
372 372
 	{
373 373
 		print '<td class="liste_titre">&nbsp;</td>';
374 374
 	}
375
-	if (! empty($arrayfields['l.ref']['checked']))
375
+	if (!empty($arrayfields['l.ref']['checked']))
376 376
 	{
377 377
 		// Delivery ref
378 378
 		print '<td class="liste_titre">';
379 379
 		print '<input class="flat" size="10" type="text" name="search_ref_liv" value="'.$search_ref_liv.'"';
380 380
 		print '</td>';
381 381
 	}
382
-	if (! empty($arrayfields['l.date_delivery']['checked']))
382
+	if (!empty($arrayfields['l.date_delivery']['checked']))
383 383
 	{
384 384
 		// Date received
385 385
 		print '<td class="liste_titre">&nbsp;</td>';
@@ -388,30 +388,30 @@  discard block
 block discarded – undo
388 388
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
389 389
 
390 390
 	// Fields from hook
391
-	$parameters=array('arrayfields'=>$arrayfields);
392
-	$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters);    // Note that $action and $object may have been modified by hook
391
+	$parameters = array('arrayfields'=>$arrayfields);
392
+	$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
393 393
 	print $hookmanager->resPrint;
394 394
 	// Date creation
395
-	if (! empty($arrayfields['e.datec']['checked']))
395
+	if (!empty($arrayfields['e.datec']['checked']))
396 396
 	{
397 397
 		print '<td class="liste_titre">';
398 398
 		print '</td>';
399 399
 	}
400 400
 	// Date modification
401
-	if (! empty($arrayfields['e.tms']['checked']))
401
+	if (!empty($arrayfields['e.tms']['checked']))
402 402
 	{
403 403
 		print '<td class="liste_titre">';
404 404
 		print '</td>';
405 405
 	}
406 406
 	// Status
407
-	if (! empty($arrayfields['e.fk_statut']['checked']))
407
+	if (!empty($arrayfields['e.fk_statut']['checked']))
408 408
 	{
409 409
 		print '<td class="liste_titre maxwidthonsmartphone" align="right">';
410
-		print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1);
410
+		print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1);
411 411
 		print '</td>';
412 412
 	}
413 413
 	// Status billed
414
-	if (! empty($arrayfields['e.billed']['checked']))
414
+	if (!empty($arrayfields['e.billed']['checked']))
415 415
 	{
416 416
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
417 417
 		print $form->selectyesno('search_billed', $search_billed, 1, 0, 1);
@@ -419,136 +419,136 @@  discard block
 block discarded – undo
419 419
 	}
420 420
 	// Action column
421 421
 	print '<td class="liste_titre" align="middle">';
422
-	$searchpicto=$form->showFilterAndCheckAddButtons(0);
422
+	$searchpicto = $form->showFilterAndCheckAddButtons(0);
423 423
 	print $searchpicto;
424 424
 	print '</td>';
425 425
 	print "</tr>\n";
426 426
 
427 427
 	print '<tr class="liste_titre">';
428
-	if (! empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
429
-	if (! empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"],"e.ref_customer","",$param,'',$sortfield,$sortorder);
430
-	if (! empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
431
-	if (! empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
432
-	if (! empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
433
-	if (! empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
434
-	if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
435
-	if (! empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
436
-	if (! empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
437
-	if (! empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"],"l.ref","",$param, '',$sortfield,$sortorder);
438
-	if (! empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"],"l.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
428
+	if (!empty($arrayfields['e.ref']['checked']))            print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder);
429
+	if (!empty($arrayfields['e.ref_customer']['checked']))   print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder);
430
+	if (!empty($arrayfields['s.nom']['checked']))            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, 'align="left"', $sortfield, $sortorder);
431
+	if (!empty($arrayfields['s.town']['checked']))           print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder);
432
+	if (!empty($arrayfields['s.zip']['checked']))            print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder);
433
+	if (!empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
434
+	if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
435
+	if (!empty($arrayfields['typent.code']['checked']))      print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
436
+	if (!empty($arrayfields['e.date_delivery']['checked']))  print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, 'align="center"', $sortfield, $sortorder);
437
+	if (!empty($arrayfields['l.ref']['checked']))            print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
438
+	if (!empty($arrayfields['l.date_delivery']['checked']))  print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, 'align="center"', $sortfield, $sortorder);
439 439
 	// Extra fields
440 440
 	if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
441 441
 	{
442
-		foreach($extrafields->attribute_label as $key => $val)
442
+		foreach ($extrafields->attribute_label as $key => $val)
443 443
 		{
444
-			if (! empty($arrayfields["ef.".$key]['checked']))
444
+			if (!empty($arrayfields["ef.".$key]['checked']))
445 445
 			{
446
-				$align=$extrafields->getAlignFlag($key);
446
+				$align = $extrafields->getAlignFlag($key);
447 447
 				$sortonfield = "ef.".$key;
448
-				if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
449
-				print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
448
+				if (!empty($extrafields->attribute_computed[$key])) $sortonfield = '';
449
+				print_liste_field_titre($extralabels[$key], $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder);
450 450
 			}
451 451
 		}
452 452
 	}
453 453
 	// Hook fields
454
-	$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
455
-	$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters);    // Note that $action and $object may have been modified by hook
454
+	$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
455
+	$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
456 456
 	print $hookmanager->resPrint;
457
-	if (! empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'],$_SERVER["PHP_SELF"],"e.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
458
-	if (! empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'],$_SERVER["PHP_SELF"],"e.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
459
-	if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'],$_SERVER["PHP_SELF"],"e.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
460
-	if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'],$_SERVER["PHP_SELF"],"e.billed","",$param,'align="center"',$sortfield,$sortorder);
461
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
457
+	if (!empty($arrayfields['e.datec']['checked']))  print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
458
+	if (!empty($arrayfields['e.tms']['checked']))    print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
459
+	if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder);
460
+	if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, 'align="center"', $sortfield, $sortorder);
461
+	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
462 462
 	print "</tr>\n";
463 463
 
464
-	$i=0;
465
-	$totalarray=array();
466
-	while ($i < min($num,$limit))
464
+	$i = 0;
465
+	$totalarray = array();
466
+	while ($i < min($num, $limit))
467 467
 	{
468 468
 		$obj = $db->fetch_object($resql);
469 469
 
470
-		$shipment->id=$obj->rowid;
471
-		$shipment->ref=$obj->ref;
470
+		$shipment->id = $obj->rowid;
471
+		$shipment->ref = $obj->ref;
472 472
 
473
-		$companystatic->id=$obj->socid;
474
-		$companystatic->ref=$obj->name;
475
-		$companystatic->name=$obj->name;
473
+		$companystatic->id = $obj->socid;
474
+		$companystatic->ref = $obj->name;
475
+		$companystatic->name = $obj->name;
476 476
 
477 477
 
478 478
 		print '<tr class="oddeven">';
479 479
 
480 480
 		// Ref
481
-		if (! empty($arrayfields['e.ref']['checked']))
481
+		if (!empty($arrayfields['e.ref']['checked']))
482 482
 		{
483 483
 			print "<td>";
484 484
 			print $shipment->getNomUrl(1);
485 485
 			print "</td>\n";
486
-			if (! $i) $totalarray['nbfield']++;
486
+			if (!$i) $totalarray['nbfield']++;
487 487
 		}
488 488
 
489 489
 		// Ref customer
490
-		if (! empty($arrayfields['e.ref_customer']['checked']))
490
+		if (!empty($arrayfields['e.ref_customer']['checked']))
491 491
 		{
492 492
 			print "<td>";
493 493
 			print $obj->ref_customer;
494 494
 			print "</td>\n";
495
-			if (! $i) $totalarray['nbfield']++;
495
+			if (!$i) $totalarray['nbfield']++;
496 496
 		}
497 497
 
498 498
 		// Third party
499
-		if (! empty($arrayfields['s.nom']['checked']))
499
+		if (!empty($arrayfields['s.nom']['checked']))
500 500
 		{
501 501
 			print '<td>';
502 502
 			print $companystatic->getNomUrl(1);
503 503
 			print '</td>';
504
-			if (! $i) $totalarray['nbfield']++;
504
+			if (!$i) $totalarray['nbfield']++;
505 505
 		}
506 506
 		// Town
507
-		if (! empty($arrayfields['s.town']['checked']))
507
+		if (!empty($arrayfields['s.town']['checked']))
508 508
 		{
509 509
 			print '<td class="nocellnopadd">';
510 510
 			print $obj->town;
511 511
 			print '</td>';
512
-			if (! $i) $totalarray['nbfield']++;
512
+			if (!$i) $totalarray['nbfield']++;
513 513
 		}
514 514
 		// Zip
515
-		if (! empty($arrayfields['s.zip']['checked']))
515
+		if (!empty($arrayfields['s.zip']['checked']))
516 516
 		{
517 517
 			print '<td class="nocellnopadd">';
518 518
 			print $obj->zip;
519 519
 			print '</td>';
520
-			if (! $i) $totalarray['nbfield']++;
520
+			if (!$i) $totalarray['nbfield']++;
521 521
 		}
522 522
 		// State
523
-		if (! empty($arrayfields['state.nom']['checked']))
523
+		if (!empty($arrayfields['state.nom']['checked']))
524 524
 		{
525 525
 			print "<td>".$obj->state_name."</td>\n";
526
-			if (! $i) $totalarray['nbfield']++;
526
+			if (!$i) $totalarray['nbfield']++;
527 527
 		}
528 528
 		// Country
529
-		if (! empty($arrayfields['country.code_iso']['checked']))
529
+		if (!empty($arrayfields['country.code_iso']['checked']))
530 530
 		{
531 531
 			print '<td align="center">';
532
-			$tmparray=getCountry($obj->fk_pays,'all');
532
+			$tmparray = getCountry($obj->fk_pays, 'all');
533 533
 			print $tmparray['label'];
534 534
 			print '</td>';
535
-			if (! $i) $totalarray['nbfield']++;
535
+			if (!$i) $totalarray['nbfield']++;
536 536
 		}
537 537
 		// Type ent
538
-		if (! empty($arrayfields['typent.code']['checked']))
538
+		if (!empty($arrayfields['typent.code']['checked']))
539 539
 		{
540 540
 			print '<td align="center">';
541
-			if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
541
+			if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
542 542
 			print $typenArray[$obj->typent_code];
543 543
 			print '</td>';
544
-			if (! $i) $totalarray['nbfield']++;
544
+			if (!$i) $totalarray['nbfield']++;
545 545
 		}
546 546
 
547 547
 		// Date delivery planed
548
-		if (! empty($arrayfields['e.date_delivery']['checked']))
548
+		if (!empty($arrayfields['e.date_delivery']['checked']))
549 549
 		{
550 550
 			print '<td align="center">';
551
-			print dol_print_date($db->jdate($obj->date_livraison),"day");
551
+			print dol_print_date($db->jdate($obj->date_livraison), "day");
552 552
 			/*$now = time();
553 553
     		if ( ($now - $db->jdate($obj->date_expedition)) > $conf->warnings->lim && $obj->statutid == 1 )
554 554
     		{
@@ -556,13 +556,13 @@  discard block
 block discarded – undo
556 556
 			print "</td>\n";
557 557
 		}
558 558
 
559
-		if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked']))
559
+		if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked']))
560 560
 		{
561
-			$shipment->fetchObjectLinked($shipment->id,$shipment->element);
562
-			$receiving='';
563
-			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']);
561
+			$shipment->fetchObjectLinked($shipment->id, $shipment->element);
562
+			$receiving = '';
563
+			if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']);
564 564
 
565
-			if (! empty($arrayfields['l.ref']['checked']))
565
+			if (!empty($arrayfields['l.ref']['checked']))
566 566
 			{
567 567
 				// Ref
568 568
 				print '<td>';
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
 				print '</td>';
571 571
 			}
572 572
 
573
-			if (! empty($arrayfields['l.date_delivery']['checked']))
573
+			if (!empty($arrayfields['l.date_delivery']['checked']))
574 574
 			{
575 575
 				// Date received
576 576
 				print '<td align="center">';
577
-				print dol_print_date($db->jdate($obj->date_reception),"day");
577
+				print dol_print_date($db->jdate($obj->date_reception), "day");
578 578
 				print '</td>'."\n";
579 579
 			}
580 580
 		}
@@ -582,41 +582,41 @@  discard block
 block discarded – undo
582 582
 		// Extra fields
583 583
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
584 584
 		// Fields from hook
585
-		$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
586
-		$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters);    // Note that $action and $object may have been modified by hook
585
+		$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
586
+		$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
587 587
 		print $hookmanager->resPrint;
588 588
 		// Date creation
589
-		if (! empty($arrayfields['e.datec']['checked']))
589
+		if (!empty($arrayfields['e.datec']['checked']))
590 590
 		{
591 591
 			print '<td align="center" class="nowrap">';
592 592
 			print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
593 593
 			print '</td>';
594
-			if (! $i) $totalarray['nbfield']++;
594
+			if (!$i) $totalarray['nbfield']++;
595 595
 		}
596 596
 		// Date modification
597
-		if (! empty($arrayfields['e.tms']['checked']))
597
+		if (!empty($arrayfields['e.tms']['checked']))
598 598
 		{
599 599
 			print '<td align="center" class="nowrap">';
600 600
 			print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
601 601
 			print '</td>';
602
-			if (! $i) $totalarray['nbfield']++;
602
+			if (!$i) $totalarray['nbfield']++;
603 603
 		}
604 604
 		// Status
605
-		if (! empty($arrayfields['e.fk_statut']['checked']))
605
+		if (!empty($arrayfields['e.fk_statut']['checked']))
606 606
 		{
607
-			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut,5).'</td>';
608
-			if (! $i) $totalarray['nbfield']++;
607
+			print '<td align="right" class="nowrap">'.$shipment->LibStatut($obj->fk_statut, 5).'</td>';
608
+			if (!$i) $totalarray['nbfield']++;
609 609
 		}
610 610
 		// Billed
611
-		if (! empty($arrayfields['e.billed']['checked']))
611
+		if (!empty($arrayfields['e.billed']['checked']))
612 612
 		{
613 613
 			print '<td align="center">'.yn($obj->billed).'</td>';
614
-			if (! $i) $totalarray['nbfield']++;
614
+			if (!$i) $totalarray['nbfield']++;
615 615
 		}
616 616
 
617 617
 		// Action column
618 618
 		print '<td></td>';
619
-		if (! $i) $totalarray['nbfield']++;
619
+		if (!$i) $totalarray['nbfield']++;
620 620
 
621 621
 		print "</tr>\n";
622 622
 
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/stats/month.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 
37 37
 llxHeader();
38 38
 
39
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
40
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
39
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
40
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
41 41
 
42 42
 $mesg = '';
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 $px = new DolGraph();
55 55
 $mesg = $px->isGraphKo();
56
-if (! $mesg)
56
+if (!$mesg)
57 57
 {
58 58
     $px->SetData($data);
59 59
     $px->SetMaxValue($px->GetCeilMaxValue());
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     $px->SetShading(3);
64 64
 	$px->SetHorizTickIncrement(1);
65 65
 	$px->SetPrecisionY(0);
66
-    $px->draw($filename,$fileurl);
66
+    $px->draw($filename, $fileurl);
67 67
 }
68 68
 
69 69
 print '<table class="border" width="100%">';
Please login to merge, or discard this patch.
dolibarr/htdocs/expedition/stats/index.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
30 30
 
31
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
32
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
31
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
32
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
33 33
 
34
-$userid=GETPOST('userid','int');
35
-$socid=GETPOST('socid','int');
34
+$userid = GETPOST('userid', 'int');
35
+$socid = GETPOST('socid', 'int');
36 36
 // Security check
37 37
 if ($user->societe_id > 0)
38 38
 {
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
     $socid = $user->societe_id;
41 41
 }
42 42
 
43
-$nowyear=strftime("%Y", dol_now());
44
-$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
43
+$nowyear = strftime("%Y", dol_now());
44
+$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear;
45 45
 //$startyear=$year-2;
46
-$startyear=$year-1;
47
-$endyear=$year;
46
+$startyear = $year - 1;
47
+$endyear = $year;
48 48
 
49 49
 // Load translation files required by the page
50 50
 $langs->loadLangs(array('sendings', 'other', 'companies'));
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  * View
55 55
  */
56 56
 
57
-$form=new Form($db);
57
+$form = new Form($db);
58 58
 
59 59
 llxHeader();
60 60
 
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 
64 64
 dol_mkdir($dir);
65 65
 
66
-$stats = new ExpeditionStats($db, $socid, $mode, ($userid>0?$userid:0));
66
+$stats = new ExpeditionStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
67 67
 
68 68
 // Build graphic number of object
69
-$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
69
+$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
70 70
 //var_dump($data);exit;
71 71
 // $data = array(array('Lib',val1,val2,val3),...)
72 72
 
@@ -86,29 +86,29 @@  discard block
 block discarded – undo
86 86
 
87 87
 $px1 = new DolGraph();
88 88
 $mesg = $px1->isGraphKo();
89
-if (! $mesg)
89
+if (!$mesg)
90 90
 {
91 91
     $px1->SetData($data);
92 92
     $px1->SetPrecisionY(0);
93
-    $i=$startyear;$legend=array();
93
+    $i = $startyear; $legend = array();
94 94
     while ($i <= $endyear)
95 95
     {
96
-        $legend[]=$i;
96
+        $legend[] = $i;
97 97
         $i++;
98 98
     }
99 99
     $px1->SetLegend($legend);
100 100
     $px1->SetMaxValue($px1->GetCeilMaxValue());
101
-    $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
101
+    $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
102 102
     $px1->SetWidth($WIDTH);
103 103
     $px1->SetHeight($HEIGHT);
104 104
     $px1->SetYLabel($langs->trans("NbOfSendings"));
105 105
     $px1->SetShading(3);
106 106
     $px1->SetHorizTickIncrement(1);
107 107
     $px1->SetPrecisionY(0);
108
-    $px1->mode='depth';
108
+    $px1->mode = 'depth';
109 109
     $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth"));
110 110
 
111
-    $px1->draw($filenamenb,$fileurlnb);
111
+    $px1->draw($filenamenb, $fileurlnb);
112 112
 }
113 113
 
114 114
 // Build graphic amount of object
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
 
204 204
 // Show array
205 205
 $data = $stats->getAllByYear();
206
-$arrayyears=array();
207
-foreach($data as $val) {
208
-	if (! empty($val['year'])) {
209
-		$arrayyears[$val['year']]=$val['year'];
206
+$arrayyears = array();
207
+foreach ($data as $val) {
208
+	if (!empty($val['year'])) {
209
+		$arrayyears[$val['year']] = $val['year'];
210 210
 	}
211 211
 }
212
-if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
212
+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
213 213
 
214
-$h=0;
214
+$h = 0;
215 215
 $head = array();
216
-$head[$h][0] = DOL_URL_ROOT . '/expedition/stats/index.php?mode='.$mode;
216
+$head[$h][0] = DOL_URL_ROOT.'/expedition/stats/index.php?mode='.$mode;
217 217
 $head[$h][1] = $langs->trans("ByMonthYear");
218 218
 $head[$h][2] = 'byyear';
219 219
 $h++;
220 220
 
221
-$type='shipment_stats';
221
+$type = 'shipment_stats';
222 222
 
223
-complete_head_from_modules($conf,$langs,null,$head,$h,$type);
223
+complete_head_from_modules($conf, $langs, null, $head, $h, $type);
224 224
 
225 225
 dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
226 226
 
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
239 239
 	// Company
240 240
 	print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
241
-	if ($mode == 'customer') $filter='s.client in (1,2,3)';
242
-	if ($mode == 'supplier') $filter='s.fournisseur = 1';
243
-	print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
241
+	if ($mode == 'customer') $filter = 's.client in (1,2,3)';
242
+	if ($mode == 'supplier') $filter = 's.fournisseur = 1';
243
+	print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"');
244 244
 	print '</td></tr>';
245 245
 	// User
246 246
 	print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 	print '</td></tr>';
249 249
 	// Year
250 250
 	print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
251
-	if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
252
-	if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
251
+	if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
252
+	if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
253 253
 	arsort($arrayyears);
254
-	print $form->selectarray('year',$arrayyears,$year,0);
254
+	print $form->selectarray('year', $arrayyears, $year, 0);
255 255
 	print '</td></tr>';
256 256
 	print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
257 257
 	print '</table>';
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 print '<td align="center">'.$langs->trans("AmountAverage").'</td>';*/
270 270
 print '</tr>';
271 271
 
272
-$oldyear=0;
272
+$oldyear = 0;
273 273
 foreach ($data as $val)
274 274
 {
275 275
 	$year = $val['year'];
276
-	while (! empty($year) && $oldyear > $year+1)
276
+	while (!empty($year) && $oldyear > $year + 1)
277 277
 	{ // If we have empty year
278 278
 		$oldyear--;
279 279
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
297 297
 	print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';*/
298 298
 	print '</tr>';
299
-	$oldyear=$year;
299
+	$oldyear = $year;
300 300
 }
301 301
 
302 302
 print '</table>';
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/companypaymentmode.class.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Put here all includes required by your class file
26
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27 27
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
28 28
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
29 29
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
81 81
 	 */
82
-	public $fields=array(
82
+	public $fields = array(
83 83
 		'rowid' =>array('type'=>'integer', 'label'=>'Rowid', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
84 84
 		'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15),
85 85
 		'label' =>array('type'=>'varchar(30)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-2, 'position'=>30),
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$this->db = $db;
214 214
 
215
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
216
-		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
215
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
216
+		if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
217 217
 	}
218 218
 
219 219
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function create(User $user, $notrigger = false)
227 227
 	{
228
-		$idpayment =  $this->createCommon($user, $notrigger);
228
+		$idpayment = $this->createCommon($user, $notrigger);
229 229
 
230 230
 		return $idpayment;
231 231
 	}
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 	public function fetch($id, $ref = null, $socid = 0, $type = '')
292 292
 	{
293 293
 		$morewhere = '';
294
-		if ($socid) $morewhere.= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
-		if ($type)  $morewhere.= " AND type = '".$this->db->escape($type)."'";
294
+		if ($socid) $morewhere .= " AND fk_soc  = ".$this->db->escape($socid)." AND default_rib = 1";
295
+		if ($type)  $morewhere .= " AND type = '".$this->db->escape($type)."'";
296 296
 
297 297
 		$result = $this->fetchCommon($id, $ref, $morewhere);
298
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
298
+		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
299 299
 		return $result;
300 300
 	}
301 301
 
@@ -347,51 +347,51 @@  discard block
 block discarded – undo
347 347
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
348 348
 	 *	@return	string								String with URL
349 349
 	 */
350
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
350
+	function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
351 351
 	{
352 352
 		global $db, $conf, $langs;
353 353
         global $dolibarr_main_authentication, $dolibarr_main_demo;
354 354
         global $menumanager;
355 355
 
356
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
356
+        if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
357 357
 
358 358
         $result = '';
359 359
         $companylink = '';
360 360
 
361
-        $label = '<u>' . $langs->trans("CompanyPaymentMode") . '</u>';
362
-        $label.= '<br>';
363
-        $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
361
+        $label = '<u>'.$langs->trans("CompanyPaymentMode").'</u>';
362
+        $label .= '<br>';
363
+        $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
364 364
 
365
-        $url = dol_buildpath('/monmodule/companypaymentmode_card.php',1).'?id='.$this->id;
365
+        $url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?id='.$this->id;
366 366
 
367 367
         if ($option != 'nolink')
368 368
         {
369 369
 	        // Add param to save lastsearch_values or not
370
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
371
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
372
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
370
+	        $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
371
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
372
+	        if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
373 373
         }
374 374
 
375
-        $linkclose='';
375
+        $linkclose = '';
376 376
         if (empty($notooltip))
377 377
         {
378
-            if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
378
+            if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
379 379
             {
380
-                $label=$langs->trans("ShowCompanyPaymentMode");
381
-                $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
380
+                $label = $langs->trans("ShowCompanyPaymentMode");
381
+                $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
382 382
             }
383
-            $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
384
-            $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
383
+            $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
384
+            $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
385 385
         }
386
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
386
+        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
387 387
 
388 388
 		$linkstart = '<a href="'.$url.'"';
389
-		$linkstart.=$linkclose.'>';
390
-		$linkend='</a>';
389
+		$linkstart .= $linkclose.'>';
390
+		$linkend = '</a>';
391 391
 
392 392
 		$result .= $linkstart;
393
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
394
-		if ($withpicto != 2) $result.= $this->ref;
393
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
394
+		if ($withpicto != 2) $result .= $this->ref;
395 395
 		$result .= $linkend;
396 396
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
397 397
 
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 	 * @param	string	$alltypes	1=The default is for all payment types instead of per type
406 406
 	 * @return  int             	0 if KO, 1 if OK
407 407
 	 */
408
-	function setAsDefault($id=0, $alltypes=0)
408
+	function setAsDefault($id = 0, $alltypes = 0)
409 409
 	{
410 410
 		$sql1 = "SELECT rowid as id, fk_soc, type FROM ".MAIN_DB_PREFIX."societe_rib";
411
-		$sql1.= " WHERE rowid = ".($id?$id:$this->id);
411
+		$sql1 .= " WHERE rowid = ".($id ? $id : $this->id);
412 412
 
413 413
 		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
414 414
 		$result1 = $this->db->query($sql1);
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 				$this->db->begin();
429 429
 
430 430
 				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
431
-				$sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
-				if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'";
431
+				$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
432
+				if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'";
433 433
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
434 434
 				$result2 = $this->db->query($sql2);
435 435
 
436 436
 				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
437
-				$sql3.= " WHERE rowid = ".$obj->id;
438
-				if ($type) $sql3.= " AND type = '".$this->db->escape($type)."'";
437
+				$sql3 .= " WHERE rowid = ".$obj->id;
438
+				if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'";
439 439
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
440 440
 				$result3 = $this->db->query($sql3);
441 441
 
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
466 466
 	 *  @return	string 			       Label of status
467 467
 	 */
468
-	function getLibStatut($mode=0)
468
+	function getLibStatut($mode = 0)
469 469
 	{
470
-		return $this->LibStatut($this->status,$mode);
470
+		return $this->LibStatut($this->status, $mode);
471 471
 	}
472 472
 
473 473
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
479 479
 	 *  @return string 			       	Label of status
480 480
 	 */
481
-	static function LibStatut($status,$mode=0)
481
+	static function LibStatut($status, $mode = 0)
482 482
 	{
483 483
         // phpcs:enable
484 484
 		global $langs;
@@ -490,28 +490,28 @@  discard block
 block discarded – undo
490 490
 		}
491 491
 		elseif ($mode == 2)
492 492
 		{
493
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
494
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
493
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
494
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
495 495
 		}
496 496
 		elseif ($mode == 3)
497 497
 		{
498
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
499
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
498
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
499
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
500 500
 		}
501 501
 		elseif ($mode == 4)
502 502
 		{
503
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
504
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
503
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
504
+			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
505 505
 		}
506 506
 		elseif ($mode == 5)
507 507
 		{
508
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
509
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
508
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
509
+			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
510 510
 		}
511 511
 		elseif ($mode == 6)
512 512
 		{
513
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
514
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
513
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
514
+			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
515 515
 		}
516 516
 	}
517 517
 
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 	function info($id)
525 525
 	{
526 526
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
527
-		$sql.= ' fk_user_creat, fk_user_modif';
528
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
-		$sql.= ' WHERE t.rowid = '.$id;
530
-		$result=$this->db->query($sql);
527
+		$sql .= ' fk_user_creat, fk_user_modif';
528
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
529
+		$sql .= ' WHERE t.rowid = '.$id;
530
+		$result = $this->db->query($sql);
531 531
 		if ($result)
532 532
 		{
533 533
 			if ($this->db->num_rows($result))
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				{
539 539
 					$cuser = new User($this->db);
540 540
 					$cuser->fetch($obj->fk_user_author);
541
-					$this->user_creation   = $cuser;
541
+					$this->user_creation = $cuser;
542 542
 				}
543 543
 
544 544
 				if ($obj->fk_user_valid)
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 				{
553 553
 					$cluser = new User($this->db);
554 554
 					$cluser->fetch($obj->fk_user_cloture);
555
-					$this->user_cloture   = $cluser;
555
+					$this->user_cloture = $cluser;
556 556
 				}
557 557
 
558 558
 				$this->date_creation     = $this->db->jdate($obj->datec);
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/societe.class.php 1 patch
Spacing   +798 added lines, -798 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @var string ID to identify managed object
47 47
 	 */
48
-	public $element='societe';
48
+	public $element = 'societe';
49 49
 
50 50
 	/**
51 51
 	 * @var string Name of table without prefix where object is stored
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @var int Field with ID of parent key if this field has a parent
57 57
 	 */
58
-	public $fk_element='fk_soc';
58
+	public $fk_element = 'fk_soc';
59 59
 
60
-	public $fieldsforcombobox='nom,name_alias';
61
-	protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord');    // To test if we can delete object
62
-	protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm");
60
+	public $fieldsforcombobox = 'nom,name_alias';
61
+	protected $childtables = array("supplier_proposal"=>'SupplierProposal', "propal"=>'Proposal', "commande"=>'Order', "facture"=>'Invoice', "facture_rec"=>'RecurringInvoiceTemplate', "contrat"=>'Contract', "fichinter"=>'Fichinter', "facture_fourn"=>'SupplierInvoice', "commande_fournisseur"=>'SupplierOrder', "projet"=>'Project', "expedition"=>'Shipment', "prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object
62
+	protected $childtablesoncascade = array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm");
63 63
 	public $picto = 'company';
64 64
 
65 65
 	/**
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
81 81
 	 */
82
-	public $fields=array(
83
-		'rowid'         =>array('type'=>'integer',      'label'=>'TechnicalID',      'enabled'=>1, 'visible'=>-2, 'notnull'=>1,  'index'=>1, 'position'=>1, 'comment'=>'Id'),
84
-		'nom'           =>array('type'=>'varchar(128)', 'label'=>'Name',             'enabled'=>1, 'visible'=>1,  'notnull'=>1,  'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
85
-		'name_alias'    =>array('type'=>'varchar(128)', 'label'=>'Name',             'enabled'=>1, 'visible'=>1,  'notnull'=>1,  'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
86
-		'entity'        =>array('type'=>'integer',      'label'=>'Entity',           'enabled'=>1, 'visible'=>0,  'default'=>1,  'notnull'=>1,  'index'=>1, 'position'=>20),
87
-		'note_public'   =>array('type'=>'text',			'label'=>'NotePublic',		 'enabled'=>1, 'visible'=>0,  'position'=>60),
88
-		'note_private'  =>array('type'=>'text',			'label'=>'NotePrivate',		 'enabled'=>1, 'visible'=>0,  'position'=>61),
89
-		'datec'			=>array('type'=>'datetime',     'label'=>'DateCreation',     'enabled'=>1, 'visible'=>-2, 'notnull'=>1,  'position'=>500),
90
-		'tms'           =>array('type'=>'timestamp',    'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1,  'position'=>501),
82
+	public $fields = array(
83
+		'rowid'         =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
84
+		'nom'           =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
85
+		'name_alias'    =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
86
+		'entity'        =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
87
+		'note_public'   =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
88
+		'note_private'  =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),
89
+		'datec'			=>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
90
+		'tms'           =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
91 91
 		//'date_valid'    =>array('type'=>'datetime',     'label'=>'DateCreation',     'enabled'=>1, 'visible'=>-2, 'position'=>502),
92
-		'fk_user_creat' =>array('type'=>'integer',      'label'=>'UserAuthor',       'enabled'=>1, 'visible'=>-2, 'notnull'=>1,  'position'=>510),
93
-		'fk_user_modif' =>array('type'=>'integer',      'label'=>'UserModif',        'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
92
+		'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
93
+		'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
94 94
 		//'fk_user_valid' =>array('type'=>'integer',      'label'=>'UserValidation',        'enabled'=>1, 'visible'=>-1, 'position'=>512),
95
-		'import_key'    =>array('type'=>'varchar(14)',  'label'=>'ImportId',         'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1,  'position'=>1000),
95
+		'import_key'    =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
96 96
 	);
97 97
 
98 98
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * Thirdparty status : 0=activity ceased, 1= in activity
135 135
 	 * @var int
136 136
 	 */
137
-	public $status=1;
137
+	public $status = 1;
138 138
 
139 139
 	/**
140 140
 	 * Id of department
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 	public $prefix_comm;
258 258
 
259
-	public $tva_assuj=1;
259
+	public $tva_assuj = 1;
260 260
 	/**
261 261
 	 * Intracommunitary VAT ID
262 262
 	 * @var string
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 
272 272
 	public $managers;
273 273
 	public $capital;
274
-	public $typent_id=0;
274
+	public $typent_id = 0;
275 275
 	public $typent_code;
276 276
 	public $effectif;
277
-	public $effectif_id=0;
277
+	public $effectif_id = 0;
278 278
 	public $forme_juridique_code;
279
-	public $forme_juridique=0;
279
+	public $forme_juridique = 0;
280 280
 
281 281
 	public $remise_percent;
282 282
 	public $remise_supplier_percent;
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
 	 * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect
321 321
 	 * @var int
322 322
 	 */
323
-	public $client=0;
323
+	public $client = 0;
324 324
 	/**
325 325
 	 * 0=no prospect, 1=prospect
326 326
 	 * @var int
327 327
 	 */
328
-	public $prospect=0;
328
+	public $prospect = 0;
329 329
 	/**
330 330
 	 * 0=no supplier, 1=supplier
331 331
 	 * @var int
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	public $fk_incoterms;
462 462
 
463 463
 	public $location_incoterms;
464
-	public $libelle_incoterms;  //Used into tooltip
464
+	public $libelle_incoterms; //Used into tooltip
465 465
 
466 466
 	// Multicurrency
467 467
 	/**
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 		$this->client = 0;
488 488
 		$this->prospect = 0;
489 489
 		$this->fournisseur = 0;
490
-		$this->typent_id  = 0;
491
-		$this->effectif_id  = 0;
492
-		$this->forme_juridique_code  = 0;
490
+		$this->typent_id = 0;
491
+		$this->effectif_id = 0;
492
+		$this->forme_juridique_code = 0;
493 493
 		$this->tva_assuj = 1;
494 494
 		$this->status = 1;
495 495
 	}
@@ -504,17 +504,17 @@  discard block
 block discarded – undo
504 504
 	 */
505 505
 	function create(User $user)
506 506
 	{
507
-		global $langs,$conf,$mysoc;
507
+		global $langs, $conf, $mysoc;
508 508
 
509
-		$error=0;
509
+		$error = 0;
510 510
 
511 511
 		// Clean parameters
512
-		if (empty($this->status)) $this->status=0;
513
-		$this->name=$this->name?trim($this->name):trim($this->nom);
514
-		if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name);
515
-		$this->nom=$this->name; // For backward compatibility
516
-		if (empty($this->client))      $this->client=0;
517
-		if (empty($this->fournisseur)) $this->fournisseur=0;
512
+		if (empty($this->status)) $this->status = 0;
513
+		$this->name = $this->name ?trim($this->name) : trim($this->nom);
514
+		if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name);
515
+		$this->nom = $this->name; // For backward compatibility
516
+		if (empty($this->client))      $this->client = 0;
517
+		if (empty($this->fournisseur)) $this->fournisseur = 0;
518 518
 		$this->import_key = trim($this->import_key);
519 519
 
520 520
 		if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
 
527 527
 		dol_syslog(get_class($this)."::create ".$this->name);
528 528
 
529
-		$now=dol_now();
529
+		$now = dol_now();
530 530
 
531 531
 		$this->db->begin();
532 532
 
533 533
 		// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
534
-		if ($this->code_client == -1 || $this->code_client === 'auto')           $this->get_codeclient($this,0);
535
-		if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1);
534
+		if ($this->code_client == -1 || $this->code_client === 'auto')           $this->get_codeclient($this, 0);
535
+		if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this, 1);
536 536
 
537 537
 		// Check more parameters (including mandatory setup
538 538
 		// If error, this->errors[] is filled
@@ -540,29 +540,29 @@  discard block
 block discarded – undo
540 540
 
541 541
 		if ($result >= 0)
542 542
 		{
543
-			$this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
543
+			$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
544 544
 
545 545
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)";
546
-			$sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'";
547
-			$sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null");
548
-			$sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null");
549
-			$sql.= ", ".$this->status;
550
-			$sql.= ", ".(! empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'":"null");
551
-			$sql.= ", ".(! empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'":"null");
552
-			$sql.= ", 0";
553
-			$sql.= ", ".(int) $this->fk_incoterms;
554
-			$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
555
-			$sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null");
556
-			$sql.= ", ".(int) $this->fk_multicurrency;
557
-			$sql.= ", '".$this->db->escape($this->multicurrency_code)."')";
546
+			$sql .= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'";
547
+			$sql .= ", ".(!empty($user->id) ? "'".$user->id."'" : "null");
548
+			$sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null");
549
+			$sql .= ", ".$this->status;
550
+			$sql .= ", ".(!empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'" : "null");
551
+			$sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null");
552
+			$sql .= ", 0";
553
+			$sql .= ", ".(int) $this->fk_incoterms;
554
+			$sql .= ", '".$this->db->escape($this->location_incoterms)."'";
555
+			$sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null");
556
+			$sql .= ", ".(int) $this->fk_multicurrency;
557
+			$sql .= ", '".$this->db->escape($this->multicurrency_code)."')";
558 558
 
559 559
 			dol_syslog(get_class($this)."::create", LOG_DEBUG);
560
-			$result=$this->db->query($sql);
560
+			$result = $this->db->query($sql);
561 561
 			if ($result)
562 562
 			{
563 563
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe");
564 564
 
565
-				$ret = $this->update($this->id,$user,0,1,1,'add');
565
+				$ret = $this->update($this->id, $user, 0, 1, 1, 'add');
566 566
 
567 567
 				// Ajout du commercial affecte
568 568
 				if ($this->commercial_id != '' && $this->commercial_id != -1)
@@ -578,13 +578,13 @@  discard block
 block discarded – undo
578 578
 				if ($ret >= 0)
579 579
 				{
580 580
 					// Call trigger
581
-					$result=$this->call_trigger('COMPANY_CREATE',$user);
581
+					$result = $this->call_trigger('COMPANY_CREATE', $user);
582 582
 					if ($result < 0) $error++;
583 583
 					// End call triggers
584 584
 				}
585 585
 				else $error++;
586 586
 
587
-				if (! $error)
587
+				if (!$error)
588 588
 				{
589 589
 					dol_syslog(get_class($this)."::Create success id=".$this->id);
590 590
 					$this->db->commit();
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 				}
593 593
 				else
594 594
 				{
595
-					dol_syslog(get_class($this)."::Create echec update ".$this->error." ".join(',',$this->errors), LOG_ERR);
595
+					dol_syslog(get_class($this)."::Create echec update ".$this->error." ".join(',', $this->errors), LOG_ERR);
596 596
 					$this->db->rollback();
597 597
 					return -4;
598 598
 				}
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
 			{
602 602
 				if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
603 603
 				{
604
-					$this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name);    // duplicate on a field (code or profid or ...)
605
-					$result=-1;
604
+					$this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); // duplicate on a field (code or profid or ...)
605
+					$result = -1;
606 606
 				}
607 607
 				else
608 608
 				{
609
-					$this->error=$this->db->lasterror();
610
-					$result=-2;
609
+					$this->error = $this->db->lasterror();
610
+					$result = -2;
611 611
 				}
612 612
 				$this->db->rollback();
613 613
 				return $result;
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		else
617 617
 		{
618 618
 			$this->db->rollback();
619
-			dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING);
619
+			dol_syslog(get_class($this)."::Create fails verify ".join(',', $this->errors), LOG_WARNING);
620 620
 			return -3;
621 621
 		}
622 622
 	}
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
 	{
634 634
         // phpcs:enable
635 635
 		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
636
-		$contact=new Contact($this->db);
636
+		$contact = new Contact($this->db);
637 637
 
638 638
 		$contact->name              = $this->name_bis;
639 639
 		$contact->firstname         = $this->firstname;
640 640
 		$contact->civility_id       = $this->civility_id;
641
-		$contact->socid             = $this->id;	// fk_soc
641
+		$contact->socid             = $this->id; // fk_soc
642 642
 		$contact->statut            = 1;
643 643
 		$contact->priv              = 0;
644 644
 		$contact->country_id        = $this->country_id;
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		{
655 655
 			$this->error = $contact->error;
656 656
 			$this->errors = $contact->errors;
657
-			dol_syslog(get_class($this)."::create_individual ERROR:" . $this->error, LOG_ERR);
657
+			dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR);
658 658
 		}
659 659
 
660 660
 		return $result;
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
 		global $conf, $langs, $mysoc;
672 672
 
673 673
 		$error = 0;
674
-		$this->errors=array();
674
+		$this->errors = array();
675 675
 
676 676
 		$result = 0;
677
-		$this->name	= trim($this->name);
678
-		$this->nom=$this->name; // For backward compatibility
677
+		$this->name = trim($this->name);
678
+		$this->nom = $this->name; // For backward compatibility
679 679
 
680
-		if (! $this->name)
680
+		if (!$this->name)
681 681
 		{
682 682
 			$this->errors[] = 'ErrorBadThirdPartyName';
683 683
 			$result = -2;
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 		}
735 735
 
736 736
 		// Check for duplicate or mandatory fields defined into setup
737
-		$array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL');
738
-		foreach($array_to_check as $key)
737
+		$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
738
+		foreach ($array_to_check as $key)
739 739
 		{
740
-			$keymin=strtolower($key);
741
-			$i=(int) preg_replace('/[^0-9]/','',$key);
742
-			$vallabel=$this->$keymin;
740
+			$keymin = strtolower($key);
741
+			$i = (int) preg_replace('/[^0-9]/', '', $key);
742
+			$vallabel = $this->$keymin;
743 743
 
744 744
 			if ($i > 0)
745 745
 			{
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 					// Check for mandatory prof id (but only if country is other than ours)
759 759
 					if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id)
760 760
 					{
761
-						$idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY';
762
-						if (! $vallabel && ! empty($conf->global->$idprof_mandatory))
761
+						$idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
762
+						if (!$vallabel && !empty($conf->global->$idprof_mandatory))
763 763
 						{
764 764
 							$langs->load("errors");
765 765
 							$error++;
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 				if ($key == 'EMAIL')
776 776
 				{
777 777
 					// Check for unicity
778
-					if ($vallabel && ! empty($conf->global->SOCIETE_EMAIL_UNIQUE))
778
+					if ($vallabel && !empty($conf->global->SOCIETE_EMAIL_UNIQUE))
779 779
 					{
780 780
 						if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
781 781
 						{
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 					}
786 786
 
787 787
 					// Check for mandatory
788
-					if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email))
788
+					if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY) && !isValidEMail($this->email))
789 789
 					{
790 790
 						$langs->load("errors");
791 791
 						$error++;
@@ -812,58 +812,58 @@  discard block
 block discarded – undo
812 812
 	 *		@param	int		$nosyncmember				Do not synchronize info of linked member
813 813
 	 *      @return int  			           			<0 if KO, >=0 if OK
814 814
 	 */
815
-	function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1)
815
+	function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = 0, $allowmodcodefournisseur = 0, $action = 'update', $nosyncmember = 1)
816 816
 	{
817
-		global $langs,$conf,$hookmanager;
817
+		global $langs, $conf, $hookmanager;
818 818
 
819 819
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
820 820
 
821 821
 		if (empty($id)) $id = $this->id;
822 822
 
823
-		$error=0;
823
+		$error = 0;
824 824
 
825 825
 		dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
826 826
 
827
-		$now=dol_now();
827
+		$now = dol_now();
828 828
 
829 829
 		// Clean parameters
830
-		$this->id			= $id;
831
-		$this->entity		= ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
832
-		$this->name			= $this->name?trim($this->name):trim($this->nom);
833
-		$this->nom			= $this->name;	// For backward compatibility
834
-		$this->name_alias	= trim($this->name_alias);
830
+		$this->id = $id;
831
+		$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
832
+		$this->name = $this->name ?trim($this->name) : trim($this->nom);
833
+		$this->nom = $this->name; // For backward compatibility
834
+		$this->name_alias = trim($this->name_alias);
835 835
 		$this->ref_ext		= trim($this->ref_ext);
836
-		$this->address		= $this->address?trim($this->address):trim($this->address);
837
-		$this->zip			= $this->zip?trim($this->zip):trim($this->zip);
838
-		$this->town			= $this->town?trim($this->town):trim($this->town);
839
-		$this->state_id		= trim($this->state_id);
840
-		$this->country_id	= ($this->country_id > 0)?$this->country_id:0;
836
+		$this->address		= $this->address ?trim($this->address) : trim($this->address);
837
+		$this->zip = $this->zip ?trim($this->zip) : trim($this->zip);
838
+		$this->town			= $this->town ?trim($this->town) : trim($this->town);
839
+		$this->state_id = trim($this->state_id);
840
+		$this->country_id = ($this->country_id > 0) ? $this->country_id : 0;
841 841
 		$this->phone		= trim($this->phone);
842
-		$this->phone		= preg_replace("/\s/","",$this->phone);
843
-		$this->phone		= preg_replace("/\./","",$this->phone);
842
+		$this->phone		= preg_replace("/\s/", "", $this->phone);
843
+		$this->phone		= preg_replace("/\./", "", $this->phone);
844 844
 		$this->fax			= trim($this->fax);
845
-		$this->fax			= preg_replace("/\s/","",$this->fax);
846
-		$this->fax			= preg_replace("/\./","",$this->fax);
845
+		$this->fax			= preg_replace("/\s/", "", $this->fax);
846
+		$this->fax			= preg_replace("/\./", "", $this->fax);
847 847
 		$this->email		= trim($this->email);
848 848
 		$this->skype		= trim($this->skype);
849
-		$this->twitter		= trim($this->twitter);
850
-		$this->facebook		= trim($this->facebook);
851
-		$this->url			= $this->url?clean_url($this->url,0):'';
849
+		$this->twitter = trim($this->twitter);
850
+		$this->facebook = trim($this->facebook);
851
+		$this->url = $this->url ?clean_url($this->url, 0) : '';
852 852
 		$this->note_private = trim($this->note_private);
853 853
 		$this->note_public  = trim($this->note_public);
854 854
 		$this->idprof1		= trim($this->idprof1);
855 855
 		$this->idprof2		= trim($this->idprof2);
856 856
 		$this->idprof3		= trim($this->idprof3);
857 857
 		$this->idprof4		= trim($this->idprof4);
858
-		$this->idprof5		= (! empty($this->idprof5)?trim($this->idprof5):'');
859
-		$this->idprof6		= (! empty($this->idprof6)?trim($this->idprof6):'');
860
-		$this->prefix_comm	= trim($this->prefix_comm);
858
+		$this->idprof5		= (!empty($this->idprof5) ?trim($this->idprof5) : '');
859
+		$this->idprof6		= (!empty($this->idprof6) ?trim($this->idprof6) : '');
860
+		$this->prefix_comm = trim($this->prefix_comm);
861 861
 		$this->outstanding_limit = price2num($this->outstanding_limit);
862 862
 		$this->order_min_amount = price2num($this->order_min_amount);
863 863
 		$this->supplier_order_min_amount = price2num($this->supplier_order_min_amount);
864 864
 
865 865
 		$this->tva_assuj	= trim($this->tva_assuj);
866
-		$this->tva_intra	= dol_sanitizeFileName($this->tva_intra,'');
866
+		$this->tva_intra	= dol_sanitizeFileName($this->tva_intra, '');
867 867
 		if (empty($this->status)) $this->status = 0;
868 868
 
869 869
 		if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
@@ -874,64 +874,64 @@  discard block
 block discarded – undo
874 874
 		}
875 875
 
876 876
 		// Local taxes
877
-		$this->localtax1_assuj=trim($this->localtax1_assuj);
878
-		$this->localtax2_assuj=trim($this->localtax2_assuj);
877
+		$this->localtax1_assuj = trim($this->localtax1_assuj);
878
+		$this->localtax2_assuj = trim($this->localtax2_assuj);
879 879
 
880
-		$this->localtax1_value=trim($this->localtax1_value);
881
-		$this->localtax2_value=trim($this->localtax2_value);
880
+		$this->localtax1_value = trim($this->localtax1_value);
881
+		$this->localtax2_value = trim($this->localtax2_value);
882 882
 
883
-		if ($this->capital != '') $this->capital=price2num(trim($this->capital));
884
-		if (! is_numeric($this->capital)) $this->capital = '';     // '' = undef
883
+		if ($this->capital != '') $this->capital = price2num(trim($this->capital));
884
+		if (!is_numeric($this->capital)) $this->capital = ''; // '' = undef
885 885
 
886
-		$this->effectif_id=trim($this->effectif_id);
887
-		$this->forme_juridique_code=trim($this->forme_juridique_code);
886
+		$this->effectif_id = trim($this->effectif_id);
887
+		$this->forme_juridique_code = trim($this->forme_juridique_code);
888 888
 
889 889
 		//Gencod
890
-		$this->barcode=trim($this->barcode);
890
+		$this->barcode = trim($this->barcode);
891 891
 
892 892
 		// For automatic creation
893
-		if ($this->code_client == -1 || $this->code_client === 'auto')           $this->get_codeclient($this,0);
894
-		if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1);
893
+		if ($this->code_client == -1 || $this->code_client === 'auto')           $this->get_codeclient($this, 0);
894
+		if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this, 1);
895 895
 
896
-		$this->code_compta=trim($this->code_compta);
897
-		$this->code_compta_fournisseur=trim($this->code_compta_fournisseur);
896
+		$this->code_compta = trim($this->code_compta);
897
+		$this->code_compta_fournisseur = trim($this->code_compta_fournisseur);
898 898
 
899 899
 		// Check parameters. More tests are done later in the ->verify()
900
-		if (! is_numeric($this->client) && ! is_numeric($this->fournisseur))
900
+		if (!is_numeric($this->client) && !is_numeric($this->fournisseur))
901 901
 		{
902 902
 			$langs->load("errors");
903 903
 			$this->error = $langs->trans("BadValueForParameterClientOrSupplier");
904 904
 			return -1;
905 905
 		}
906 906
 
907
-		$customer=false;
908
-		if (! empty($allowmodcodeclient) && ! empty($this->client))
907
+		$customer = false;
908
+		if (!empty($allowmodcodeclient) && !empty($this->client))
909 909
 		{
910 910
 			// Attention get_codecompta peut modifier le code suivant le module utilise
911 911
 			if (empty($this->code_compta))
912 912
 			{
913
-				$ret=$this->get_codecompta('customer');
913
+				$ret = $this->get_codecompta('customer');
914 914
 				if ($ret < 0) return -1;
915 915
 			}
916 916
 
917
-			$customer=true;
917
+			$customer = true;
918 918
 		}
919 919
 
920
-		$supplier=false;
921
-		if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur))
920
+		$supplier = false;
921
+		if (!empty($allowmodcodefournisseur) && !empty($this->fournisseur))
922 922
 		{
923 923
 			// Attention get_codecompta peut modifier le code suivant le module utilise
924 924
 			if (empty($this->code_compta_fournisseur))
925 925
 			{
926
-				$ret=$this->get_codecompta('supplier');
926
+				$ret = $this->get_codecompta('supplier');
927 927
 				if ($ret < 0) return -1;
928 928
 			}
929 929
 
930
-			$supplier=true;
930
+			$supplier = true;
931 931
 		}
932 932
 
933 933
 		//Web services
934
-		$this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):'';
934
+		$this->webservices_url = $this->webservices_url ?clean_url($this->webservices_url, 0) : '';
935 935
 		$this->webservices_key = trim($this->webservices_key);
936 936
 
937 937
 		//Incoterms
@@ -955,11 +955,11 @@  discard block
 block discarded – undo
955 955
 			{
956 956
 				if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client)
957 957
 				{
958
-					if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]);	// Remove error message
958
+					if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message
959 959
 				}
960 960
 				if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur)
961 961
 				{
962
-					if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]);	// Remove error message
962
+					if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message
963 963
 				}
964 964
 				if (empty($this->errors))	// If there is no more error, we can make like if there is no error at all
965 965
 				{
@@ -973,118 +973,118 @@  discard block
 block discarded – undo
973 973
 			dol_syslog(get_class($this)."::update verify ok or not done");
974 974
 
975 975
 			$sql  = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
976
-			$sql .= "entity = " . $this->db->escape($this->entity);
977
-			$sql .= ",nom = '" . $this->db->escape($this->name) ."'"; // Required
978
-			$sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'";
979
-			$sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null");
980
-			$sql .= ",address = '" . $this->db->escape($this->address) ."'";
981
-
982
-			$sql .= ",zip = ".(! empty($this->zip)?"'".$this->db->escape($this->zip)."'":"null");
983
-			$sql .= ",town = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null");
984
-
985
-			$sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'";
986
-			$sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'";
987
-
988
-			$sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null");
989
-			$sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null");
990
-			$sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null");
991
-			$sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null");
992
-			$sql .= ",twitter = ".(! empty($this->twitter)?"'".$this->db->escape($this->twitter)."'":"null");
993
-			$sql .= ",facebook = ".(! empty($this->facebook)?"'".$this->db->escape($this->facebook)."'":"null");
994
-			$sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null");
995
-
996
-			$sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null");
997
-
998
-			$sql .= ",note_private = ".(! empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
999
-			$sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
1000
-
1001
-			$sql .= ",siren   = '". $this->db->escape($this->idprof1) ."'";
1002
-			$sql .= ",siret   = '". $this->db->escape($this->idprof2) ."'";
1003
-			$sql .= ",ape     = '". $this->db->escape($this->idprof3) ."'";
1004
-			$sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'";
1005
-			$sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'";
1006
-			$sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'";
1007
-
1008
-			$sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->db->escape($this->tva_assuj)."'":"null");
1009
-			$sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'";
1010
-			$sql .= ",status = " .$this->status;
976
+			$sql .= "entity = ".$this->db->escape($this->entity);
977
+			$sql .= ",nom = '".$this->db->escape($this->name)."'"; // Required
978
+			$sql .= ",name_alias = '".$this->db->escape($this->name_alias)."'";
979
+			$sql .= ",ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null");
980
+			$sql .= ",address = '".$this->db->escape($this->address)."'";
981
+
982
+			$sql .= ",zip = ".(!empty($this->zip) ? "'".$this->db->escape($this->zip)."'" : "null");
983
+			$sql .= ",town = ".(!empty($this->town) ? "'".$this->db->escape($this->town)."'" : "null");
984
+
985
+			$sql .= ",fk_departement = '".(!empty($this->state_id) ? $this->state_id : '0')."'";
986
+			$sql .= ",fk_pays = '".(!empty($this->country_id) ? $this->country_id : '0')."'";
987
+
988
+			$sql .= ",phone = ".(!empty($this->phone) ? "'".$this->db->escape($this->phone)."'" : "null");
989
+			$sql .= ",fax = ".(!empty($this->fax) ? "'".$this->db->escape($this->fax)."'" : "null");
990
+			$sql .= ",email = ".(!empty($this->email) ? "'".$this->db->escape($this->email)."'" : "null");
991
+			$sql .= ",skype = ".(!empty($this->skype) ? "'".$this->db->escape($this->skype)."'" : "null");
992
+			$sql .= ",twitter = ".(!empty($this->twitter) ? "'".$this->db->escape($this->twitter)."'" : "null");
993
+			$sql .= ",facebook = ".(!empty($this->facebook) ? "'".$this->db->escape($this->facebook)."'" : "null");
994
+			$sql .= ",url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null");
995
+
996
+			$sql .= ",parent = ".($this->parent > 0 ? $this->parent : "null");
997
+
998
+			$sql .= ",note_private = ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null");
999
+			$sql .= ",note_public = ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null");
1000
+
1001
+			$sql .= ",siren   = '".$this->db->escape($this->idprof1)."'";
1002
+			$sql .= ",siret   = '".$this->db->escape($this->idprof2)."'";
1003
+			$sql .= ",ape     = '".$this->db->escape($this->idprof3)."'";
1004
+			$sql .= ",idprof4 = '".$this->db->escape($this->idprof4)."'";
1005
+			$sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'";
1006
+			$sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'";
1007
+
1008
+			$sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null");
1009
+			$sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'";
1010
+			$sql .= ",status = ".$this->status;
1011 1011
 
1012 1012
 			// Local taxes
1013
-			$sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->db->escape($this->localtax1_assuj)."'":"null");
1014
-			$sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->db->escape($this->localtax2_assuj)."'":"null");
1015
-			if($this->localtax1_assuj==1)
1013
+			$sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null");
1014
+			$sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null");
1015
+			if ($this->localtax1_assuj == 1)
1016 1016
 			{
1017
-				if($this->localtax1_value!='')
1017
+				if ($this->localtax1_value != '')
1018 1018
 				{
1019
-					$sql .=",localtax1_value =".$this->localtax1_value;
1019
+					$sql .= ",localtax1_value =".$this->localtax1_value;
1020 1020
 				}
1021
-				else $sql .=",localtax1_value =0.000";
1021
+				else $sql .= ",localtax1_value =0.000";
1022 1022
 			}
1023
-			else $sql .=",localtax1_value =0.000";
1023
+			else $sql .= ",localtax1_value =0.000";
1024 1024
 
1025
-			if($this->localtax2_assuj==1)
1025
+			if ($this->localtax2_assuj == 1)
1026 1026
 			{
1027
-				if($this->localtax2_value!='')
1027
+				if ($this->localtax2_value != '')
1028 1028
 				{
1029
-					$sql .=",localtax2_value =".$this->localtax2_value;
1029
+					$sql .= ",localtax2_value =".$this->localtax2_value;
1030 1030
 				}
1031
-				else $sql .=",localtax2_value =0.000";
1031
+				else $sql .= ",localtax2_value =0.000";
1032 1032
 			}
1033
-			else $sql .=",localtax2_value =0.000";
1033
+			else $sql .= ",localtax2_value =0.000";
1034 1034
 
1035 1035
 			$sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital);
1036 1036
 
1037
-			$sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null");
1037
+			$sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null");
1038 1038
 
1039
-			$sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null");
1039
+			$sql .= ",fk_effectif = ".(!empty($this->effectif_id) ? "'".$this->db->escape($this->effectif_id)."'" : "null");
1040 1040
 			if (isset($this->stcomm_id))
1041 1041
 			{
1042
-				$sql .= ",fk_stcomm=".(!empty($this->stcomm_id)  ? $this->stcomm_id : "0");
1042
+				$sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0");
1043 1043
 			}
1044
-			$sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0");
1045
-
1046
-			$sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null");
1047
-
1048
-			$sql .= ",mode_reglement = ".(! empty($this->mode_reglement_id)?"'".$this->db->escape($this->mode_reglement_id)."'":"null");
1049
-			$sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null");
1050
-			$sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null");
1051
-			$sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null");
1052
-			$sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null");
1053
-
1054
-			$sql .= ",client = " . (! empty($this->client)?$this->client:0);
1055
-			$sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0);
1056
-			$sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null");
1057
-			$sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null");
1058
-			$sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null");
1059
-			$sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null');
1060
-			$sql .= ",order_min_amount= ".($this->order_min_amount!=''?$this->order_min_amount:'null');
1061
-			$sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount!=''?$this->supplier_order_min_amount:'null');
1044
+			$sql .= ",fk_typent = ".(!empty($this->typent_id) ? "'".$this->db->escape($this->typent_id)."'" : "0");
1045
+
1046
+			$sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null");
1047
+
1048
+			$sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null");
1049
+			$sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null");
1050
+			$sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null");
1051
+			$sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null");
1052
+			$sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null");
1053
+
1054
+			$sql .= ",client = ".(!empty($this->client) ? $this->client : 0);
1055
+			$sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0);
1056
+			$sql .= ",barcode = ".(!empty($this->barcode) ? "'".$this->db->escape($this->barcode)."'" : "null");
1057
+			$sql .= ",default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null");
1058
+			$sql .= ",logo = ".(!empty($this->logo) ? "'".$this->db->escape($this->logo)."'" : "null");
1059
+			$sql .= ",outstanding_limit= ".($this->outstanding_limit != '' ? $this->outstanding_limit : 'null');
1060
+			$sql .= ",order_min_amount= ".($this->order_min_amount != '' ? $this->order_min_amount : 'null');
1061
+			$sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null');
1062 1062
 			$sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'";
1063 1063
 
1064
-			$sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null");
1065
-			$sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null");
1064
+			$sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null");
1065
+			$sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null");
1066 1066
 
1067 1067
 			//Incoterms
1068
-			$sql.= ", fk_incoterms = ".$this->fk_incoterms;
1069
-			$sql.= ", location_incoterms = ".(! empty($this->location_incoterms)?"'".$this->db->escape($this->location_incoterms)."'":"null");
1068
+			$sql .= ", fk_incoterms = ".$this->fk_incoterms;
1069
+			$sql .= ", location_incoterms = ".(!empty($this->location_incoterms) ? "'".$this->db->escape($this->location_incoterms)."'" : "null");
1070 1070
 
1071 1071
 			if ($customer)
1072 1072
 			{
1073
-				$sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null");
1074
-				$sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null");
1073
+				$sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null");
1074
+				$sql .= ", code_compta = ".(!empty($this->code_compta) ? "'".$this->db->escape($this->code_compta)."'" : "null");
1075 1075
 			}
1076 1076
 
1077 1077
 			if ($supplier)
1078 1078
 			{
1079
-				$sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null");
1080
-				$sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
1079
+				$sql .= ", code_fournisseur = ".(!empty($this->code_fournisseur) ? "'".$this->db->escape($this->code_fournisseur)."'" : "null");
1080
+				$sql .= ", code_compta_fournisseur = ".(!empty($this->code_compta_fournisseur) ? "'".$this->db->escape($this->code_compta_fournisseur)."'" : "null");
1081 1081
 			}
1082
-			$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id:"null");
1082
+			$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : "null");
1083 1083
 			$sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency;
1084 1084
 			$sql .= ", multicurrency_code = '".$this->db->escape($this->multicurrency_code)."'";
1085
-			$sql .= " WHERE rowid = " . (int) $id;
1085
+			$sql .= " WHERE rowid = ".(int) $id;
1086 1086
 
1087
-			$resql=$this->db->query($sql);
1087
+			$resql = $this->db->query($sql);
1088 1088
 			if ($resql)
1089 1089
 			{
1090 1090
 				if (is_object($this->oldcopy))	// If we have information on old values
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 				}
1103 1103
 				else
1104 1104
 				{
1105
-					unset($this->country_code);	// We clean this, in the doubt, because it may have been changed after an update of country_id
1105
+					unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id
1106 1106
 					unset($this->country);
1107 1107
 					unset($this->state_code);
1108 1108
 					unset($this->state);
@@ -1110,67 +1110,67 @@  discard block
 block discarded – undo
1110 1110
 
1111 1111
 				$nbrowsaffected = $this->db->affected_rows($resql);
1112 1112
 
1113
-				if (! $error && $nbrowsaffected)
1113
+				if (!$error && $nbrowsaffected)
1114 1114
 				{
1115 1115
 					// Update information on linked member if it is an update
1116
-					if (! $nosyncmember && ! empty($conf->adherent->enabled))
1116
+					if (!$nosyncmember && !empty($conf->adherent->enabled))
1117 1117
 					{
1118 1118
 						require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1119 1119
 
1120 1120
 						dol_syslog(get_class($this)."::update update linked member");
1121 1121
 
1122
-						$lmember=new Adherent($this->db);
1123
-						$result=$lmember->fetch(0, 0, $this->id);
1122
+						$lmember = new Adherent($this->db);
1123
+						$result = $lmember->fetch(0, 0, $this->id);
1124 1124
 
1125 1125
 						if ($result > 0)
1126 1126
 						{
1127
-							$lmember->societe=$this->name;
1127
+							$lmember->societe = $this->name;
1128 1128
 							//$lmember->firstname=$this->firstname?$this->firstname:$lmember->firstname;	// We keep firstname and lastname of member unchanged
1129 1129
 							//$lmember->lastname=$this->lastname?$this->lastname:$lmember->lastname;		// We keep firstname and lastname of member unchanged
1130
-							$lmember->address=$this->address;
1131
-							$lmember->email=$this->email;
1132
-							$lmember->skype=$this->skype;
1133
-							$lmember->twitter=$this->twitter;
1134
-							$lmember->facebook=$this->facebook;
1135
-							$lmember->phone=$this->phone;
1136
-
1137
-							$result=$lmember->update($user,0,1,1,1);	// Use nosync to 1 to avoid cyclic updates
1130
+							$lmember->address = $this->address;
1131
+							$lmember->email = $this->email;
1132
+							$lmember->skype = $this->skype;
1133
+							$lmember->twitter = $this->twitter;
1134
+							$lmember->facebook = $this->facebook;
1135
+							$lmember->phone = $this->phone;
1136
+
1137
+							$result = $lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates
1138 1138
 							if ($result < 0)
1139 1139
 							{
1140
-								$this->error=$lmember->error;
1141
-								dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR);
1140
+								$this->error = $lmember->error;
1141
+								dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
1142 1142
 								$error++;
1143 1143
 							}
1144 1144
 						}
1145 1145
 						elseif ($result < 0)
1146 1146
 						{
1147
-							$this->error=$lmember->error;
1147
+							$this->error = $lmember->error;
1148 1148
 							$error++;
1149 1149
 						}
1150 1150
 					}
1151 1151
 				}
1152 1152
 
1153
-				$action='update';
1153
+				$action = 'update';
1154 1154
 
1155 1155
 				// Actions on extra fields
1156
-				if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1156
+				if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
1157 1157
 				{
1158
-					$result=$this->insertExtraFields();
1158
+					$result = $this->insertExtraFields();
1159 1159
 					if ($result < 0)
1160 1160
 					{
1161 1161
 						$error++;
1162 1162
 					}
1163 1163
 				}
1164 1164
 
1165
-				if (! $error && $call_trigger)
1165
+				if (!$error && $call_trigger)
1166 1166
 				{
1167 1167
 					// Call trigger
1168
-					$result=$this->call_trigger('COMPANY_MODIFY',$user);
1168
+					$result = $this->call_trigger('COMPANY_MODIFY', $user);
1169 1169
 					if ($result < 0) $error++;
1170 1170
 					// End call triggers
1171 1171
 				}
1172 1172
 
1173
-				if (! $error)
1173
+				if (!$error)
1174 1174
 				{
1175 1175
 					dol_syslog(get_class($this)."::Update success");
1176 1176
 					$this->db->commit();
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 		else
1203 1203
 	   {
1204 1204
 			$this->db->rollback();
1205
-			dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING);
1205
+			dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING);
1206 1206
 			return -3;
1207 1207
 		}
1208 1208
 	}
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 	 *    @param    string	$ref_alias 		Name_alias of third party (Warning, this can return several records)
1225 1225
 	 *    @return   int						>0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found.
1226 1226
 	 */
1227
-	function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='', $ref_alias='')
1227
+	function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
1228 1228
 	{
1229 1229
 		global $langs;
1230 1230
 		global $conf;
@@ -1279,13 +1279,13 @@  discard block
 block discarded – undo
1279 1279
 		if ($idprof6)   $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'";
1280 1280
 		if ($email)     $sql .= " AND s.email = '".$this->db->escape($email)."'";
1281 1281
 
1282
-		$resql=$this->db->query($sql);
1282
+		$resql = $this->db->query($sql);
1283 1283
 		if ($resql)
1284 1284
 		{
1285
-			$num=$this->db->num_rows($resql);
1285
+			$num = $this->db->num_rows($resql);
1286 1286
 			if ($num > 1)
1287 1287
 			{
1288
-				$this->error='Fetch found several records. Rename one of tirdparties to avoid duplicate.';
1288
+				$this->error = 'Fetch found several records. Rename one of tirdparties to avoid duplicate.';
1289 1289
 				dol_syslog($this->error, LOG_ERR);
1290 1290
 				$result = -2;
1291 1291
 			}
@@ -1295,11 +1295,11 @@  discard block
 block discarded – undo
1295 1295
 
1296 1296
 				$this->id           = $obj->rowid;
1297 1297
 				$this->entity       = $obj->entity;
1298
-				$this->canvas		= $obj->canvas;
1298
+				$this->canvas = $obj->canvas;
1299 1299
 
1300 1300
 				$this->ref          = $obj->rowid;
1301
-				$this->name 		= $obj->name;
1302
-				$this->nom          = $obj->name;		// deprecated
1301
+				$this->name = $obj->name;
1302
+				$this->nom          = $obj->name; // deprecated
1303 1303
 				$this->name_alias = $obj->name_alias;
1304 1304
 				$this->ref_ext      = $obj->ref_ext;
1305 1305
 				$this->ref_int      = $obj->ref_int;
@@ -1309,22 +1309,22 @@  discard block
 block discarded – undo
1309 1309
 				$this->user_creation     = $obj->fk_user_creat;
1310 1310
 				$this->user_modification = $obj->fk_user_modif;
1311 1311
 
1312
-				$this->address 		= $obj->address;
1312
+				$this->address = $obj->address;
1313 1313
 				$this->zip 			= $obj->zip;
1314 1314
 				$this->town 		= $obj->town;
1315 1315
 
1316 1316
 				$this->country_id   = $obj->country_id;
1317
-				$this->country_code = $obj->country_id?$obj->country_code:'';
1318
-				$this->country 		= $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):'';
1317
+				$this->country_code = $obj->country_id ? $obj->country_code : '';
1318
+				$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
1319 1319
 
1320 1320
 				$this->state_id     = $obj->fk_departement;
1321 1321
 				$this->state_code   = $obj->state_code;
1322
-				$this->state        = ($obj->state!='-'?$obj->state:'');
1322
+				$this->state        = ($obj->state != '-' ? $obj->state : '');
1323 1323
 
1324
-				$transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm);
1325
-				$libelle=($transcode!='StatusProspect'.$obj->fk_stcomm?$transcode:$obj->stcomm);
1326
-				$this->stcomm_id = $obj->fk_stcomm;     // id statut commercial
1327
-				$this->statut_commercial = $libelle;    // libelle statut commercial
1324
+				$transcode = $langs->trans('StatusProspect'.$obj->fk_stcomm);
1325
+				$libelle = ($transcode != 'StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm);
1326
+				$this->stcomm_id = $obj->fk_stcomm; // id statut commercial
1327
+				$this->statut_commercial = $libelle; // libelle statut commercial
1328 1328
 
1329 1329
 				$this->email = $obj->email;
1330 1330
 				$this->skype = $obj->skype;
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
 				$this->phone = $obj->phone;
1335 1335
 				$this->fax = $obj->fax;
1336 1336
 
1337
-				$this->parent    = $obj->parent;
1337
+				$this->parent = $obj->parent;
1338 1338
 
1339 1339
 				$this->idprof1		= $obj->idprof1;
1340 1340
 				$this->idprof2		= $obj->idprof2;
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 				$this->idprof5		= $obj->idprof5;
1344 1344
 				$this->idprof6		= $obj->idprof6;
1345 1345
 
1346
-				$this->capital   = $obj->capital;
1346
+				$this->capital = $obj->capital;
1347 1347
 
1348 1348
 				$this->code_client = $obj->code_client;
1349 1349
 				$this->code_fournisseur = $obj->code_fournisseur;
@@ -1368,23 +1368,23 @@  discard block
 block discarded – undo
1368 1368
 				$this->typent_code    = $obj->typent_code;
1369 1369
 
1370 1370
 				$this->effectif_id    = $obj->effectif_id;
1371
-				$this->effectif       = $obj->effectif_id?$obj->effectif:'';
1371
+				$this->effectif       = $obj->effectif_id ? $obj->effectif : '';
1372 1372
 
1373
-				$this->forme_juridique_code= $obj->forme_juridique_code;
1374
-				$this->forme_juridique     = $obj->forme_juridique_code?$obj->forme_juridique:'';
1373
+				$this->forme_juridique_code = $obj->forme_juridique_code;
1374
+				$this->forme_juridique     = $obj->forme_juridique_code ? $obj->forme_juridique : '';
1375 1375
 
1376 1376
 				$this->fk_prospectlevel = $obj->fk_prospectlevel;
1377 1377
 
1378 1378
 				$this->prefix_comm = $obj->prefix_comm;
1379 1379
 
1380
-				$this->remise_percent		= $obj->remise_client;
1381
-				$this->remise_supplier_percent		= $obj->remise_supplier;
1380
+				$this->remise_percent = $obj->remise_client;
1381
+				$this->remise_supplier_percent = $obj->remise_supplier;
1382 1382
 				$this->mode_reglement_id 	= $obj->mode_reglement;
1383 1383
 				$this->cond_reglement_id 	= $obj->cond_reglement;
1384 1384
 				$this->mode_reglement_supplier_id 	= $obj->mode_reglement_supplier;
1385 1385
 				$this->cond_reglement_supplier_id 	= $obj->cond_reglement_supplier;
1386
-				$this->shipping_method_id   = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
1387
-				$this->fk_account			= $obj->fk_account;
1386
+				$this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null;
1387
+				$this->fk_account = $obj->fk_account;
1388 1388
 
1389 1389
 				$this->client      = $obj->client;
1390 1390
 				$this->fournisseur = $obj->fournisseur;
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 
1402 1402
 				$this->outstanding_limit		= $obj->outstanding_limit;
1403 1403
 				$this->order_min_amount			= $obj->order_min_amount;
1404
-				$this->supplier_order_min_amount	= $obj->supplier_order_min_amount;
1404
+				$this->supplier_order_min_amount = $obj->supplier_order_min_amount;
1405 1405
 
1406 1406
 				// multiprix
1407 1407
 				$this->price_level = $obj->price_level;
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
 		}
1432 1432
 		else
1433 1433
 		{
1434
-			$this->error=$this->db->lasterror();
1434
+			$this->error = $this->db->lasterror();
1435 1435
 			$result = -3;
1436 1436
 		}
1437 1437
 
1438 1438
 		// Use first price level if level not defined for third party
1439
-		if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) $this->price_level=1;
1439
+		if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) $this->price_level = 1;
1440 1440
 
1441 1441
 		return $result;
1442 1442
 	}
@@ -1449,15 +1449,15 @@  discard block
 block discarded – undo
1449 1449
 	 *    @param    int		$call_trigger   0=No, 1=yes
1450 1450
 	 *    @return	int						<0 if KO, 0 if nothing done, >0 if OK
1451 1451
 	 */
1452
-	function delete($id, User $fuser=null, $call_trigger=1)
1452
+	function delete($id, User $fuser = null, $call_trigger = 1)
1453 1453
 	{
1454 1454
 		global $langs, $conf, $user;
1455 1455
 
1456
-		if (empty($fuser)) $fuser=$user;
1456
+		if (empty($fuser)) $fuser = $user;
1457 1457
 
1458 1458
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1459 1459
 
1460
-		$entity=isset($this->entity)?$this->entity:$conf->entity;
1460
+		$entity = isset($this->entity) ? $this->entity : $conf->entity;
1461 1461
 
1462 1462
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
1463 1463
 		$error = 0;
@@ -1469,15 +1469,15 @@  discard block
 block discarded – undo
1469 1469
 			$this->db->begin();
1470 1470
 
1471 1471
 			// User is mandatory for trigger call
1472
-			if (! $error && $call_trigger)
1472
+			if (!$error && $call_trigger)
1473 1473
 			{
1474 1474
 				// Call trigger
1475
-				$result=$this->call_trigger('COMPANY_DELETE',$fuser);
1475
+				$result = $this->call_trigger('COMPANY_DELETE', $fuser);
1476 1476
 				if ($result < 0) $error++;
1477 1477
 				// End call triggers
1478 1478
 			}
1479 1479
 
1480
-			if (! $error)
1480
+			if (!$error)
1481 1481
 			{
1482 1482
 				require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1483 1483
 				$static_cat = new Categorie($this->db);
@@ -1486,11 +1486,11 @@  discard block
 block discarded – undo
1486 1486
 				// Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
1487 1487
 				if ($this->client || $this->prospect)
1488 1488
 				{
1489
-					$toute_categs['customer'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER);
1489
+					$toute_categs['customer'] = $static_cat->containing($this->id, Categorie::TYPE_CUSTOMER);
1490 1490
 				}
1491 1491
 				if ($this->fournisseur)
1492 1492
 				{
1493
-					$toute_categs['supplier'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER);
1493
+					$toute_categs['supplier'] = $static_cat->containing($this->id, Categorie::TYPE_SUPPLIER);
1494 1494
 				}
1495 1495
 
1496 1496
 				// Remove each "Categorie"
@@ -1505,11 +1505,11 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
 			foreach ($this->childtablesoncascade as $tabletodelete)
1507 1507
 			{
1508
-				if (! $error)
1508
+				if (!$error)
1509 1509
 				{
1510 1510
 					$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete;
1511
-					$sql.= " WHERE fk_soc = " . $id;
1512
-					if (! $this->db->query($sql))
1511
+					$sql .= " WHERE fk_soc = ".$id;
1512
+					if (!$this->db->query($sql))
1513 1513
 					{
1514 1514
 						$error++;
1515 1515
 						$this->errors[] = $this->db->lasterror();
@@ -1518,9 +1518,9 @@  discard block
 block discarded – undo
1518 1518
 			}
1519 1519
 
1520 1520
 			// Removed extrafields
1521
-			if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
1521
+			if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
1522 1522
 			{
1523
-				$result=$this->deleteExtraFields();
1523
+				$result = $this->deleteExtraFields();
1524 1524
 				if ($result < 0)
1525 1525
 				{
1526 1526
 					$error++;
@@ -1529,12 +1529,12 @@  discard block
 block discarded – undo
1529 1529
 			}
1530 1530
 
1531 1531
 			// Remove links to subsidiaries companies
1532
-			if (! $error)
1532
+			if (!$error)
1533 1533
 			{
1534 1534
 				$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
1535
-				$sql.= " SET parent = NULL";
1536
-				$sql.= " WHERE parent = " . $id;
1537
-				if (! $this->db->query($sql))
1535
+				$sql .= " SET parent = NULL";
1536
+				$sql .= " WHERE parent = ".$id;
1537
+				if (!$this->db->query($sql))
1538 1538
 				{
1539 1539
 					$error++;
1540 1540
 					$this->errors[] = $this->db->lasterror();
@@ -1542,25 +1542,25 @@  discard block
 block discarded – undo
1542 1542
 			}
1543 1543
 
1544 1544
 			// Remove third party
1545
-			if (! $error)
1545
+			if (!$error)
1546 1546
 			{
1547 1547
 				$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
1548
-				$sql.= " WHERE rowid = " . $id;
1549
-				if (! $this->db->query($sql))
1548
+				$sql .= " WHERE rowid = ".$id;
1549
+				if (!$this->db->query($sql))
1550 1550
 				{
1551 1551
 					$error++;
1552 1552
 					$this->errors[] = $this->db->lasterror();
1553 1553
 				}
1554 1554
 			}
1555 1555
 
1556
-			if (! $error)
1556
+			if (!$error)
1557 1557
 			{
1558 1558
 				$this->db->commit();
1559 1559
 
1560 1560
 				// Delete directory
1561
-				if (! empty($conf->societe->multidir_output[$entity]))
1561
+				if (!empty($conf->societe->multidir_output[$entity]))
1562 1562
 				{
1563
-					$docdir = $conf->societe->multidir_output[$entity] . "/" . $id;
1563
+					$docdir = $conf->societe->multidir_output[$entity]."/".$id;
1564 1564
 					if (dol_is_dir($docdir))
1565 1565
 					{
1566 1566
 						dol_delete_dir_recursive($docdir);
@@ -1591,13 +1591,13 @@  discard block
 block discarded – undo
1591 1591
         // phpcs:enable
1592 1592
 		if ($this->id)
1593 1593
 		{
1594
-			$newclient=1;
1595
-			if ($this->client == 2 || $this->client == 3) $newclient=3;	//If prospect, we keep prospect tag
1594
+			$newclient = 1;
1595
+			if ($this->client == 2 || $this->client == 3) $newclient = 3; //If prospect, we keep prospect tag
1596 1596
 			$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
1597
-			$sql.= " SET client = ".$newclient;
1598
-			$sql.= " WHERE rowid = " . $this->id;
1597
+			$sql .= " SET client = ".$newclient;
1598
+			$sql .= " WHERE rowid = ".$this->id;
1599 1599
 
1600
-			$resql=$this->db->query($sql);
1600
+			$resql = $this->db->query($sql);
1601 1601
 			if ($resql)
1602 1602
 			{
1603 1603
 				$this->client = $newclient;
@@ -1623,10 +1623,10 @@  discard block
 block discarded – undo
1623 1623
 		global $conf, $langs;
1624 1624
 
1625 1625
 		// Nettoyage parametres
1626
-		$note=trim($note);
1627
-		if (! $note)
1626
+		$note = trim($note);
1627
+		if (!$note)
1628 1628
 		{
1629
-			$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason"));
1629
+			$this->error = $langs->trans("ErrorFieldRequired", $langs->trans("NoteReason"));
1630 1630
 			return -2;
1631 1631
 		}
1632 1632
 
@@ -1636,33 +1636,33 @@  discard block
 block discarded – undo
1636 1636
 		{
1637 1637
 			$this->db->begin();
1638 1638
 
1639
-			$now=dol_now();
1639
+			$now = dol_now();
1640 1640
 
1641 1641
 			// Positionne remise courante
1642 1642
 			$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
1643
-			$sql.= " SET remise_client = '".$this->db->escape($remise)."'";
1644
-			$sql.= " WHERE rowid = " . $this->id;
1645
-			$resql=$this->db->query($sql);
1646
-			if (! $resql)
1643
+			$sql .= " SET remise_client = '".$this->db->escape($remise)."'";
1644
+			$sql .= " WHERE rowid = ".$this->id;
1645
+			$resql = $this->db->query($sql);
1646
+			if (!$resql)
1647 1647
 			{
1648 1648
 				$this->db->rollback();
1649
-				$this->error=$this->db->error();
1649
+				$this->error = $this->db->error();
1650 1650
 				return -1;
1651 1651
 			}
1652 1652
 
1653 1653
 			// Ecrit trace dans historique des remises
1654 1654
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise";
1655
-			$sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)";
1656
-			$sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
1657
-			$sql.= " '".$this->db->escape($note)."',";
1658
-			$sql.= " ".$user->id;
1659
-			$sql.= ")";
1660
-
1661
-			$resql=$this->db->query($sql);
1662
-			if (! $resql)
1655
+			$sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)";
1656
+			$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
1657
+			$sql .= " '".$this->db->escape($note)."',";
1658
+			$sql .= " ".$user->id;
1659
+			$sql .= ")";
1660
+
1661
+			$resql = $this->db->query($sql);
1662
+			if (!$resql)
1663 1663
 			{
1664 1664
 				$this->db->rollback();
1665
-				$this->error=$this->db->lasterror();
1665
+				$this->error = $this->db->lasterror();
1666 1666
 				return -1;
1667 1667
 			}
1668 1668
 
@@ -1686,10 +1686,10 @@  discard block
 block discarded – undo
1686 1686
 		global $conf, $langs;
1687 1687
 
1688 1688
 		// Nettoyage parametres
1689
-		$note=trim($note);
1690
-		if (! $note)
1689
+		$note = trim($note);
1690
+		if (!$note)
1691 1691
 		{
1692
-			$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason"));
1692
+			$this->error = $langs->trans("ErrorFieldRequired", $langs->trans("NoteReason"));
1693 1693
 			return -2;
1694 1694
 		}
1695 1695
 
@@ -1699,33 +1699,33 @@  discard block
 block discarded – undo
1699 1699
 		{
1700 1700
 			$this->db->begin();
1701 1701
 
1702
-			$now=dol_now();
1702
+			$now = dol_now();
1703 1703
 
1704 1704
 			// Positionne remise courante
1705 1705
 			$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
1706
-			$sql.= " SET remise_supplier = '".$this->db->escape($remise)."'";
1707
-			$sql.= " WHERE rowid = " . $this->id;
1708
-			$resql=$this->db->query($sql);
1709
-			if (! $resql)
1706
+			$sql .= " SET remise_supplier = '".$this->db->escape($remise)."'";
1707
+			$sql .= " WHERE rowid = ".$this->id;
1708
+			$resql = $this->db->query($sql);
1709
+			if (!$resql)
1710 1710
 			{
1711 1711
 				$this->db->rollback();
1712
-				$this->error=$this->db->error();
1712
+				$this->error = $this->db->error();
1713 1713
 				return -1;
1714 1714
 			}
1715 1715
 
1716 1716
 			// Ecrit trace dans historique des remises
1717 1717
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier";
1718
-			$sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)";
1719
-			$sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
1720
-			$sql.= " '".$this->db->escape($note)."',";
1721
-			$sql.= " ".$user->id;
1722
-			$sql.= ")";
1723
-
1724
-			$resql=$this->db->query($sql);
1725
-			if (! $resql)
1718
+			$sql .= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)";
1719
+			$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
1720
+			$sql .= " '".$this->db->escape($note)."',";
1721
+			$sql .= " ".$user->id;
1722
+			$sql .= ")";
1723
+
1724
+			$resql = $this->db->query($sql);
1725
+			if (!$resql)
1726 1726
 			{
1727 1727
 				$this->db->rollback();
1728
-				$this->error=$this->db->lasterror();
1728
+				$this->error = $this->db->lasterror();
1729 1729
 				return -1;
1730 1730
 			}
1731 1731
 
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 	 *      @param	int		$discount_type	0 => customer discount, 1 => supplier discount
1746 1746
 	 *		@return	int					<0 if KO, id of discount record if OK
1747 1747
 	 */
1748
-	function set_remise_except($remise, User $user, $desc, $tva_tx=0, $discount_type=0)
1748
+	function set_remise_except($remise, User $user, $desc, $tva_tx = 0, $discount_type = 0)
1749 1749
 	{
1750 1750
         // phpcs:enable
1751 1751
 		global $langs;
@@ -1755,14 +1755,14 @@  discard block
 block discarded – undo
1755 1755
 		$desc = trim($desc);
1756 1756
 
1757 1757
 		// Check parameters
1758
-		if (! $remise > 0)
1758
+		if (!$remise > 0)
1759 1759
 		{
1760
-			$this->error=$langs->trans("ErrorWrongValueForParameter","1");
1760
+			$this->error = $langs->trans("ErrorWrongValueForParameter", "1");
1761 1761
 			return -1;
1762 1762
 		}
1763
-		if (! $desc)
1763
+		if (!$desc)
1764 1764
 		{
1765
-			$this->error=$langs->trans("ErrorWrongValueForParameter","3");
1765
+			$this->error = $langs->trans("ErrorWrongValueForParameter", "3");
1766 1766
 			return -2;
1767 1767
 		}
1768 1768
 
@@ -1771,25 +1771,25 @@  discard block
 block discarded – undo
1771 1771
 			require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
1772 1772
 
1773 1773
 			$discount = new DiscountAbsolute($this->db);
1774
-			$discount->fk_soc=$this->id;
1774
+			$discount->fk_soc = $this->id;
1775 1775
 
1776
-			$discount->discount_type=$discount_type;
1776
+			$discount->discount_type = $discount_type;
1777 1777
 
1778
-			$discount->amount_ht=$discount->multicurrency_amount_ht=price2num($remise,'MT');
1779
-			$discount->amount_tva=$discount->multicurrency_amount_tva=price2num($remise*$tva_tx/100,'MT');
1780
-			$discount->amount_ttc=$discount->multicurrency_amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT');
1778
+			$discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT');
1779
+			$discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $tva_tx / 100, 'MT');
1780
+			$discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT');
1781 1781
 
1782
-			$discount->tva_tx=price2num($tva_tx,'MT');
1783
-			$discount->description=$desc;
1782
+			$discount->tva_tx = price2num($tva_tx, 'MT');
1783
+			$discount->description = $desc;
1784 1784
 
1785
-			$result=$discount->create($user);
1785
+			$result = $discount->create($user);
1786 1786
 			if ($result > 0)
1787 1787
 			{
1788 1788
 				return $result;
1789 1789
 			}
1790 1790
 			else
1791 1791
 			{
1792
-				$this->error=$discount->error;
1792
+				$this->error = $discount->error;
1793 1793
 				return -3;
1794 1794
 			}
1795 1795
 		}
@@ -1805,19 +1805,19 @@  discard block
 block discarded – undo
1805 1805
 	 * 	@param	int		$discount_type	0 => customer discount, 1 => supplier discount
1806 1806
 	 *	@return	int					<0 if KO, Credit note amount otherwise
1807 1807
 	 */
1808
-	function getAvailableDiscounts($user='',$filter='',$maxvalue=0,$discount_type=0)
1808
+	function getAvailableDiscounts($user = '', $filter = '', $maxvalue = 0, $discount_type = 0)
1809 1809
 	{
1810 1810
 		require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
1811 1811
 
1812
-		$discountstatic=new DiscountAbsolute($this->db);
1813
-		$result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue,$discount_type);
1812
+		$discountstatic = new DiscountAbsolute($this->db);
1813
+		$result = $discountstatic->getAvailableDiscounts($this, $user, $filter, $maxvalue, $discount_type);
1814 1814
 		if ($result >= 0)
1815 1815
 		{
1816 1816
 			return $result;
1817 1817
 		}
1818 1818
 		else
1819 1819
 		{
1820
-			$this->error=$discountstatic->error;
1820
+			$this->error = $discountstatic->error;
1821 1821
 			return -1;
1822 1822
 		}
1823 1823
 	}
@@ -1829,49 +1829,49 @@  discard block
 block discarded – undo
1829 1829
 	 *  @param	int		$mode		0=Array with properties, 1=Array of id.
1830 1830
 	 *  @return array       		Array of sales representatives of third party
1831 1831
 	 */
1832
-	function getSalesRepresentatives(User $user, $mode=0)
1832
+	function getSalesRepresentatives(User $user, $mode = 0)
1833 1833
 	{
1834 1834
 		global $conf;
1835 1835
 
1836
-		$reparray=array();
1836
+		$reparray = array();
1837 1837
 
1838 1838
 		$sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo";
1839
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
1840
-		if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
1839
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
1840
+		if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
1841 1841
 		{
1842
-			$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
1843
-			$sql.= " WHERE ((ug.fk_user = sc.fk_user";
1844
-			$sql.= " AND ug.entity = ".$conf->entity.")";
1845
-			$sql.= " OR u.admin = 1)";
1842
+			$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
1843
+			$sql .= " WHERE ((ug.fk_user = sc.fk_user";
1844
+			$sql .= " AND ug.entity = ".$conf->entity.")";
1845
+			$sql .= " OR u.admin = 1)";
1846 1846
 		}
1847 1847
 		else
1848
-			$sql.= " WHERE entity in (0, ".$conf->entity.")";
1848
+			$sql .= " WHERE entity in (0, ".$conf->entity.")";
1849 1849
 
1850
-		$sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id;
1850
+		$sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id;
1851 1851
 
1852 1852
 		$resql = $this->db->query($sql);
1853 1853
 		if ($resql)
1854 1854
 		{
1855 1855
 			$num = $this->db->num_rows($resql);
1856
-			$i=0;
1856
+			$i = 0;
1857 1857
 			while ($i < $num)
1858 1858
 			{
1859 1859
 				$obj = $this->db->fetch_object($resql);
1860 1860
 
1861 1861
 				if (empty($mode))
1862 1862
 				{
1863
-					$reparray[$i]['id']=$obj->rowid;
1864
-					$reparray[$i]['lastname']=$obj->lastname;
1865
-					$reparray[$i]['firstname']=$obj->firstname;
1866
-					$reparray[$i]['email']=$obj->email;
1867
-					$reparray[$i]['statut']=$obj->statut;
1868
-					$reparray[$i]['entity']=$obj->entity;
1869
-					$reparray[$i]['login']=$obj->login;
1870
-					$reparray[$i]['photo']=$obj->photo;
1863
+					$reparray[$i]['id'] = $obj->rowid;
1864
+					$reparray[$i]['lastname'] = $obj->lastname;
1865
+					$reparray[$i]['firstname'] = $obj->firstname;
1866
+					$reparray[$i]['email'] = $obj->email;
1867
+					$reparray[$i]['statut'] = $obj->statut;
1868
+					$reparray[$i]['entity'] = $obj->entity;
1869
+					$reparray[$i]['login'] = $obj->login;
1870
+					$reparray[$i]['photo'] = $obj->photo;
1871 1871
 				}
1872 1872
 				else
1873 1873
 				{
1874
-					$reparray[]=$obj->rowid;
1874
+					$reparray[] = $obj->rowid;
1875 1875
 				}
1876 1876
 				$i++;
1877 1877
 			}
@@ -1896,13 +1896,13 @@  discard block
 block discarded – undo
1896 1896
         // phpcs:enable
1897 1897
 		if ($this->id)
1898 1898
 		{
1899
-			$now=dol_now();
1899
+			$now = dol_now();
1900 1900
 
1901 1901
 			$sql  = "UPDATE ".MAIN_DB_PREFIX."societe";
1902 1902
 			$sql .= " SET price_level = '".$this->db->escape($price_level)."'";
1903
-			$sql .= " WHERE rowid = " . $this->id;
1903
+			$sql .= " WHERE rowid = ".$this->id;
1904 1904
 
1905
-			if (! $this->db->query($sql))
1905
+			if (!$this->db->query($sql))
1906 1906
 			{
1907 1907
 				dol_print_error($this->db);
1908 1908
 				return -1;
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
 			$sql .= " (datec, fk_soc, price_level, fk_user_author)";
1913 1913
 			$sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")";
1914 1914
 
1915
-			if (! $this->db->query($sql))
1915
+			if (!$this->db->query($sql))
1916 1916
 			{
1917 1917
 				dol_print_error($this->db);
1918 1918
 				return -1;
@@ -1933,28 +1933,28 @@  discard block
 block discarded – undo
1933 1933
 	function add_commercial(User $user, $commid)
1934 1934
 	{
1935 1935
         // phpcs:enable
1936
-		$error=0;
1936
+		$error = 0;
1937 1937
 
1938 1938
 
1939 1939
 		if ($this->id > 0 && $commid > 0)
1940 1940
 		{
1941 1941
 			$sql = "DELETE FROM  ".MAIN_DB_PREFIX."societe_commerciaux";
1942
-			$sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid;
1942
+			$sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid;
1943 1943
 
1944 1944
 			$this->db->query($sql);
1945 1945
 
1946 1946
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux";
1947
-			$sql.= " ( fk_soc, fk_user )";
1948
-			$sql.= " VALUES (".$this->id.",".$commid.")";
1947
+			$sql .= " ( fk_soc, fk_user )";
1948
+			$sql .= " VALUES (".$this->id.",".$commid.")";
1949 1949
 
1950
-			if (! $this->db->query($sql) )
1950
+			if (!$this->db->query($sql))
1951 1951
 			{
1952 1952
 				dol_syslog(get_class($this)."::add_commercial Erreur");
1953 1953
 			}
1954 1954
 			else {
1955
-				$this->context=array('commercial_modified'=>$commid);
1955
+				$this->context = array('commercial_modified'=>$commid);
1956 1956
 
1957
-				$result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user);
1957
+				$result = $this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user);
1958 1958
                 if ($result < 0) $error++;
1959 1959
 			}
1960 1960
 		}
@@ -1971,10 +1971,10 @@  discard block
 block discarded – undo
1971 1971
 	function del_commercial(User $user, $commid)
1972 1972
 	{
1973 1973
         // phpcs:enable
1974
-		$error=0;
1975
-		$this->context=array('commercial_modified'=>$commid);
1974
+		$error = 0;
1975
+		$this->context = array('commercial_modified'=>$commid);
1976 1976
 
1977
-		$result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user);
1977
+		$result = $this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE', $user);
1978 1978
         if ($result < 0) $error++;
1979 1979
 
1980 1980
 		if ($this->id > 0 && $commid > 0)
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 			$sql  = "DELETE FROM  ".MAIN_DB_PREFIX."societe_commerciaux ";
1983 1983
 			$sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid;
1984 1984
 
1985
-			if (! $this->db->query($sql) )
1985
+			if (!$this->db->query($sql))
1986 1986
 			{
1987 1987
 				dol_syslog(get_class($this)."::del_commercial Erreur");
1988 1988
 			}
@@ -2000,162 +2000,162 @@  discard block
 block discarded – undo
2000 2000
 	 *      @param  int     $save_lastsearch_value    -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
2001 2001
 	 *		@return	string					          String with URL
2002 2002
 	 */
2003
-	function getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0, $save_lastsearch_value=-1)
2003
+	function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip = 0, $save_lastsearch_value = -1)
2004 2004
 	{
2005 2005
 		global $conf, $langs, $hookmanager;
2006 2006
 
2007
-		if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
2007
+		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
2008 2008
 
2009
-		$name=$this->name?$this->name:$this->nom;
2009
+		$name = $this->name ? $this->name : $this->nom;
2010 2010
 
2011
-		if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){
2011
+		if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) {
2012 2012
 
2013
-             if(empty($option) && $this->client > 0) $option = 'customer';
2014
-             if(empty($option) && $this->fournisseur > 0) $option = 'supplier';
2013
+             if (empty($option) && $this->client > 0) $option = 'customer';
2014
+             if (empty($option) && $this->fournisseur > 0) $option = 'supplier';
2015 2015
          }
2016 2016
 
2017 2017
 
2018
-		if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto)))
2018
+		if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto)))
2019 2019
 		{
2020 2020
 			$code = '';
2021
-			if (($this->client) && (! empty ( $this->code_client ))
2021
+			if (($this->client) && (!empty ($this->code_client))
2022 2022
 				&& ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1
2023 2023
 				|| $conf->global->SOCIETE_ADD_REF_IN_LIST == 2
2024 2024
 				)
2025 2025
 			)
2026 2026
 			{
2027
-				$code = $this->code_client . ' - ';
2027
+				$code = $this->code_client.' - ';
2028 2028
 			}
2029 2029
 
2030
-			if (($this->fournisseur) && (! empty ( $this->code_fournisseur ))
2030
+			if (($this->fournisseur) && (!empty ($this->code_fournisseur))
2031 2031
 				&& ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1
2032 2032
 				|| $conf->global->SOCIETE_ADD_REF_IN_LIST == 3
2033 2033
 				)
2034 2034
 			)
2035 2035
 			{
2036
-				$code .= $this->code_fournisseur . ' - ';
2036
+				$code .= $this->code_fournisseur.' - ';
2037 2037
 			}
2038 2038
 
2039 2039
 			if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1)
2040 2040
 			{
2041
-				$name =$code.' '.$name;
2041
+				$name = $code.' '.$name;
2042 2042
 			}
2043 2043
 			else
2044 2044
 			{
2045
-				$name =$code;
2045
+				$name = $code;
2046 2046
 			}
2047 2047
 		}
2048 2048
 
2049 2049
 		if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')';
2050 2050
 
2051
-		$result=''; $label='';
2052
-		$linkstart=''; $linkend='';
2051
+		$result = ''; $label = '';
2052
+		$linkstart = ''; $linkend = '';
2053 2053
 
2054
-		if (! empty($this->logo) && class_exists('Form'))
2054
+		if (!empty($this->logo) && class_exists('Form'))
2055 2055
 		{
2056
-			$label.= '<div class="photointooltip">';
2057
-			$label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0);	// Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
2058
-			$label.= '</div><div style="clear: both;"></div>';
2056
+			$label .= '<div class="photointooltip">';
2057
+			$label .= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
2058
+			$label .= '</div><div style="clear: both;"></div>';
2059 2059
 		}
2060 2060
 
2061
-		$label.= '<div class="centpercent">';
2061
+		$label .= '<div class="centpercent">';
2062 2062
 
2063 2063
 		if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier')
2064 2064
 		{
2065
-		   $label.= '<u>' . $langs->trans("ShowCustomer") . '</u>';
2065
+		   $label .= '<u>'.$langs->trans("ShowCustomer").'</u>';
2066 2066
 		   $linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
2067 2067
 		}
2068 2068
 		elseif ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
2069 2069
 		{
2070
-			$label.= '<u>' . $langs->trans("ShowProspect") . '</u>';
2070
+			$label .= '<u>'.$langs->trans("ShowProspect").'</u>';
2071 2071
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
2072 2072
 		}
2073 2073
 		elseif ($option == 'supplier')
2074 2074
 		{
2075
-			$label.= '<u>' . $langs->trans("ShowSupplier") . '</u>';
2075
+			$label .= '<u>'.$langs->trans("ShowSupplier").'</u>';
2076 2076
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id;
2077 2077
 		}
2078 2078
 		elseif ($option == 'agenda')
2079 2079
 		{
2080
-			$label.= '<u>' . $langs->trans("ShowAgenda") . '</u>';
2080
+			$label .= '<u>'.$langs->trans("ShowAgenda").'</u>';
2081 2081
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/agenda.php?socid='.$this->id;
2082 2082
 		}
2083 2083
 		elseif ($option == 'project')
2084 2084
 		{
2085
-			$label.= '<u>' . $langs->trans("ShowProject") . '</u>';
2085
+			$label .= '<u>'.$langs->trans("ShowProject").'</u>';
2086 2086
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/project.php?socid='.$this->id;
2087 2087
 		}
2088 2088
 		elseif ($option == 'margin')
2089 2089
 		{
2090
-			$label.= '<u>' . $langs->trans("ShowMargin") . '</u>';
2090
+			$label .= '<u>'.$langs->trans("ShowMargin").'</u>';
2091 2091
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1';
2092 2092
 		}
2093 2093
 		elseif ($option == 'contact')
2094 2094
 		{
2095
-			$label.= '<u>' . $langs->trans("ShowContacts") . '</u>';
2095
+			$label .= '<u>'.$langs->trans("ShowContacts").'</u>';
2096 2096
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/contact.php?socid='.$this->id;
2097 2097
 		}
2098 2098
 		elseif ($option == 'ban')
2099 2099
 		{
2100
-			$label.= '<u>' . $langs->trans("ShowBan") . '</u>';
2100
+			$label .= '<u>'.$langs->trans("ShowBan").'</u>';
2101 2101
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$this->id;
2102 2102
 		}
2103 2103
 
2104 2104
 		// By default
2105 2105
 		if (empty($linkstart))
2106 2106
 		{
2107
-			$label.= '<u>' . $langs->trans("ShowCompany") . '</u>';
2107
+			$label .= '<u>'.$langs->trans("ShowCompany").'</u>';
2108 2108
 			$linkstart = '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$this->id;
2109 2109
 		}
2110 2110
 
2111
-		if (! empty($this->name))
2111
+		if (!empty($this->name))
2112 2112
 		{
2113
-			$label.= '<br><b>' . $langs->trans('Name') . ':</b> '. $this->name;
2114
-			if (! empty($this->name_alias)) $label.=' ('.$this->name_alias.')';
2115
-			$label.= '<br><b>' . $langs->trans('Email') . ':</b> '. $this->email;
2116
-		}
2117
-		if (! empty($this->country_code))
2118
-			$label.= '<br><b>' . $langs->trans('Country') . ':</b> '. $this->country_code;
2119
-		if (! empty($this->tva_intra) || (! empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false))
2120
-			$label.= '<br><b>' . $langs->trans('VATIntra') . ':</b> '. $this->tva_intra;
2121
-		if (! empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP))
2113
+			$label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->name;
2114
+			if (!empty($this->name_alias)) $label .= ' ('.$this->name_alias.')';
2115
+			$label .= '<br><b>'.$langs->trans('Email').':</b> '.$this->email;
2116
+		}
2117
+		if (!empty($this->country_code))
2118
+			$label .= '<br><b>'.$langs->trans('Country').':</b> '.$this->country_code;
2119
+		if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false))
2120
+			$label .= '<br><b>'.$langs->trans('VATIntra').':</b> '.$this->tva_intra;
2121
+		if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP))
2122 2122
 		{
2123
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false) $label.= '<br><b>' . $langs->trans('ProfId1'.$this->country_code) . ':</b> '. $this->idprof1;
2124
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false) $label.= '<br><b>' . $langs->trans('ProfId2'.$this->country_code) . ':</b> '. $this->idprof2;
2125
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false) $label.= '<br><b>' . $langs->trans('ProfId3'.$this->country_code) . ':</b> '. $this->idprof3;
2126
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false) $label.= '<br><b>' . $langs->trans('ProfId4'.$this->country_code) . ':</b> '. $this->idprof4;
2127
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false) $label.= '<br><b>' . $langs->trans('ProfId5'.$this->country_code) . ':</b> '. $this->idprof5;
2128
-			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false) $label.= '<br><b>' . $langs->trans('ProfId6'.$this->country_code) . ':</b> '. $this->idprof6;
2129
-		}
2130
-		if (! empty($this->code_client) && ($this->client == 1 || $this->client == 3))
2131
-			$label.= '<br><b>' . $langs->trans('CustomerCode') . ':</b> '. $this->code_client;
2132
-		if (! empty($this->code_fournisseur) && $this->fournisseur)
2133
-			$label.= '<br><b>' . $langs->trans('SupplierCode') . ':</b> '. $this->code_fournisseur;
2134
-		if (! empty($conf->accounting->enabled) && ($this->client == 1 || $this->client == 3))
2135
-			$label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. ($this->code_compta ? $this->code_compta : $this->code_compta_client);
2136
-		if (! empty($conf->accounting->enabled) && $this->fournisseur)
2137
-			$label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur;
2138
-
2139
-		$label.= '</div>';
2123
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false) $label .= '<br><b>'.$langs->trans('ProfId1'.$this->country_code).':</b> '.$this->idprof1;
2124
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false) $label .= '<br><b>'.$langs->trans('ProfId2'.$this->country_code).':</b> '.$this->idprof2;
2125
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false) $label .= '<br><b>'.$langs->trans('ProfId3'.$this->country_code).':</b> '.$this->idprof3;
2126
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false) $label .= '<br><b>'.$langs->trans('ProfId4'.$this->country_code).':</b> '.$this->idprof4;
2127
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false) $label .= '<br><b>'.$langs->trans('ProfId5'.$this->country_code).':</b> '.$this->idprof5;
2128
+			if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false) $label .= '<br><b>'.$langs->trans('ProfId6'.$this->country_code).':</b> '.$this->idprof6;
2129
+		}
2130
+		if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3))
2131
+			$label .= '<br><b>'.$langs->trans('CustomerCode').':</b> '.$this->code_client;
2132
+		if (!empty($this->code_fournisseur) && $this->fournisseur)
2133
+			$label .= '<br><b>'.$langs->trans('SupplierCode').':</b> '.$this->code_fournisseur;
2134
+		if (!empty($conf->accounting->enabled) && ($this->client == 1 || $this->client == 3))
2135
+			$label .= '<br><b>'.$langs->trans('CustomerAccountancyCode').':</b> '.($this->code_compta ? $this->code_compta : $this->code_compta_client);
2136
+		if (!empty($conf->accounting->enabled) && $this->fournisseur)
2137
+			$label .= '<br><b>'.$langs->trans('SupplierAccountancyCode').':</b> '.$this->code_compta_fournisseur;
2138
+
2139
+		$label .= '</div>';
2140 2140
 
2141 2141
 		// Add type of canvas
2142
-		$linkstart.=(!empty($this->canvas)?'&canvas='.$this->canvas:'');
2142
+		$linkstart .= (!empty($this->canvas) ? '&canvas='.$this->canvas : '');
2143 2143
 		// Add param to save lastsearch_values or not
2144
-		$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
2145
-		if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
2146
-		if ($add_save_lastsearch_values) $linkstart.='&save_lastsearch_values=1';
2147
-		$linkstart.='"';
2144
+		$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2145
+		if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
2146
+		if ($add_save_lastsearch_values) $linkstart .= '&save_lastsearch_values=1';
2147
+		$linkstart .= '"';
2148 2148
 
2149
-		$linkclose='';
2149
+		$linkclose = '';
2150 2150
 		if (empty($notooltip))
2151 2151
 		{
2152
-			if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
2152
+			if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
2153 2153
 			{
2154
-				$label=$langs->trans("ShowCompany");
2155
-				$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
2154
+				$label = $langs->trans("ShowCompany");
2155
+				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
2156 2156
 			}
2157
-			$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
2158
-			$linkclose.=' class="classfortooltip refurl"';
2157
+			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
2158
+			$linkclose .= ' class="classfortooltip refurl"';
2159 2159
 
2160 2160
 		 	/*
2161 2161
 			$hookmanager->initHooks(array('thirdpartydao'));
@@ -2164,25 +2164,25 @@  discard block
 block discarded – undo
2164 2164
 			if ($reshook > 0) $linkclose = $hookmanager->resPrint;
2165 2165
 			*/
2166 2166
 		}
2167
-		$linkstart.=$linkclose.'>';
2168
-		$linkend='</a>';
2167
+		$linkstart .= $linkclose.'>';
2168
+		$linkend = '</a>';
2169 2169
 
2170 2170
 		global $user;
2171
-		if (! $user->rights->societe->client->voir && $user->societe_id > 0 && $this->id != $user->societe_id)
2171
+		if (!$user->rights->societe->client->voir && $user->societe_id > 0 && $this->id != $user->societe_id)
2172 2172
 		{
2173
-			$linkstart='';
2174
-			$linkend='';
2173
+			$linkstart = '';
2174
+			$linkend = '';
2175 2175
 		}
2176 2176
 
2177
-		$result.=$linkstart;
2178
-		if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1);
2179
-		if ($withpicto != 2) $result.=($maxlen?dol_trunc($name,$maxlen):$name);
2180
-		$result.=$linkend;
2177
+		$result .= $linkstart;
2178
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip ? 0 : 1);
2179
+		if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($name, $maxlen) : $name);
2180
+		$result .= $linkend;
2181 2181
 
2182 2182
 		global $action;
2183 2183
 		$hookmanager->initHooks(array('thirdpartydao'));
2184
-		$parameters=array('id'=>$this->id, 'getnomurl'=>$result);
2185
-		$reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
2184
+		$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
2185
+		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
2186 2186
 		if ($reshook > 0) $result = $hookmanager->resPrint;
2187 2187
 		else $result .= $hookmanager->resPrint;
2188 2188
 
@@ -2195,9 +2195,9 @@  discard block
 block discarded – undo
2195 2195
 	 *    @param	int		$mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
2196 2196
 	 *    @return   string        		Libelle
2197 2197
 	 */
2198
-	function getLibStatut($mode=0)
2198
+	function getLibStatut($mode = 0)
2199 2199
 	{
2200
-		return $this->LibStatut($this->status,$mode);
2200
+		return $this->LibStatut($this->status, $mode);
2201 2201
 	}
2202 2202
 
2203 2203
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 	 *  @param	int		$mode           0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
2209 2209
 	 *  @return	string          		Libelle du statut
2210 2210
 	 */
2211
-	function LibStatut($statut,$mode=0)
2211
+	function LibStatut($statut, $mode = 0)
2212 2212
 	{
2213 2213
         // phpcs:enable
2214 2214
 		global $langs;
@@ -2216,38 +2216,38 @@  discard block
 block discarded – undo
2216 2216
 
2217 2217
 		if ($mode == 0)
2218 2218
 		{
2219
-			if ($statut==0) return $langs->trans("ActivityCeased");
2220
-			elseif ($statut==1) return $langs->trans("InActivity");
2219
+			if ($statut == 0) return $langs->trans("ActivityCeased");
2220
+			elseif ($statut == 1) return $langs->trans("InActivity");
2221 2221
 		}
2222 2222
 		elseif ($mode == 1)
2223 2223
 		{
2224
-			if ($statut==0) return $langs->trans("ActivityCeased");
2225
-			elseif ($statut==1) return $langs->trans("InActivity");
2224
+			if ($statut == 0) return $langs->trans("ActivityCeased");
2225
+			elseif ($statut == 1) return $langs->trans("InActivity");
2226 2226
 		}
2227 2227
 		elseif ($mode == 2)
2228 2228
 		{
2229
-			if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
2230
-			elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
2229
+			if ($statut == 0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
2230
+			elseif ($statut == 1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
2231 2231
 		}
2232 2232
 		elseif ($mode == 3)
2233 2233
 		{
2234
-			if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"');
2235
-			elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"');
2234
+			if ($statut == 0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
2235
+			elseif ($statut == 1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
2236 2236
 		}
2237 2237
 		elseif ($mode == 4)
2238 2238
 		{
2239
-			if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
2240
-			elseif ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
2239
+			if ($statut == 0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
2240
+			elseif ($statut == 1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
2241 2241
 		}
2242 2242
 		elseif ($mode == 5)
2243 2243
 		{
2244
-			if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"');
2245
-			elseif ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"');
2244
+			if ($statut == 0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
2245
+			elseif ($statut == 1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
2246 2246
 		}
2247 2247
 		elseif ($mode == 6)
2248 2248
 		{
2249
-			if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"');
2250
-			elseif ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"');
2249
+			if ($statut == 0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
2250
+			elseif ($statut == 1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
2251 2251
 		}
2252 2252
 	}
2253 2253
 
@@ -2258,16 +2258,16 @@  discard block
 block discarded – undo
2258 2258
 	 *	  @param	  int		$addthirdparty		1=Add also a record for thirdparty email
2259 2259
 	 *    @return     array       					Array of contacts emails
2260 2260
 	 */
2261
-	function thirdparty_and_contact_email_array($addthirdparty=0)
2261
+	function thirdparty_and_contact_email_array($addthirdparty = 0)
2262 2262
 	{
2263 2263
         // phpcs:enable
2264 2264
 		global $langs;
2265 2265
 
2266
-		$contact_emails = $this->contact_property_array('email',1);
2266
+		$contact_emails = $this->contact_property_array('email', 1);
2267 2267
 		if ($this->email && $addthirdparty)
2268 2268
 		{
2269
-			if (empty($this->name)) $this->name=$this->nom;
2270
-			$contact_emails['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">";
2269
+			if (empty($this->name)) $this->name = $this->nom;
2270
+			$contact_emails['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">";
2271 2271
 		}
2272 2272
 		//var_dump($contact_emails)
2273 2273
 		return $contact_emails;
@@ -2286,11 +2286,11 @@  discard block
 block discarded – undo
2286 2286
 
2287 2287
 		$contact_phone = $this->contact_property_array('mobile');
2288 2288
 
2289
-		if (! empty($this->phone))	// If a phone of thirdparty is defined, we add it ot mobile of contacts
2289
+		if (!empty($this->phone))	// If a phone of thirdparty is defined, we add it ot mobile of contacts
2290 2290
 		{
2291
-			if (empty($this->name)) $this->name=$this->nom;
2291
+			if (empty($this->name)) $this->name = $this->nom;
2292 2292
 			// TODO: Tester si tel non deja present dans tableau contact
2293
-			$contact_phone['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">";
2293
+			$contact_phone['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->phone.">";
2294 2294
 		}
2295 2295
 		return $contact_phone;
2296 2296
 	}
@@ -2303,7 +2303,7 @@  discard block
 block discarded – undo
2303 2303
 	 * 	@param	int		$hidedisabled		1=Hide contact if disabled
2304 2304
 	 *  @return array       				Array of contacts emails or mobile. Example: array(id=>'Name <email>')
2305 2305
 	 */
2306
-	function contact_property_array($mode='email', $hidedisabled=0)
2306
+	function contact_property_array($mode = 'email', $hidedisabled = 0)
2307 2307
 	{
2308 2308
         // phpcs:enable
2309 2309
 		global $langs;
@@ -2312,45 +2312,45 @@  discard block
 block discarded – undo
2312 2312
 
2313 2313
 
2314 2314
 		$sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname";
2315
-		$sql.= " FROM ".MAIN_DB_PREFIX."socpeople";
2316
-		$sql.= " WHERE fk_soc = ".$this->id;
2315
+		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople";
2316
+		$sql .= " WHERE fk_soc = ".$this->id;
2317 2317
 
2318
-		$resql=$this->db->query($sql);
2318
+		$resql = $this->db->query($sql);
2319 2319
 		if ($resql)
2320 2320
 		{
2321 2321
 			$nump = $this->db->num_rows($resql);
2322 2322
 			if ($nump)
2323 2323
 			{
2324
-				$sepa="("; $sepb=")";
2324
+				$sepa = "("; $sepb = ")";
2325 2325
 				if ($mode == 'email')
2326 2326
 				{
2327 2327
 					//$sepa="&lt;"; $sepb="&gt;";
2328
-					$sepa="<"; $sepb=">";
2328
+					$sepa = "<"; $sepb = ">";
2329 2329
 				}
2330 2330
 				$i = 0;
2331 2331
 				while ($i < $nump)
2332 2332
 				{
2333 2333
 					$obj = $this->db->fetch_object($resql);
2334
-					if ($mode == 'email') $property=$obj->email;
2335
-					else if ($mode == 'mobile') $property=$obj->phone_mobile;
2336
-					else $property=$obj->$mode;
2334
+					if ($mode == 'email') $property = $obj->email;
2335
+					else if ($mode == 'mobile') $property = $obj->phone_mobile;
2336
+					else $property = $obj->$mode;
2337 2337
 
2338 2338
 					// Show all contact. If hidedisabled is 1, showonly contacts with status = 1
2339 2339
 					if ($obj->statut == 1 || empty($hidedisabled))
2340 2340
 					{
2341 2341
 						if (empty($property))
2342 2342
 						{
2343
-							if ($mode == 'email') $property=$langs->transnoentitiesnoconv("NoEMail");
2344
-							else if ($mode == 'mobile') $property=$langs->transnoentitiesnoconv("NoMobilePhone");
2343
+							if ($mode == 'email') $property = $langs->transnoentitiesnoconv("NoEMail");
2344
+							else if ($mode == 'mobile') $property = $langs->transnoentitiesnoconv("NoMobilePhone");
2345 2345
 						}
2346 2346
 
2347 2347
 						if (!empty($obj->poste))
2348 2348
 						{
2349
-							$contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).($obj->poste?" - ".$obj->poste:"").(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:'');
2349
+							$contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).($obj->poste ? " - ".$obj->poste : "").(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : '');
2350 2350
 						}
2351 2351
 						else
2352 2352
 						{
2353
-							$contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:'');
2353
+							$contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : '');
2354 2354
 						}
2355 2355
 					}
2356 2356
 					$i++;
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 		$contacts = array();
2378 2378
 
2379 2379
 		$sql = "SELECT rowid, lastname, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id;
2380
-		$resql=$this->db->query($sql);
2380
+		$resql = $this->db->query($sql);
2381 2381
 		if ($resql)
2382 2382
 		{
2383 2383
 			$nump = $this->db->num_rows($resql);
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
 				while ($i < $nump)
2388 2388
 				{
2389 2389
 					$obj = $this->db->fetch_object($resql);
2390
-					$contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname,$obj->lastname);
2390
+					$contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname, $obj->lastname);
2391 2391
 					$i++;
2392 2392
 				}
2393 2393
 			}
@@ -2408,11 +2408,11 @@  discard block
 block discarded – undo
2408 2408
 	function contact_array_objects()
2409 2409
 	{
2410 2410
         // phpcs:enable
2411
-		require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
2411
+		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
2412 2412
 		$contacts = array();
2413 2413
 
2414 2414
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id;
2415
-		$resql=$this->db->query($sql);
2415
+		$resql = $this->db->query($sql);
2416 2416
 		if ($resql)
2417 2417
 		{
2418 2418
 			$nump = $this->db->num_rows($resql);
@@ -2444,18 +2444,18 @@  discard block
 block discarded – undo
2444 2444
 	 *  @param  string	$mode       'email' or 'mobile'
2445 2445
 	 *  @return string  			Email of contact with format: "Full name <email>"
2446 2446
 	 */
2447
-	function contact_get_property($rowid,$mode)
2447
+	function contact_get_property($rowid, $mode)
2448 2448
 	{
2449 2449
         // phpcs:enable
2450
-		$contact_property='';
2450
+		$contact_property = '';
2451 2451
 
2452 2452
 		if (empty($rowid)) return '';
2453 2453
 
2454 2454
 		$sql = "SELECT rowid, email, phone_mobile, lastname, firstname";
2455
-		$sql.= " FROM ".MAIN_DB_PREFIX."socpeople";
2456
-		$sql.= " WHERE rowid = '".$rowid."'";
2455
+		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople";
2456
+		$sql .= " WHERE rowid = '".$rowid."'";
2457 2457
 
2458
-		$resql=$this->db->query($sql);
2458
+		$resql = $this->db->query($sql);
2459 2459
 		if ($resql)
2460 2460
 		{
2461 2461
 			$nump = $this->db->num_rows($resql);
@@ -2483,13 +2483,13 @@  discard block
 block discarded – undo
2483 2483
 	 *	@param	string	$mode	'label' or 'rum' or 'format'
2484 2484
 	 *  @return	string			Bank number
2485 2485
 	 */
2486
-	function display_rib($mode='label')
2486
+	function display_rib($mode = 'label')
2487 2487
 	{
2488 2488
         // phpcs:enable
2489
-		require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
2489
+		require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
2490 2490
 
2491 2491
 		$bac = new CompanyBankAccount($this->db);
2492
-		$bac->fetch(0,$this->id);
2492
+		$bac->fetch(0, $this->id);
2493 2493
 
2494 2494
 		if ($mode == 'label')
2495 2495
 		{
@@ -2499,7 +2499,7 @@  discard block
 block discarded – undo
2499 2499
 		{
2500 2500
 			if (empty($bac->rum))
2501 2501
 			{
2502
-				require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php';
2502
+				require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
2503 2503
 				$prelevement = new BonPrelevement($this->db);
2504 2504
 				$bac->fetch_thirdparty();
2505 2505
 				$bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
 	function get_all_rib()
2524 2524
 	{
2525 2525
         // phpcs:enable
2526
-		require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
2526
+		require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
2527 2527
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".$this->id;
2528 2528
 		$result = $this->db->query($sql);
2529 2529
 		if (!$result) {
@@ -2553,23 +2553,23 @@  discard block
 block discarded – undo
2553 2553
 	 *	@param	int			$type		Should be 0 to say customer
2554 2554
 	 *  @return void
2555 2555
 	 */
2556
-	function get_codeclient($objsoc=0,$type=0)
2556
+	function get_codeclient($objsoc = 0, $type = 0)
2557 2557
 	{
2558 2558
         // phpcs:enable
2559 2559
 		global $conf;
2560
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2560
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2561 2561
 		{
2562
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2562
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2563 2563
 
2564
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2564
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2565 2565
 			foreach ($dirsociete as $dirroot)
2566 2566
 			{
2567
-				$res=dol_include_once($dirroot.$module.'.php');
2567
+				$res = dol_include_once($dirroot.$module.'.php');
2568 2568
 				if ($res) break;
2569 2569
 			}
2570 2570
 			$mod = new $module();
2571 2571
 
2572
-			$this->code_client = $mod->getNextValue($objsoc,$type);
2572
+			$this->code_client = $mod->getNextValue($objsoc, $type);
2573 2573
 			$this->prefixCustomerIsRequired = $mod->prefixIsRequired;
2574 2574
 
2575 2575
 			dol_syslog(get_class($this)."::get_codeclient code_client=".$this->code_client." module=".$module);
@@ -2585,23 +2585,23 @@  discard block
 block discarded – undo
2585 2585
 	 *	@param	int			$type		Should be 1 to say supplier
2586 2586
 	 *  @return void
2587 2587
 	 */
2588
-	function get_codefournisseur($objsoc=0,$type=1)
2588
+	function get_codefournisseur($objsoc = 0, $type = 1)
2589 2589
 	{
2590 2590
         // phpcs:enable
2591 2591
 		global $conf;
2592
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2592
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2593 2593
 		{
2594
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2594
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2595 2595
 
2596
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2596
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2597 2597
 			foreach ($dirsociete as $dirroot)
2598 2598
 			{
2599
-				$res=dol_include_once($dirroot.$module.'.php');
2599
+				$res = dol_include_once($dirroot.$module.'.php');
2600 2600
 				if ($res) break;
2601 2601
 			}
2602 2602
 			$mod = new $module();
2603 2603
 
2604
-			$this->code_fournisseur = $mod->getNextValue($objsoc,$type);
2604
+			$this->code_fournisseur = $mod->getNextValue($objsoc, $type);
2605 2605
 
2606 2606
 			dol_syslog(get_class($this)."::get_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module);
2607 2607
 		}
@@ -2618,23 +2618,23 @@  discard block
 block discarded – undo
2618 2618
 	{
2619 2619
         // phpcs:enable
2620 2620
 		global $conf;
2621
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2621
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2622 2622
 		{
2623
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2623
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2624 2624
 
2625
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2625
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2626 2626
 			foreach ($dirsociete as $dirroot)
2627 2627
 			{
2628
-				$res=dol_include_once($dirroot.$module.'.php');
2628
+				$res = dol_include_once($dirroot.$module.'.php');
2629 2629
 				if ($res) break;
2630 2630
 			}
2631 2631
 
2632 2632
 			$mod = new $module();
2633 2633
 
2634 2634
 			dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module);
2635
-			if ($mod->code_modifiable_null && ! $this->code_client) return 1;
2635
+			if ($mod->code_modifiable_null && !$this->code_client) return 1;
2636 2636
 			if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1;
2637
-			if ($mod->code_modifiable) return 1;	// A mettre en dernier
2637
+			if ($mod->code_modifiable) return 1; // A mettre en dernier
2638 2638
 			return 0;
2639 2639
 		}
2640 2640
 		else
@@ -2654,23 +2654,23 @@  discard block
 block discarded – undo
2654 2654
 	{
2655 2655
         // phpcs:enable
2656 2656
 		global $conf;
2657
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2657
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2658 2658
 		{
2659
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2659
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2660 2660
 
2661
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2661
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2662 2662
 			foreach ($dirsociete as $dirroot)
2663 2663
 			{
2664
-				$res=dol_include_once($dirroot.$module.'.php');
2664
+				$res = dol_include_once($dirroot.$module.'.php');
2665 2665
 				if ($res) break;
2666 2666
 			}
2667 2667
 
2668 2668
 			$mod = new $module();
2669 2669
 
2670 2670
 			dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module);
2671
-			if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1;
2671
+			if ($mod->code_modifiable_null && !$this->code_fournisseur) return 1;
2672 2672
 			if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1;
2673
-			if ($mod->code_modifiable) return 1;	// A mettre en dernier
2673
+			if ($mod->code_modifiable) return 1; // A mettre en dernier
2674 2674
 			return 0;
2675 2675
 		}
2676 2676
 		else
@@ -2694,14 +2694,14 @@  discard block
 block discarded – undo
2694 2694
 	{
2695 2695
         // phpcs:enable
2696 2696
 		global $conf;
2697
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2697
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2698 2698
 		{
2699
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2699
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2700 2700
 
2701
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2701
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2702 2702
 			foreach ($dirsociete as $dirroot)
2703 2703
 			{
2704
-				$res=dol_include_once($dirroot.$module.'.php');
2704
+				$res = dol_include_once($dirroot.$module.'.php');
2705 2705
 				if ($res) break;
2706 2706
 			}
2707 2707
 
@@ -2731,14 +2731,14 @@  discard block
 block discarded – undo
2731 2731
 	{
2732 2732
         // phpcs:enable
2733 2733
 		global $conf;
2734
-		if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2734
+		if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON))
2735 2735
 		{
2736
-			$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
2736
+			$module = $conf->global->SOCIETE_CODECLIENT_ADDON;
2737 2737
 
2738
-			$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']);
2738
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2739 2739
 			foreach ($dirsociete as $dirroot)
2740 2740
 			{
2741
-				$res=dol_include_once($dirroot.$module.'.php');
2741
+				$res = dol_include_once($dirroot.$module.'.php');
2742 2742
 				if ($res) break;
2743 2743
 			}
2744 2744
 
@@ -2768,13 +2768,13 @@  discard block
 block discarded – undo
2768 2768
         // phpcs:enable
2769 2769
 		global $conf;
2770 2770
 
2771
-		if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON))
2771
+		if (!empty($conf->global->SOCIETE_CODECOMPTA_ADDON))
2772 2772
 		{
2773
-			$res=false;
2774
-			$dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2773
+			$res = false;
2774
+			$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2775 2775
 			foreach ($dirsociete as $dirroot)
2776 2776
 			{
2777
-				$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php');
2777
+				$res = dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php');
2778 2778
 				if ($res) break;
2779 2779
 			}
2780 2780
 
@@ -2819,10 +2819,10 @@  discard block
 block discarded – undo
2819 2819
 		if ($this->id)
2820 2820
 		{
2821 2821
 			$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
2822
-			$sql.= " SET parent = ".($id > 0 ? $id : "null");
2823
-			$sql.= " WHERE rowid = " . $this->id;
2822
+			$sql .= " SET parent = ".($id > 0 ? $id : "null");
2823
+			$sql .= " WHERE rowid = ".$this->id;
2824 2824
 			dol_syslog(get_class($this).'::set_parent', LOG_DEBUG);
2825
-			$resql=$this->db->query($sql);
2825
+			$resql = $this->db->query($sql);
2826 2826
 			if ($resql)
2827 2827
 			{
2828 2828
 				$this->parent = $id;
@@ -2848,28 +2848,28 @@  discard block
 block discarded – undo
2848 2848
         // phpcs:enable
2849 2849
 		global $conf;
2850 2850
 
2851
-	 	switch($idprof)
2851
+	 	switch ($idprof)
2852 2852
 		{
2853 2853
 			case 1:
2854
-				$ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true);
2854
+				$ret = (!$conf->global->SOCIETE_IDPROF1_UNIQUE ?false:true);
2855 2855
 				break;
2856 2856
 			case 2:
2857
-				$ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true);
2857
+				$ret = (!$conf->global->SOCIETE_IDPROF2_UNIQUE ?false:true);
2858 2858
 				break;
2859 2859
 			case 3:
2860
-				$ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true);
2860
+				$ret = (!$conf->global->SOCIETE_IDPROF3_UNIQUE ?false:true);
2861 2861
 				break;
2862 2862
 			case 4:
2863
-				$ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true);
2863
+				$ret = (!$conf->global->SOCIETE_IDPROF4_UNIQUE ?false:true);
2864 2864
 				break;
2865 2865
 			case 5:
2866
-				$ret=(!$conf->global->SOCIETE_IDPROF5_UNIQUE?false:true);
2866
+				$ret = (!$conf->global->SOCIETE_IDPROF5_UNIQUE ?false:true);
2867 2867
 				break;
2868 2868
 			case 6:
2869
-				$ret=(!$conf->global->SOCIETE_IDPROF6_UNIQUE?false:true);
2869
+				$ret = (!$conf->global->SOCIETE_IDPROF6_UNIQUE ?false:true);
2870 2870
 				break;
2871 2871
 			default:
2872
-				$ret=false;
2872
+				$ret = false;
2873 2873
 		}
2874 2874
 
2875 2875
 		return $ret;
@@ -2884,40 +2884,40 @@  discard block
 block discarded – undo
2884 2884
 	 *    @param	int		$socid		Id of thirdparty to exclude (if update)
2885 2885
 	 *    @return   boolean				True if exists, False if not
2886 2886
 	 */
2887
-	function id_prof_exists($idprof, $value, $socid=0)
2887
+	function id_prof_exists($idprof, $value, $socid = 0)
2888 2888
 	{
2889 2889
         // phpcs:enable
2890 2890
 		$field = $idprof;
2891 2891
 
2892
-	 	switch($idprof)	// For backward compatibility
2892
+	 	switch ($idprof)	// For backward compatibility
2893 2893
 		{
2894 2894
 			case '1':
2895 2895
 			case 'idprof1':
2896
-				$field="siren";
2896
+				$field = "siren";
2897 2897
 				break;
2898 2898
 			case '2':
2899 2899
 			case 'idprof2':
2900
-				$field="siret";
2900
+				$field = "siret";
2901 2901
 				break;
2902 2902
 			case '3':
2903 2903
 			case 'idprof3':
2904
-				$field="ape";
2904
+				$field = "ape";
2905 2905
 				break;
2906 2906
 			case '4':
2907 2907
 			case 'idprof4':
2908
-				$field="idprof4";
2908
+				$field = "idprof4";
2909 2909
 				break;
2910 2910
 			case '5':
2911
-				$field="idprof5";
2911
+				$field = "idprof5";
2912 2912
 				break;
2913 2913
 			case '6':
2914
-				$field="idprof6";
2914
+				$field = "idprof6";
2915 2915
 				break;
2916 2916
 	 	}
2917 2917
 
2918 2918
 		 //Verify duplicate entries
2919
-		$sql  = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")";
2920
-		if($socid) $sql .= " AND rowid <> ".$socid;
2919
+		$sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")";
2920
+		if ($socid) $sql .= " AND rowid <> ".$socid;
2921 2921
 		$resql = $this->db->query($sql);
2922 2922
 		if ($resql)
2923 2923
 		{
@@ -2944,20 +2944,20 @@  discard block
 block discarded – undo
2944 2944
 	 *  @return int             			<=0 if KO, >0 if OK
2945 2945
 	 *  TODO better to have this in a lib than into a business class
2946 2946
 	 */
2947
-	function id_prof_check($idprof,$soc)
2947
+	function id_prof_check($idprof, $soc)
2948 2948
 	{
2949 2949
         // phpcs:enable
2950 2950
 		global $conf;
2951 2951
 
2952
-		$ok=1;
2952
+		$ok = 1;
2953 2953
 
2954
-		if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1;
2954
+		if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1;
2955 2955
 
2956 2956
 		// Verifie SIREN si pays FR
2957 2957
 		if ($idprof == 1 && $soc->country_code == 'FR')
2958 2958
 		{
2959
-			$chaine=trim($this->idprof1);
2960
-			$chaine=preg_replace('/(\s)/','',$chaine);
2959
+			$chaine = trim($this->idprof1);
2960
+			$chaine = preg_replace('/(\s)/', '', $chaine);
2961 2961
 
2962 2962
 			if (!is_numeric($chaine)) return -1;
2963 2963
 			if (dol_strlen($chaine) != 9) return -1;
@@ -2967,7 +2967,7 @@  discard block
 block discarded – undo
2967 2967
 			// on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9
2968 2968
 			// on ajoute cette valeur à la somme totale
2969 2969
 
2970
-			for ($index = 0; $index < 9; $index ++)
2970
+			for ($index = 0; $index < 9; $index++)
2971 2971
 			{
2972 2972
 				$number = (int) $siren[$index];
2973 2973
 				if (($index % 2) != 0) { if (($number *= 2) > 9) $number -= 9; }
@@ -2981,8 +2981,8 @@  discard block
 block discarded – undo
2981 2981
 		// Verifie SIRET si pays FR
2982 2982
 		if ($idprof == 2 && $soc->country_code == 'FR')
2983 2983
 		{
2984
-			$chaine=trim($this->idprof2);
2985
-			$chaine=preg_replace('/(\s)/','',$chaine);
2984
+			$chaine = trim($this->idprof2);
2985
+			$chaine = preg_replace('/(\s)/', '', $chaine);
2986 2986
 
2987 2987
 			if (!is_numeric($chaine)) return -1;
2988 2988
 			if (dol_strlen($chaine) != 14) return -1;
@@ -2992,7 +2992,7 @@  discard block
 block discarded – undo
2992 2992
 			// on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9
2993 2993
 			// on ajoute cette valeur à la somme totale
2994 2994
 
2995
-			for ($index = 0; $index < 14; $index ++)
2995
+			for ($index = 0; $index < 14; $index++)
2996 2996
 			{
2997 2997
 				$number = (int) $chaine[$index];
2998 2998
 				if (($index % 2) == 0) { if (($number *= 2) > 9) $number -= 9; }
@@ -3007,11 +3007,11 @@  discard block
 block discarded – undo
3007 3007
 		//Returns: 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, 0 if unexpected bad
3008 3008
 		if ($idprof == 1 && $soc->country_code == 'ES')
3009 3009
 		{
3010
-			$string=trim($this->idprof1);
3011
-			$string=preg_replace('/(\s)/','',$string);
3010
+			$string = trim($this->idprof1);
3011
+			$string = preg_replace('/(\s)/', '', $string);
3012 3012
 			$string = strtoupper($string);
3013 3013
 
3014
-			for ($i = 0; $i < 9; $i ++)
3014
+			for ($i = 0; $i < 9; $i++)
3015 3015
 			$num[$i] = substr($string, $i, 1);
3016 3016
 
3017 3017
 			//Check format
@@ -3028,7 +3028,7 @@  discard block
 block discarded – undo
3028 3028
 			//algorithm checking type code CIF
3029 3029
 			$sum = $num[2] + $num[4] + $num[6];
3030 3030
 			for ($i = 1; $i < 8; $i += 2)
3031
-			$sum += intval(substr((2 * $num[$i]),0,1)) + intval(substr((2 * $num[$i]),1,1));
3031
+			$sum += intval(substr((2 * $num[$i]), 0, 1)) + intval(substr((2 * $num[$i]), 1, 1));
3032 3032
 			$n = 10 - substr($sum, strlen($sum) - 1, 1);
3033 3033
 
3034 3034
 			//Chek special NIF
@@ -3054,7 +3054,7 @@  discard block
 block discarded – undo
3054 3054
 
3055 3055
 			//Check NIE XYZ
3056 3056
 			if (preg_match('/^[XYZ]{1}/', $string))
3057
-				if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1))
3057
+				if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X', 'Y', 'Z'), array('0', '1', '2'), $string), 0, 8) % 23, 1))
3058 3058
 				return 3;
3059 3059
 				else
3060 3060
 				return -3;
@@ -3067,10 +3067,10 @@  discard block
 block discarded – undo
3067 3067
 		//Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad
3068 3068
 		if ($idprof == 1 && $soc->country_code == 'PT')
3069 3069
 		{
3070
-			$string=trim($this->idprof1);
3071
-			$string=preg_replace('/(\s)/','',$string);
3070
+			$string = trim($this->idprof1);
3071
+			$string = preg_replace('/(\s)/', '', $string);
3072 3072
 
3073
-			for ($i = 0; $i < 9; $i ++) {
3073
+			for ($i = 0; $i < 9; $i++) {
3074 3074
 				$num[$i] = substr($string, $i, 1);
3075 3075
 			}
3076 3076
 
@@ -3095,38 +3095,38 @@  discard block
 block discarded – undo
3095 3095
 	 *   @return	string          		Url or empty string if no URL known
3096 3096
 	 *   TODO better in a lib than into business class
3097 3097
 	 */
3098
-	function id_prof_url($idprof,$thirdparty)
3098
+	function id_prof_url($idprof, $thirdparty)
3099 3099
 	{
3100 3100
         // phpcs:enable
3101
-		global $conf,$langs,$hookmanager;
3101
+		global $conf, $langs, $hookmanager;
3102 3102
 
3103
-		$url='';
3103
+		$url = '';
3104 3104
 		$action = '';
3105 3105
 
3106 3106
 		$hookmanager->initHooks(array('idprofurl'));
3107
-		$parameters=array('idprof'=>$idprof, 'company'=>$thirdparty);
3108
-		$reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
3107
+		$parameters = array('idprof'=>$idprof, 'company'=>$thirdparty);
3108
+		$reshook = $hookmanager->executeHooks('getIdProfUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
3109 3109
 		if (empty($reshook)) {
3110
-			if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
3110
+			if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
3111 3111
 				return '';
3112 3112
 			}
3113 3113
 
3114 3114
 			// TODO Move links to validate professional ID into a dictionary table "country" + "link"
3115 3115
             $strippedIdProf1 = str_replace(' ', '', $thirdparty->idprof1);
3116 3116
 			if ($idprof == 1 && $thirdparty->country_code == 'FR') {
3117
-				$url='http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1;    // See also http://avis-situation-sirene.insee.fr/
3117
+				$url = 'http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1; // See also http://avis-situation-sirene.insee.fr/
3118 3118
 			}
3119 3119
 			if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) {
3120
-				$url='https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1;
3120
+				$url = 'https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1;
3121 3121
 			}
3122 3122
 			if ($idprof == 1 && $thirdparty->country_code == 'ES') {
3123
-				$url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1;
3123
+				$url = 'http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1;
3124 3124
 			}
3125 3125
 			if ($idprof == 1 && $thirdparty->country_code == 'IN') {
3126
-				$url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp';
3126
+				$url = 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp';
3127 3127
 			}
3128 3128
 			if ($idprof == 1 && $thirdparty->country_code == 'PT') {
3129
-				$url='http://www.nif.pt/'.$strippedIdProf1;
3129
+				$url = 'http://www.nif.pt/'.$strippedIdProf1;
3130 3130
 			}
3131 3131
 
3132 3132
 			if ($url) {
@@ -3149,7 +3149,7 @@  discard block
 block discarded – undo
3149 3149
 	function has_projects()
3150 3150
 	{
3151 3151
         // phpcs:enable
3152
-		$sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id;
3152
+		$sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = '.$this->id;
3153 3153
 		$resql = $this->db->query($sql);
3154 3154
 		if ($resql)
3155 3155
 		{
@@ -3175,11 +3175,11 @@  discard block
 block discarded – undo
3175 3175
 	function info($id)
3176 3176
 	{
3177 3177
 		$sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,";
3178
-		$sql.= " fk_user_creat, fk_user_modif";
3179
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
3180
-		$sql.= " WHERE s.rowid = ".$id;
3178
+		$sql .= " fk_user_creat, fk_user_modif";
3179
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
3180
+		$sql .= " WHERE s.rowid = ".$id;
3181 3181
 
3182
-		$result=$this->db->query($sql);
3182
+		$result = $this->db->query($sql);
3183 3183
 		if ($result)
3184 3184
 		{
3185 3185
 			if ($this->db->num_rows($result))
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
 				if ($obj->fk_user_creat) {
3192 3192
 					$cuser = new User($this->db);
3193 3193
 					$cuser->fetch($obj->fk_user_creat);
3194
-					$this->user_creation     = $cuser;
3194
+					$this->user_creation = $cuser;
3195 3195
 				}
3196 3196
 
3197 3197
 				if ($obj->fk_user_modif) {
@@ -3200,7 +3200,7 @@  discard block
 block discarded – undo
3200 3200
 					$this->user_modification = $muser;
3201 3201
 				}
3202 3202
 
3203
-				$this->ref			     = $obj->name;
3203
+				$this->ref = $obj->name;
3204 3204
 				$this->date_creation     = $this->db->jdate($obj->date_creation);
3205 3205
 				$this->date_modification = $this->db->jdate($obj->date_modification);
3206 3206
 			}
@@ -3223,13 +3223,13 @@  discard block
 block discarded – undo
3223 3223
 		global $conf;
3224 3224
 
3225 3225
 		// Define if third party is treated as company (or not) when nature is unknown
3226
-		$isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default
3227
-		if (! empty($this->tva_intra)) $isacompany=1;
3228
-		else if (! empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN')
3226
+		$isacompany = empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES) ? 0 : 1; // 0 by default
3227
+		if (!empty($this->tva_intra)) $isacompany = 1;
3228
+		else if (!empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN')
3229 3229
 		{
3230 3230
 			// TODO Add a field is_a_company into dictionary
3231
-			if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany=0;
3232
-			else $isacompany=1;
3231
+			if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany = 0;
3232
+			else $isacompany = 1;
3233 3233
 		}
3234 3234
 
3235 3235
 		return $isacompany;
@@ -3257,13 +3257,13 @@  discard block
 block discarded – undo
3257 3257
         // phpcs:enable
3258 3258
 		$this->SupplierCategories = array();
3259 3259
 		$sql = "SELECT rowid, label";
3260
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
3261
-		$sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER;
3260
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
3261
+		$sql .= " WHERE type = ".Categorie::TYPE_SUPPLIER;
3262 3262
 
3263
-		$resql=$this->db->query($sql);
3263
+		$resql = $this->db->query($sql);
3264 3264
 		if ($resql)
3265 3265
 		{
3266
-			while ($obj = $this->db->fetch_object($resql) )
3266
+			while ($obj = $this->db->fetch_object($resql))
3267 3267
 			{
3268 3268
 				$this->SupplierCategories[$obj->rowid] = $obj->label;
3269 3269
 			}
@@ -3288,9 +3288,9 @@  discard block
 block discarded – undo
3288 3288
 		if ($categorie_id > 0 && $this->id > 0)
3289 3289
 		{
3290 3290
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) ";
3291
-			$sql.= " VALUES (".$categorie_id.", ".$this->id.")";
3291
+			$sql .= " VALUES (".$categorie_id.", ".$this->id.")";
3292 3292
 
3293
-			if ($resql=$this->db->query($sql)) return 0;
3293
+			if ($resql = $this->db->query($sql)) return 0;
3294 3294
 		}
3295 3295
 		else
3296 3296
 		{
@@ -3310,48 +3310,48 @@  discard block
 block discarded – undo
3310 3310
 	 *  @param	string		$customercode	Customer code
3311 3311
 	 *  @return int							<0 if KO, id of created account if OK
3312 3312
 	 */
3313
-	function create_from_member(Adherent $member, $socname='', $socalias='', $customercode='')
3313
+	function create_from_member(Adherent $member, $socname = '', $socalias = '', $customercode = '')
3314 3314
 	{
3315 3315
         // phpcs:enable
3316
-		global $user,$langs;
3316
+		global $user, $langs;
3317 3317
 
3318 3318
 		dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
3319 3319
 
3320
-		$name = $socname?$socname:$member->societe;
3321
-		if (empty($name)) $name=$member->getFullName($langs);
3320
+		$name = $socname ? $socname : $member->societe;
3321
+		if (empty($name)) $name = $member->getFullName($langs);
3322 3322
 
3323
-		$alias = $socalias?$socalias:'';
3323
+		$alias = $socalias ? $socalias : '';
3324 3324
 
3325 3325
 		// Positionne parametres
3326
-		$this->nom=$name;				// TODO deprecated
3327
-		$this->name=$name;
3328
-		$this->name_alias=$alias;
3329
-		$this->address=$member->address;
3330
-		$this->zip=$member->zip;
3331
-		$this->town=$member->town;
3332
-		$this->country_code=$member->country_code;
3333
-		$this->country_id=$member->country_id;
3334
-		$this->phone=$member->phone;       // Prof phone
3335
-		$this->email=$member->email;
3336
-		$this->skype=$member->skype;
3337
-		$this->twitter=$member->twitter;
3338
-		$this->facebook=$member->facebook;
3339
-
3340
-		$this->client = 1;				// A member is a customer by default
3341
-		$this->code_client = ($customercode?$customercode:-1);
3326
+		$this->nom = $name; // TODO deprecated
3327
+		$this->name = $name;
3328
+		$this->name_alias = $alias;
3329
+		$this->address = $member->address;
3330
+		$this->zip = $member->zip;
3331
+		$this->town = $member->town;
3332
+		$this->country_code = $member->country_code;
3333
+		$this->country_id = $member->country_id;
3334
+		$this->phone = $member->phone; // Prof phone
3335
+		$this->email = $member->email;
3336
+		$this->skype = $member->skype;
3337
+		$this->twitter = $member->twitter;
3338
+		$this->facebook = $member->facebook;
3339
+
3340
+		$this->client = 1; // A member is a customer by default
3341
+		$this->code_client = ($customercode ? $customercode : -1);
3342 3342
 		$this->code_fournisseur = -1;
3343 3343
 
3344 3344
 		$this->db->begin();
3345 3345
 
3346 3346
 		// Cree et positionne $this->id
3347
-		$result=$this->create($user);
3347
+		$result = $this->create($user);
3348 3348
 		if ($result >= 0)
3349 3349
 		{
3350 3350
 			$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
3351
-			$sql.= " SET fk_soc=".$this->id;
3352
-			$sql.= " WHERE rowid=".$member->id;
3351
+			$sql .= " SET fk_soc=".$this->id;
3352
+			$sql .= " WHERE rowid=".$member->id;
3353 3353
 
3354
-			$resql=$this->db->query($sql);
3354
+			$resql = $this->db->query($sql);
3355 3355
 			if ($resql)
3356 3356
 			{
3357 3357
 				$this->db->commit();
@@ -3359,7 +3359,7 @@  discard block
 block discarded – undo
3359 3359
 			}
3360 3360
 			else
3361 3361
 			{
3362
-				$this->error=$this->db->error();
3362
+				$this->error = $this->db->error();
3363 3363
 
3364 3364
 				$this->db->rollback();
3365 3365
 				return -1;
@@ -3368,7 +3368,7 @@  discard block
 block discarded – undo
3368 3368
 		else
3369 3369
 		{
3370 3370
 			// $this->error deja positionne
3371
-			dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',',$this->errors), LOG_ERR);
3371
+			dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',', $this->errors), LOG_ERR);
3372 3372
 
3373 3373
 			$this->db->rollback();
3374 3374
 			return $result;
@@ -3385,68 +3385,68 @@  discard block
 block discarded – undo
3385 3385
 	{
3386 3386
 		global $langs;
3387 3387
 
3388
-		$this->id=0;
3389
-		$this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM;
3390
-		$this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS;
3391
-		$this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP;
3392
-		$this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN;
3393
-		$this->state_id=empty($conf->global->MAIN_INFO_SOCIETE_STATE)?'':$conf->global->MAIN_INFO_SOCIETE_STATE;
3394
-		$this->region_code=empty($conf->global->MAIN_INFO_SOCIETE_REGION)?'':$conf->global->MAIN_INFO_SOCIETE_REGION;
3395
-		$this->object=empty($conf->global->MAIN_INFO_SOCIETE_OBJECT)?'':$conf->global->MAIN_INFO_SOCIETE_OBJECT;
3388
+		$this->id = 0;
3389
+		$this->name = empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM;
3390
+		$this->address = empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS) ? '' : $conf->global->MAIN_INFO_SOCIETE_ADDRESS;
3391
+		$this->zip = empty($conf->global->MAIN_INFO_SOCIETE_ZIP) ? '' : $conf->global->MAIN_INFO_SOCIETE_ZIP;
3392
+		$this->town = empty($conf->global->MAIN_INFO_SOCIETE_TOWN) ? '' : $conf->global->MAIN_INFO_SOCIETE_TOWN;
3393
+		$this->state_id = empty($conf->global->MAIN_INFO_SOCIETE_STATE) ? '' : $conf->global->MAIN_INFO_SOCIETE_STATE;
3394
+		$this->region_code = empty($conf->global->MAIN_INFO_SOCIETE_REGION) ? '' : $conf->global->MAIN_INFO_SOCIETE_REGION;
3395
+		$this->object = empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? '' : $conf->global->MAIN_INFO_SOCIETE_OBJECT;
3396 3396
 
3397
-		$this->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE;
3397
+		$this->note_private = empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOTE;
3398 3398
 
3399
-		$this->nom=$this->name; 									// deprecated
3399
+		$this->nom = $this->name; // deprecated
3400 3400
 
3401 3401
 		// We define country_id, country_code and country
3402
-		$country_id=$country_code=$country_label='';
3403
-		if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY))
3402
+		$country_id = $country_code = $country_label = '';
3403
+		if (!empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY))
3404 3404
 		{
3405
-			$tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_COUNTRY);
3406
-			$country_id=$tmp[0];
3407
-			if (! empty($tmp[1]))   // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label"
3405
+			$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
3406
+			$country_id = $tmp[0];
3407
+			if (!empty($tmp[1]))   // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label"
3408 3408
 			{
3409
-				$country_code=$tmp[1];
3410
-				$country_label=$tmp[2];
3409
+				$country_code = $tmp[1];
3410
+				$country_label = $tmp[2];
3411 3411
 			}
3412 3412
 			else                    // For backward compatibility
3413 3413
 			{
3414 3414
 				dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_ERR);
3415 3415
 				include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
3416
-				$country_code=getCountry($country_id,2,$this->db);  // This need a SQL request, but it's the old feature that should not be used anymore
3417
-				$country_label=getCountry($country_id,0,$this->db);  // This need a SQL request, but it's the old feature that should not be used anymore
3416
+				$country_code = getCountry($country_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore
3417
+				$country_label = getCountry($country_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore
3418 3418
 			}
3419 3419
 		}
3420
-		$this->country_id=$country_id;
3421
-		$this->country_code=$country_code;
3422
-		$this->country=$country_label;
3423
-		if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label;
3420
+		$this->country_id = $country_id;
3421
+		$this->country_code = $country_code;
3422
+		$this->country = $country_label;
3423
+		if (is_object($langs)) $this->country = ($langs->trans('Country'.$country_code) != 'Country'.$country_code) ? $langs->trans('Country'.$country_code) : $country_label;
3424 3424
 
3425
-		$this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL;
3426
-		$this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX;
3427
-		$this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB;
3425
+		$this->phone = empty($conf->global->MAIN_INFO_SOCIETE_TEL) ? '' : $conf->global->MAIN_INFO_SOCIETE_TEL;
3426
+		$this->fax = empty($conf->global->MAIN_INFO_SOCIETE_FAX) ? '' : $conf->global->MAIN_INFO_SOCIETE_FAX;
3427
+		$this->url = empty($conf->global->MAIN_INFO_SOCIETE_WEB) ? '' : $conf->global->MAIN_INFO_SOCIETE_WEB;
3428 3428
 		// Id prof generiques
3429
-		$this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN;
3430
-		$this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET;
3431
-		$this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE;
3432
-		$this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS;
3433
-		$this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5;
3434
-		$this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6;
3435
-		$this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA;	// VAT number, not necessarly INTRA.
3436
-		$this->managers=empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS)?'':$conf->global->MAIN_INFO_SOCIETE_MANAGERS;
3437
-		$this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL;
3438
-		$this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE;
3439
-		$this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL;
3440
-		$this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO;
3441
-		$this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL;
3442
-		$this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
3429
+		$this->idprof1 = empty($conf->global->MAIN_INFO_SIREN) ? '' : $conf->global->MAIN_INFO_SIREN;
3430
+		$this->idprof2 = empty($conf->global->MAIN_INFO_SIRET) ? '' : $conf->global->MAIN_INFO_SIRET;
3431
+		$this->idprof3 = empty($conf->global->MAIN_INFO_APE) ? '' : $conf->global->MAIN_INFO_APE;
3432
+		$this->idprof4 = empty($conf->global->MAIN_INFO_RCS) ? '' : $conf->global->MAIN_INFO_RCS;
3433
+		$this->idprof5 = empty($conf->global->MAIN_INFO_PROFID5) ? '' : $conf->global->MAIN_INFO_PROFID5;
3434
+		$this->idprof6 = empty($conf->global->MAIN_INFO_PROFID6) ? '' : $conf->global->MAIN_INFO_PROFID6;
3435
+		$this->tva_intra = empty($conf->global->MAIN_INFO_TVAINTRA) ? '' : $conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA.
3436
+		$this->managers = empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS) ? '' : $conf->global->MAIN_INFO_SOCIETE_MANAGERS;
3437
+		$this->capital = empty($conf->global->MAIN_INFO_CAPITAL) ? '' : $conf->global->MAIN_INFO_CAPITAL;
3438
+		$this->forme_juridique_code = empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) ? '' : $conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE;
3439
+		$this->email = empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? '' : $conf->global->MAIN_INFO_SOCIETE_MAIL;
3440
+		$this->logo = empty($conf->global->MAIN_INFO_SOCIETE_LOGO) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO;
3441
+		$this->logo_small = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL;
3442
+		$this->logo_mini = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
3443 3443
 
3444 3444
 		// Define if company use vat or not
3445
-		$this->tva_assuj=$conf->global->FACTURE_TVAOPTION;
3445
+		$this->tva_assuj = $conf->global->FACTURE_TVAOPTION;
3446 3446
 
3447 3447
 		// Define if company use local taxes
3448
-		$this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on'))?1:0);
3449
-		$this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on'))?1:0);
3448
+		$this->localtax1_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on')) ? 1 : 0);
3449
+		$this->localtax2_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on')) ? 1 : 0);
3450 3450
 	}
3451 3451
 
3452 3452
 	/**
@@ -3458,48 +3458,48 @@  discard block
 block discarded – undo
3458 3458
 	 */
3459 3459
 	function initAsSpecimen()
3460 3460
 	{
3461
-		$now=dol_now();
3461
+		$now = dol_now();
3462 3462
 
3463 3463
 		// Initialize parameters
3464
-		$this->id=0;
3465
-		$this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now,'dayhourlog');
3466
-		$this->nom = $this->name;   // For backward compatibility
3464
+		$this->id = 0;
3465
+		$this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now, 'dayhourlog');
3466
+		$this->nom = $this->name; // For backward compatibility
3467 3467
 		$this->ref_ext = 'Ref ext';
3468
-		$this->specimen=1;
3469
-		$this->address='21 jump street';
3470
-		$this->zip='99999';
3471
-		$this->town='MyTown';
3472
-		$this->state_id=1;
3473
-		$this->state_code='AA';
3474
-		$this->state='MyState';
3475
-		$this->country_id=1;
3476
-		$this->country_code='FR';
3477
-		$this->email='[email protected]';
3478
-		$this->skype='tom.hanson';
3479
-		$this->twitter='tomhanson';
3480
-		$this->facebook='tomhanson';
3481
-		$this->url='http://www.specimen.com';
3482
-
3483
-		$this->phone='0909090901';
3484
-		$this->fax='0909090909';
3485
-
3486
-		$this->code_client='CC-'.dol_print_date($now,'dayhourlog');
3487
-		$this->code_fournisseur='SC-'.dol_print_date($now,'dayhourlog');
3488
-		$this->capital=10000;
3489
-		$this->client=1;
3490
-		$this->prospect=1;
3491
-		$this->fournisseur=1;
3492
-		$this->tva_assuj=1;
3493
-		$this->tva_intra='EU1234567';
3494
-		$this->note_public='This is a comment (public)';
3495
-		$this->note_private='This is a comment (private)';
3496
-
3497
-		$this->idprof1='idprof1';
3498
-		$this->idprof2='idprof2';
3499
-		$this->idprof3='idprof3';
3500
-		$this->idprof4='idprof4';
3501
-		$this->idprof5='idprof5';
3502
-		$this->idprof6='idprof6';
3468
+		$this->specimen = 1;
3469
+		$this->address = '21 jump street';
3470
+		$this->zip = '99999';
3471
+		$this->town = 'MyTown';
3472
+		$this->state_id = 1;
3473
+		$this->state_code = 'AA';
3474
+		$this->state = 'MyState';
3475
+		$this->country_id = 1;
3476
+		$this->country_code = 'FR';
3477
+		$this->email = '[email protected]';
3478
+		$this->skype = 'tom.hanson';
3479
+		$this->twitter = 'tomhanson';
3480
+		$this->facebook = 'tomhanson';
3481
+		$this->url = 'http://www.specimen.com';
3482
+
3483
+		$this->phone = '0909090901';
3484
+		$this->fax = '0909090909';
3485
+
3486
+		$this->code_client = 'CC-'.dol_print_date($now, 'dayhourlog');
3487
+		$this->code_fournisseur = 'SC-'.dol_print_date($now, 'dayhourlog');
3488
+		$this->capital = 10000;
3489
+		$this->client = 1;
3490
+		$this->prospect = 1;
3491
+		$this->fournisseur = 1;
3492
+		$this->tva_assuj = 1;
3493
+		$this->tva_intra = 'EU1234567';
3494
+		$this->note_public = 'This is a comment (public)';
3495
+		$this->note_private = 'This is a comment (private)';
3496
+
3497
+		$this->idprof1 = 'idprof1';
3498
+		$this->idprof2 = 'idprof2';
3499
+		$this->idprof3 = 'idprof3';
3500
+		$this->idprof4 = 'idprof4';
3501
+		$this->idprof5 = 'idprof5';
3502
+		$this->idprof6 = 'idprof6';
3503 3503
 	}
3504 3504
 
3505 3505
 	/**
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
 	 *	@param		int		$localTaxNum	To get info for only localtax1 or localtax2
3509 3509
 	 *  @return		boolean					true or false
3510 3510
 	 */
3511
-	function useLocalTax($localTaxNum=0)
3511
+	function useLocalTax($localTaxNum = 0)
3512 3512
 	{
3513 3513
 		$sql  = "SELECT t.localtax1, t.localtax2";
3514 3514
 		$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
@@ -3519,7 +3519,7 @@  discard block
 block discarded – undo
3519 3519
 		elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'";
3520 3520
 
3521 3521
 		dol_syslog("useLocalTax", LOG_DEBUG);
3522
-		$resql=$this->db->query($sql);
3522
+		$resql = $this->db->query($sql);
3523 3523
 		if ($resql)
3524 3524
 		{
3525 3525
    			return ($this->db->num_rows($resql) > 0);
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
 		$sql .= " AND t.active = 1 AND t.recuperableonly = 1";
3541 3541
 
3542 3542
 		dol_syslog("useNPR", LOG_DEBUG);
3543
-		$resql=$this->db->query($sql);
3543
+		$resql = $this->db->query($sql);
3544 3544
 		if ($resql)
3545 3545
 		{
3546 3546
 			return ($this->db->num_rows($resql) > 0);
@@ -3561,15 +3561,15 @@  discard block
 block discarded – undo
3561 3561
 		$sql .= " AND r.active = 1";
3562 3562
 
3563 3563
 		dol_syslog("useRevenueStamp", LOG_DEBUG);
3564
-		$resql=$this->db->query($sql);
3564
+		$resql = $this->db->query($sql);
3565 3565
 		if ($resql)
3566 3566
 		{
3567
-			$obj=$this->db->fetch_object($resql);
3568
-   			return (($obj->nb > 0)?true:false);
3567
+			$obj = $this->db->fetch_object($resql);
3568
+   			return (($obj->nb > 0) ?true:false);
3569 3569
 		}
3570 3570
 		else
3571 3571
 		{
3572
-			$this->error=$this->db->lasterror();
3572
+			$this->error = $this->db->lasterror();
3573 3573
 			return false;
3574 3574
 		}
3575 3575
 	}
@@ -3596,11 +3596,11 @@  discard block
 block discarded – undo
3596 3596
         // phpcs:enable
3597 3597
 		global $langs;
3598 3598
 
3599
-		$lib=$langs->trans("ProspectLevel".$fk_prospectlevel);
3599
+		$lib = $langs->trans("ProspectLevel".$fk_prospectlevel);
3600 3600
 		// If lib not found in language file, we get label from cache/databse
3601 3601
 		if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel))
3602 3602
 		{
3603
-			$lib=$langs->getLabelFromKey($this->db,$fk_prospectlevel,'c_prospectlevel','code','label');
3603
+			$lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label');
3604 3604
 		}
3605 3605
 		return $lib;
3606 3606
 	}
@@ -3627,7 +3627,7 @@  discard block
 block discarded – undo
3627 3627
 	 *  @param	string	$label		Label to use for status for added status
3628 3628
 	 *  @return string        		Libelle
3629 3629
 	 */
3630
-	function getLibProspCommStatut($mode=0, $label='')
3630
+	function getLibProspCommStatut($mode = 0, $label = '')
3631 3631
 	{
3632 3632
 		return $this->LibProspCommStatut($this->stcomm_id, $mode, $label);
3633 3633
 	}
@@ -3641,7 +3641,7 @@  discard block
 block discarded – undo
3641 3641
 	 *  @param	string		$label			Label to use for status for added status
3642 3642
 	 *  @return string       	 			Libelle du statut
3643 3643
 	 */
3644
-	function LibProspCommStatut($statut, $mode=0, $label='')
3644
+	function LibProspCommStatut($statut, $mode = 0, $label = '')
3645 3645
 	{
3646 3646
         // phpcs:enable
3647 3647
 		global $langs;
@@ -3649,11 +3649,11 @@  discard block
 block discarded – undo
3649 3649
 
3650 3650
 		if ($mode == 2)
3651 3651
 		{
3652
-			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1");
3653
-			elseif ($statut ==  '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
3654
-			elseif ($statut ==  '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
3655
-			elseif ($statut ==  '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
3656
-			elseif ($statut ==  '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
3652
+			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
3653
+			elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
3654
+			elseif ($statut == '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
3655
+			elseif ($statut == '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
3656
+			elseif ($statut == '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
3657 3657
 			else
3658 3658
 			{
3659 3659
 				return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
@@ -3661,11 +3661,11 @@  discard block
 block discarded – undo
3661 3661
 		}
3662 3662
 		if ($mode == 3)
3663 3663
 		{
3664
-			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"),-1);
3665
-			elseif ($statut ==  '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0);
3666
-			elseif ($statut ==  '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1);
3667
-			elseif ($statut ==  '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2);
3668
-			elseif ($statut ==  '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3);
3664
+			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"), -1);
3665
+			elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0);
3666
+			elseif ($statut == '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1);
3667
+			elseif ($statut == '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2);
3668
+			elseif ($statut == '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3);
3669 3669
 			else
3670 3670
 			{
3671 3671
 				return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0);
@@ -3673,11 +3673,11 @@  discard block
 block discarded – undo
3673 3673
 		}
3674 3674
 		if ($mode == 4)
3675 3675
 		{
3676
-			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1");
3677
-			elseif ($statut ==  '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
3678
-			elseif ($statut ==  '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
3679
-			elseif ($statut ==  '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
3680
-			elseif ($statut ==  '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
3676
+			if ($statut == '-1' || $statut == 'ST_NO')         return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
3677
+			elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
3678
+			elseif ($statut == '1' || $statut == 'ST_TODO')  return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
3679
+			elseif ($statut == '2' || $statut == 'ST_PEND')  return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
3680
+			elseif ($statut == '3' || $statut == 'ST_DONE')  return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
3681 3681
 			else
3682 3682
 			{
3683 3683
 				return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
@@ -3707,13 +3707,13 @@  discard block
 block discarded – undo
3707 3707
 	 *  @param     string      $mode    'customer' or 'supplier'
3708 3708
 	 *  @return    array				array('opened'=>Amount, 'total'=>Total amount)
3709 3709
 	 */
3710
-	function getOutstandingProposals($mode='customer')
3710
+	function getOutstandingProposals($mode = 'customer')
3711 3711
 	{
3712
-		$table='propal';
3712
+		$table = 'propal';
3713 3713
 		if ($mode == 'supplier') $table = 'supplier_proposal';
3714 3714
 
3715 3715
 		$sql  = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
3716
-		$sql .= " WHERE fk_soc = ". $this->id;
3716
+		$sql .= " WHERE fk_soc = ".$this->id;
3717 3717
 		if ($mode == 'supplier') {
3718 3718
 			$sql .= " AND entity IN (".getEntity('supplier_proposal').")";
3719 3719
 		} else {
@@ -3721,21 +3721,21 @@  discard block
 block discarded – undo
3721 3721
 		}
3722 3722
 
3723 3723
 		dol_syslog("getOutstandingProposals", LOG_DEBUG);
3724
-		$resql=$this->db->query($sql);
3724
+		$resql = $this->db->query($sql);
3725 3725
 		if ($resql)
3726 3726
 		{
3727 3727
 			$outstandingOpened = 0;
3728 3728
 			$outstandingTotal = 0;
3729 3729
 			$outstandingTotalIncTax = 0;
3730
-			while($obj=$this->db->fetch_object($resql)) {
3731
-				$outstandingTotal+= $obj->total_ht;
3732
-				$outstandingTotalIncTax+= $obj->total_ttc;
3730
+			while ($obj = $this->db->fetch_object($resql)) {
3731
+				$outstandingTotal += $obj->total_ht;
3732
+				$outstandingTotalIncTax += $obj->total_ttc;
3733 3733
 				if ($obj->fk_statut != 0)    // Not a draft
3734 3734
 				{
3735
-					$outstandingOpened+=$obj->total_ttc;
3735
+					$outstandingOpened += $obj->total_ttc;
3736 3736
 				}
3737 3737
 			}
3738
-			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);	// 'opened' is 'incl taxes'
3738
+			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
3739 3739
 		}
3740 3740
 		else
3741 3741
 			return array();
@@ -3747,13 +3747,13 @@  discard block
 block discarded – undo
3747 3747
 	 *  @param     string      $mode    'customer' or 'supplier'
3748 3748
 	 *  @return		array				array('opened'=>Amount, 'total'=>Total amount)
3749 3749
 	 */
3750
-	function getOutstandingOrders($mode='customer')
3750
+	function getOutstandingOrders($mode = 'customer')
3751 3751
 	{
3752
-		$table='commande';
3752
+		$table = 'commande';
3753 3753
 		if ($mode == 'supplier') $table = 'commande_fournisseur';
3754 3754
 
3755 3755
 		$sql  = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
3756
-		$sql .= " WHERE fk_soc = ". $this->id;
3756
+		$sql .= " WHERE fk_soc = ".$this->id;
3757 3757
 		if ($mode == 'supplier') {
3758 3758
 			$sql .= " AND entity IN (".getEntity('supplier_order').")";
3759 3759
 		} else {
@@ -3761,21 +3761,21 @@  discard block
 block discarded – undo
3761 3761
 		}
3762 3762
 
3763 3763
 		dol_syslog("getOutstandingOrders", LOG_DEBUG);
3764
-		$resql=$this->db->query($sql);
3764
+		$resql = $this->db->query($sql);
3765 3765
 		if ($resql)
3766 3766
 		{
3767 3767
 			$outstandingOpened = 0;
3768 3768
 			$outstandingTotal = 0;
3769 3769
 			$outstandingTotalIncTax = 0;
3770
-			while($obj=$this->db->fetch_object($resql)) {
3771
-				$outstandingTotal+= $obj->total_ht;
3772
-				$outstandingTotalIncTax+= $obj->total_ttc;
3770
+			while ($obj = $this->db->fetch_object($resql)) {
3771
+				$outstandingTotal += $obj->total_ht;
3772
+				$outstandingTotalIncTax += $obj->total_ttc;
3773 3773
 				if ($obj->fk_statut != 0)    // Not a draft
3774 3774
 				{
3775
-					$outstandingOpened+=$obj->total_ttc;
3775
+					$outstandingOpened += $obj->total_ttc;
3776 3776
 				}
3777 3777
 			}
3778
-			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);	// 'opened' is 'incl taxes'
3778
+			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
3779 3779
 		}
3780 3780
 		else
3781 3781
 			return array();
@@ -3787,9 +3787,9 @@  discard block
 block discarded – undo
3787 3787
 	 *  @param     string      $mode    'customer' or 'supplier'
3788 3788
 	 *  @return		array				array('opened'=>Amount, 'total'=>Total amount)
3789 3789
 	 */
3790
-	function getOutstandingBills($mode='customer')
3790
+	function getOutstandingBills($mode = 'customer')
3791 3791
 	{
3792
-		$table='facture';
3792
+		$table = 'facture';
3793 3793
 		if ($mode == 'supplier') $table = 'facture_fourn';
3794 3794
 
3795 3795
 		/* Accurate value of remain to pay is to sum remaintopay for each invoice
@@ -3799,9 +3799,9 @@  discard block
 block discarded – undo
3799 3799
 		 $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
3800 3800
 		 $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
3801 3801
 		 */
3802
-		if ($mode == 'supplier') $sql  = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
3803
-		else $sql  = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
3804
-		$sql .= " WHERE fk_soc = ". $this->id;
3802
+		if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
3803
+		else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
3804
+		$sql .= " WHERE fk_soc = ".$this->id;
3805 3805
 		if ($mode == 'supplier') {
3806 3806
 			$sql .= " AND entity IN (".getEntity('facture_fourn').")";
3807 3807
 		} else {
@@ -3809,7 +3809,7 @@  discard block
 block discarded – undo
3809 3809
 		}
3810 3810
 
3811 3811
 		dol_syslog("getOutstandingBills", LOG_DEBUG);
3812
-		$resql=$this->db->query($sql);
3812
+		$resql = $this->db->query($sql);
3813 3813
 		if ($resql)
3814 3814
 		{
3815 3815
 			$outstandingOpened = 0;
@@ -3818,21 +3818,21 @@  discard block
 block discarded – undo
3818 3818
 			if ($mode == 'supplier')
3819 3819
 			{
3820 3820
 				require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
3821
-				$tmpobject=new FactureFournisseur($this->db);
3821
+				$tmpobject = new FactureFournisseur($this->db);
3822 3822
 			}
3823 3823
 			else
3824 3824
 			{
3825 3825
 				require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
3826
-				$tmpobject=new Facture($this->db);
3826
+				$tmpobject = new Facture($this->db);
3827 3827
 			}
3828
-			while($obj=$this->db->fetch_object($resql)) {
3829
-				$tmpobject->id=$obj->rowid;
3828
+			while ($obj = $this->db->fetch_object($resql)) {
3829
+				$tmpobject->id = $obj->rowid;
3830 3830
 				if ($obj->fk_statut != 0                                           // Not a draft
3831
-					&& ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced')  // Not a replaced invoice
3831
+					&& !($obj->fk_statut == 3 && $obj->close_code == 'replaced')  // Not a replaced invoice
3832 3832
 					)
3833 3833
 				{
3834
-					$outstandingTotal+= $obj->total_ht;
3835
-					$outstandingTotalIncTax+= $obj->total_ttc;
3834
+					$outstandingTotal += $obj->total_ht;
3835
+					$outstandingTotalIncTax += $obj->total_ttc;
3836 3836
 				}
3837 3837
 				if ($obj->paye == 0
3838 3838
 					&& $obj->fk_statut != 0    // Not a draft
@@ -3843,10 +3843,10 @@  discard block
 block discarded – undo
3843 3843
 					$paiement = $tmpobject->getSommePaiement();
3844 3844
 					$creditnotes = $tmpobject->getSumCreditNotesUsed();
3845 3845
 					$deposits = $tmpobject->getSumDepositsUsed();
3846
-					$outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits;
3846
+					$outstandingOpened += $obj->total_ttc - $paiement - $creditnotes - $deposits;
3847 3847
 				}
3848 3848
 			}
3849
-			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax);	// 'opened' is 'incl taxes'
3849
+			return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
3850 3850
 		}
3851 3851
 		else
3852 3852
 		{
@@ -3873,26 +3873,26 @@  discard block
 block discarded – undo
3873 3873
 	     $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
3874 3874
 	     */
3875 3875
 		$sql  = "SELECT rowid, total_ttc FROM ".MAIN_DB_PREFIX."facture as f";
3876
-		$sql .= " WHERE fk_soc = ". $this->id;
3876
+		$sql .= " WHERE fk_soc = ".$this->id;
3877 3877
 		$sql .= " AND paye = 0";
3878
-		$sql .= " AND fk_statut <> 0";	// Not a draft
3878
+		$sql .= " AND fk_statut <> 0"; // Not a draft
3879 3879
 		//$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')";		// Not abandonned for undefined reason
3880
-		$sql .= " AND fk_statut <> 3";		// Not abandonned
3881
-		$sql .= " AND fk_statut <> 2";		// Not clasified as paid
3880
+		$sql .= " AND fk_statut <> 3"; // Not abandonned
3881
+		$sql .= " AND fk_statut <> 2"; // Not clasified as paid
3882 3882
 
3883 3883
 		dol_syslog("get_OutstandingBill", LOG_DEBUG);
3884
-		$resql=$this->db->query($sql);
3884
+		$resql = $this->db->query($sql);
3885 3885
 		if ($resql)
3886 3886
 		{
3887 3887
 			$outstandingAmount = 0;
3888 3888
 			require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
3889
-			$tmpobject=new Facture($this->db);
3890
-			while($obj=$this->db->fetch_object($resql)) {
3891
-				$tmpobject->id=$obj->rowid;
3889
+			$tmpobject = new Facture($this->db);
3890
+			while ($obj = $this->db->fetch_object($resql)) {
3891
+				$tmpobject->id = $obj->rowid;
3892 3892
 				$paiement = $tmpobject->getSommePaiement();
3893 3893
 				$creditnotes = $tmpobject->getSumCreditNotesUsed();
3894 3894
 				$deposits = $tmpobject->getSumDepositsUsed();
3895
-				$outstandingAmount+= $obj->total_ttc - $paiement - $creditnotes - $deposits;
3895
+				$outstandingAmount += $obj->total_ttc - $paiement - $creditnotes - $deposits;
3896 3896
 			}
3897 3897
 			return $outstandingAmount;
3898 3898
 		}
@@ -3923,10 +3923,10 @@  discard block
 block discarded – undo
3923 3923
 		global $langs;
3924 3924
 		$langs->load('companies');
3925 3925
 
3926
-		if ($statut==0) return $langs->trans("NorProspectNorCustomer");
3927
-		if ($statut==1) return $langs->trans("Customer");
3928
-		if ($statut==2) return $langs->trans("Prospect");
3929
-		if ($statut==3) return $langs->trans("ProspectCustomer");
3926
+		if ($statut == 0) return $langs->trans("NorProspectNorCustomer");
3927
+		if ($statut == 1) return $langs->trans("Customer");
3928
+		if ($statut == 2) return $langs->trans("Prospect");
3929
+		if ($statut == 3) return $langs->trans("ProspectCustomer");
3930 3930
 	}
3931 3931
 
3932 3932
 
@@ -3941,26 +3941,26 @@  discard block
 block discarded – undo
3941 3941
 	 *  @param  null|array  $moreparams     Array to provide more information
3942 3942
 	 *	@return int        					<0 if KO, >0 if OK
3943 3943
 	 */
3944
-	public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
3944
+	public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
3945 3945
 	{
3946
-		global $conf,$user,$langs;
3946
+		global $conf, $user, $langs;
3947 3947
 
3948
-		if (! empty($moreparams) && ! empty($moreparams['use_companybankid']))
3948
+		if (!empty($moreparams) && !empty($moreparams['use_companybankid']))
3949 3949
 		{
3950 3950
 			$modelpath = "core/modules/bank/doc/";
3951 3951
 
3952 3952
 			include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
3953 3953
 			$companybankaccount = new CompanyBankAccount($this->db);
3954 3954
 			$result = $companybankaccount->fetch($moreparams['use_companybankid']);
3955
-			if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors);
3956
-			$result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3955
+			if (!$result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors);
3956
+			$result = $companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3957 3957
 		}
3958 3958
 		else
3959 3959
 		{
3960 3960
 			// Positionne le modele sur le nom du modele a utiliser
3961
-			if (! dol_strlen($modele))
3961
+			if (!dol_strlen($modele))
3962 3962
 			{
3963
-				if (! empty($conf->global->COMPANY_ADDON_PDF))
3963
+				if (!empty($conf->global->COMPANY_ADDON_PDF))
3964 3964
 				{
3965 3965
 					$modele = $conf->global->COMPANY_ADDON_PDF;
3966 3966
 				}
@@ -3973,7 +3973,7 @@  discard block
 block discarded – undo
3973 3973
 
3974 3974
 			$modelpath = "core/modules/societe/doc/";
3975 3975
 
3976
-			$result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3976
+			$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
3977 3977
 		}
3978 3978
 
3979 3979
 		return $result;
@@ -3993,7 +3993,7 @@  discard block
 block discarded – undo
3993 3993
 	 */
3994 3994
 	public function setCategories($categories, $type)
3995 3995
 	{
3996
-		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
3996
+		require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
3997 3997
 
3998 3998
 		// Decode type
3999 3999
 		if ($type == 'customer') {
@@ -4003,7 +4003,7 @@  discard block
 block discarded – undo
4003 4003
 			$type_id = Categorie::TYPE_SUPPLIER;
4004 4004
 			$type_text = 'supplier';
4005 4005
 		} else {
4006
-			dol_syslog(__METHOD__ . ': Type ' . $type .  'is an unknown company category type. Done nothing.', LOG_ERR);
4006
+			dol_syslog(__METHOD__.': Type '.$type.'is an unknown company category type. Done nothing.', LOG_ERR);
4007 4007
 			return -1;
4008 4008
 		}
4009 4009
 
Please login to merge, or discard this patch.