Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/htdocs/societe/class/companybankaccount.class.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *		\brief      File of class to manage bank accounts description of third parties
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
28
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 	 * @param   int    $notrigger   1=Disable triggers
68 68
 	 * @return	int					<0 if KO, >= 0 if OK
69 69
 	 */
70
-	function create(User $user = null, $notrigger=0)
70
+	function create(User $user = null, $notrigger = 0)
71 71
 	{
72 72
 		$now	= dol_now();
73
-		$error	= 0;
73
+		$error = 0;
74 74
 		// Correct default_rib to be sure to have always one default
75 75
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
76 76
    		$result = $this->db->query($sql);
77 77
 		if ($result)
78 78
 		{
79
-			$numrows=$this->db->num_rows($result);
79
+			$numrows = $this->db->num_rows($result);
80 80
 			if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
81 81
 			if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
82 82
 		}
83 83
 
84 84
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
85
-		$sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
-		$resql=$this->db->query($sql);
85
+		$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
86
+		$resql = $this->db->query($sql);
87 87
 		if ($resql)
88 88
 		{
89 89
 			if ($this->db->affected_rows($resql))
90 90
 			{
91 91
 				$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
92 92
 
93
-				if (! $notrigger)
93
+				if (!$notrigger)
94 94
 				{
95 95
 				   	// Call trigger
96
-					$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
96
+					$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
97 97
 					if ($result < 0) $error++;
98 98
 					// End call triggers
99 99
 
100
-					if (! $error)
100
+					if (!$error)
101 101
 					{
102 102
 						return 1;
103 103
 					}
@@ -131,47 +131,47 @@  discard block
 block discarded – undo
131 131
 		global $conf;
132 132
 		$error = 0;
133 133
 
134
-		if (! $this->id) return -1;
134
+		if (!$this->id) return -1;
135 135
 
136 136
 		if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
137 137
 		if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
138 138
 
139 139
 		$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
140
-		$sql.= " bank = '" .$this->db->escape($this->bank)."'";
141
-		$sql.= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
-		$sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
-		$sql.= ",number='".$this->db->escape($this->number)."'";
144
-		$sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
-		$sql.= ",bic='".$this->db->escape($this->bic)."'";
146
-		$sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
-		$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
-		$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
149
-		$sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
-		$sql.= ",default_rib = ".$this->default_rib;
140
+		$sql .= " bank = '".$this->db->escape($this->bank)."'";
141
+		$sql .= ",code_banque='".$this->db->escape($this->code_banque)."'";
142
+		$sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'";
143
+		$sql .= ",number='".$this->db->escape($this->number)."'";
144
+		$sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'";
145
+		$sql .= ",bic='".$this->db->escape($this->bic)."'";
146
+		$sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'";
147
+		$sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
148
+		$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
149
+		$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
150
+		$sql .= ",default_rib = ".$this->default_rib;
151 151
 		if ($conf->prelevement->enabled)
152 152
 		{
153
-			$sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
-			$sql.= ",rum = '".$this->db->escape($this->rum)."'";
155
-			$sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
153
+			$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
154
+			$sql .= ",rum = '".$this->db->escape($this->rum)."'";
155
+			$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
156 156
 		}
157 157
 		if (trim($this->label) != '')
158
-			$sql.= ",label = '".$this->db->escape($this->label)."'";
158
+			$sql .= ",label = '".$this->db->escape($this->label)."'";
159 159
 		else
160
-			$sql.= ",label = NULL";
161
-		$sql.= " WHERE rowid = ".$this->id;
160
+			$sql .= ",label = NULL";
161
+		$sql .= " WHERE rowid = ".$this->id;
162 162
 
163 163
 		$result = $this->db->query($sql);
164 164
 		if ($result)
165 165
 		{
166 166
 
167 167
 
168
-		if (! $notrigger)
168
+		if (!$notrigger)
169 169
 		{
170 170
 			// Call trigger
171
-			$result=$this->call_trigger('COMPANY_RIB_MODIFY',$user);
171
+			$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
172 172
 			if ($result < 0) $error++;
173 173
 			// End call triggers
174
-			if(! $error )
174
+			if (!$error)
175 175
 			{
176 176
 				return 1;
177 177
 			}
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 	 *  @param	int		$type		If id of company filled, we say if we want record of this type only
202 202
 	 * 	@return	int					<0 if KO, >0 if OK
203 203
 	 */
204
-	function fetch($id, $socid=0, $default=1, $type='ban')
204
+	function fetch($id, $socid = 0, $default = 1, $type = 'ban')
205 205
 	{
206 206
 		if (empty($id) && empty($socid)) return -1;
207 207
 
208 208
 		$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
209
-		$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
-		if ($id)    $sql.= " WHERE rowid = ".$id;
209
+		$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
210
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
211
+		if ($id)    $sql .= " WHERE rowid = ".$id;
212 212
 		if ($socid)
213 213
 		{
214
-			$sql.= " WHERE fk_soc  = ".$socid;
215
-			if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default);
216
-			if ($type) $sql.= " AND type ='".$this->db->escape($type)."'";
214
+			$sql .= " WHERE fk_soc  = ".$socid;
215
+			if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
216
+			if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
217 217
 		}
218 218
 
219 219
 		$resql = $this->db->query($sql);
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 			{
224 224
 				$obj = $this->db->fetch_object($resql);
225 225
 
226
-				$this->ref             = $obj->fk_soc.'-'.$obj->label;      // Generate an artificial ref
226
+				$this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
227 227
 
228
-				$this->id			   = $obj->rowid;
229
-				$this->type			   = $obj->type;
228
+				$this->id = $obj->rowid;
229
+				$this->type = $obj->type;
230 230
 				$this->socid           = $obj->fk_soc;
231 231
 				$this->bank            = $obj->bank;
232 232
 				$this->code_banque     = $obj->code_banque;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				$this->number          = $obj->number;
235 235
 				$this->cle_rib         = $obj->cle_rib;
236 236
 				$this->bic             = $obj->bic;
237
-				$this->iban		       = $obj->iban;
237
+				$this->iban = $obj->iban;
238 238
 				$this->domiciliation   = $obj->domiciliation;
239 239
 				$this->proprio         = $obj->proprio;
240 240
 				$this->owner_address   = $obj->owner_address;
@@ -263,37 +263,37 @@  discard block
 block discarded – undo
263 263
 	 *	@param  	int		$notrigger	1=Disable triggers
264 264
 	 *  @return		int		            <0 if KO, >0 if OK
265 265
 	 */
266
-	function delete(User $user = null, $notrigger=0)
266
+	function delete(User $user = null, $notrigger = 0)
267 267
 	{
268 268
 		global $conf;
269 269
 
270 270
 		$error = 0;
271 271
 
272
-		dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
272
+		dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG);
273 273
 
274 274
 		$this->db->begin();
275 275
 
276
-		if (! $error && ! $notrigger)
276
+		if (!$error && !$notrigger)
277 277
 		{
278 278
 			// Call trigger
279
-			$result=$this->call_trigger('COMPANY_RIB_DELETE',$user);
279
+			$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
280 280
 			if ($result < 0) $error++;
281 281
 			// End call triggers
282 282
 		}
283 283
 
284
-		if (! $error)
284
+		if (!$error)
285 285
 		{
286
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
287
-			$sql .= " WHERE rowid  = " . $this->id;
286
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
287
+			$sql .= " WHERE rowid  = ".$this->id;
288 288
 
289
-			if (! $this->db->query($sql))
289
+			if (!$this->db->query($sql))
290 290
 			{
291 291
 				$error++;
292
-				$this->errors[]=$this->db->lasterror();
292
+				$this->errors[] = $this->db->lasterror();
293 293
 			}
294 294
 		}
295 295
 
296
-		if (! $error)
296
+		if (!$error)
297 297
 		{
298 298
 			$this->db->commit();
299 299
 			return 1;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		else
302 302
 		{
303 303
 			$this->db->rollback();
304
-			return -1*$error;
304
+			return -1 * $error;
305 305
 		}
306 306
 	}
307 307
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	{
316 316
 		$rib = '';
317 317
 
318
-		if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
318
+		if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) {
319 319
 
320 320
 			if ($this->label && $displayriblabel) {
321 321
 				$rib = $this->label." : ";
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 	 * @param   int     $rib    RIB id
334 334
 	 * @return  int             0 if KO, 1 if OK
335 335
 	 */
336
-	function setAsDefault($rib=0)
336
+	function setAsDefault($rib = 0)
337 337
 	{
338 338
 		$sql1 = "SELECT rowid as id, fk_soc  FROM ".MAIN_DB_PREFIX."societe_rib";
339
-		$sql1.= " WHERE rowid = ".($rib?$rib:$this->id);
339
+		$sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id);
340 340
 
341 341
 		dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
342 342
 		$result1 = $this->db->query($sql1);
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 				$this->db->begin();
354 354
 
355 355
 				$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0";
356
-				$sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
356
+				$sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc;
357 357
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
358 358
 				$result2 = $this->db->query($sql2);
359 359
 
360 360
 				$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
361
-				$sql3.= " WHERE rowid = ".$obj->id;
361
+				$sql3 .= " WHERE rowid = ".$obj->id;
362 362
 				dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
363 363
 				$result3 = $this->db->query($sql3);
364 364
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		$this->country_id      = 1;
410 410
 
411 411
 		$this->rum             = 'UMR-CU1212-0007-5-1475405262';
412
-		$this->date_rum        =dol_now() - 10000;
412
+		$this->date_rum        = dol_now() - 10000;
413 413
 		$this->frstrecur       = 'FRST';
414 414
 
415 415
 		$this->socid = 0;
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/api_contacts.class.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
83 83
 		{
84
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
84
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
85 85
 		}
86 86
 
87 87
 		return $this->_cleanObjectDatas($this->contact);
@@ -122,37 +122,37 @@  discard block
 block discarded – undo
122 122
 			$search_sale = DolibarrApiAccess::$user->id;
123 123
 
124 124
 		$sql = "SELECT t.rowid";
125
-		$sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
126
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid";
125
+		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
126
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid";
127 127
 		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
128 128
 			// We need this table joined to the select in order to filter by sale
129
-			$sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
129
+			$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
130 130
 		}
131
-		$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid";
132
-		$sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')';
133
-		if ($socids) $sql.= " AND t.fk_soc IN (" . $socids . ")";
131
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
132
+		$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
133
+		if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
134 134
 
135 135
 		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
136
-			$sql.= " AND t.fk_soc = sc.fk_soc";
136
+			$sql .= " AND t.fk_soc = sc.fk_soc";
137 137
 		if ($search_sale > 0)
138
-			$sql.= " AND s.rowid = sc.fk_soc";  // Join for the needed table to filter by sale
138
+			$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
139 139
 		// Insert sale filter
140 140
 		if ($search_sale > 0)
141 141
 		{
142
-			$sql .= " AND sc.fk_user = " . $search_sale;
142
+			$sql .= " AND sc.fk_user = ".$search_sale;
143 143
 		}
144 144
 	    // Add sql filters
145 145
         if ($sqlfilters)
146 146
         {
147
-            if (! DolibarrApi::_checkFilters($sqlfilters))
147
+            if (!DolibarrApi::_checkFilters($sqlfilters))
148 148
             {
149 149
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
150 150
             }
151
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
152
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
151
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
152
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
153 153
         }
154 154
 
155
-		$sql.= $db->order($sortfield, $sortorder);
155
+		$sql .= $db->order($sortfield, $sortorder);
156 156
 
157 157
 		if ($limit)
158 158
 		{
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			}
163 163
 			$offset = $limit * $page;
164 164
 
165
-			$sql.= $db->plimit($limit + 1, $offset);
165
+			$sql .= $db->plimit($limit + 1, $offset);
166 166
 		}
167 167
 		$result = $db->query($sql);
168 168
 		if ($result)
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			}
182 182
 		}
183 183
 		else {
184
-			throw new RestException(503, 'Error when retrieve contacts : ' . $sql);
184
+			throw new RestException(503, 'Error when retrieve contacts : '.$sql);
185 185
 		}
186 186
 		if (!count($obj_ret))
187 187
 		{
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
239 239
 		{
240
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
240
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
241 241
 		}
242 242
 
243 243
 		foreach ($request_data as $field => $value)
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
 		if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
274 274
 		{
275
-			throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
275
+			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
276 276
 		}
277 277
 
278 278
 		return $this->contact->delete($id);
@@ -312,19 +312,19 @@  discard block
 block discarded – undo
312 312
 	    }
313 313
 
314 314
 	    if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) {
315
-	        throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
315
+	        throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
316 316
 	    }
317 317
 
318 318
 	    // Check mandatory fields
319 319
 	    $login = $request_data["login"];
320 320
 	    $password = $request_data["password"];
321 321
 	    $useraccount = new User($this->db);
322
-	    $result = $useraccount->create_from_contact($contact,$login,$password);
322
+	    $result = $useraccount->create_from_contact($contact, $login, $password);
323 323
 	    if ($result <= 0) {
324 324
 	        throw new RestException(500, "User not created");
325 325
 	    }
326 326
 	    // password parameter not used in create_from_contact
327
-	    $useraccount->setPassword($useraccount,$password);
327
+	    $useraccount->setPassword($useraccount, $password);
328 328
 
329 329
 	    return $result;
330 330
 	}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
 	function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
346 346
 	{
347
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
347
+		if (!DolibarrApiAccess::$user->rights->categorie->lire) {
348 348
 			throw new RestException(401);
349 349
 		}
350 350
 
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/societeaccount.class.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 
28 28
 // Put here all includes required by your class file
29
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
29
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30 30
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
31 31
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32 32
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
79 79
 	 */
80
-	public $fields=array(
80
+	public $fields = array(
81 81
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
82 82
 		'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'default'=>1),
83 83
 		'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>-1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',),
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
98 98
 		'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
99 99
 		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
100
-		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active','0'=>'Disabled')),
100
+		'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'default'=>1, 'arrayofkeyval'=>array('1'=>'Active', '0'=>'Disabled')),
101 101
 	);
102 102
 
103 103
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 		$this->db = $db;
188 188
 
189
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
189
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
190 190
 	}
191 191
 
192 192
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	public function fetch($id, $ref = null)
261 261
 	{
262 262
 		$result = $this->fetchCommon($id, $ref);
263
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
263
+		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
264 264
 		return $result;
265 265
 	}
266 266
 
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public function fetchLines()
273 273
 	{
274
-		$this->lines=array();
274
+		$this->lines = array();
275 275
 
276 276
 		// Load lines with object societeAccountLine
277 277
 
278
-		return count($this->lines)?1:0;
278
+		return count($this->lines) ? 1 : 0;
279 279
 	}
280 280
 
281 281
 	/**
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 	 * @param	int		$status		Status (0=test, 1=live)
287 287
 	 * @return	string				Stripe customer ref 'cu_xxxxxxxxxxxxx' or ''
288 288
 	 */
289
-	public function getCustomerAccount($id, $site, $status=0)
289
+	public function getCustomerAccount($id, $site, $status = 0)
290 290
 	{
291 291
 		$sql = "SELECT sa.key_account as key_account, sa.entity";
292
-		$sql.= " FROM " . MAIN_DB_PREFIX . "societe_account as sa";
293
-		$sql.= " WHERE sa.fk_soc = " . $id;
294
-		$sql.= " AND sa.entity IN (".getEntity('societe').")";
295
-		$sql.= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
-		$sql.= " AND key_account IS NOT NULL AND key_account <> ''";
292
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa";
293
+		$sql .= " WHERE sa.fk_soc = ".$id;
294
+		$sql .= " AND sa.entity IN (".getEntity('societe').")";
295
+		$sql .= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status);
296
+		$sql .= " AND key_account IS NOT NULL AND key_account <> ''";
297 297
 		//$sql.= " ORDER BY sa.key_account DESC";
298 298
 
299
-		dol_syslog(get_class($this) . "::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
299
+		dol_syslog(get_class($this)."::getCustomerAccount Try to find the first system customer id for ".$site." of thirdparty id=".$id." (exemple: cus_.... for stripe)", LOG_DEBUG);
300 300
 		$result = $this->db->query($sql);
301 301
 		if ($result) {
302 302
 			if ($this->db->num_rows($result)) {
@@ -346,54 +346,54 @@  discard block
 block discarded – undo
346 346
      *  @param  int     $save_lastsearch_value    	-1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
347 347
 	 *	@return	string								String with URL
348 348
 	 */
349
-	function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
349
+	function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
350 350
 	{
351 351
 		global $db, $conf, $langs;
352 352
         global $dolibarr_main_authentication, $dolibarr_main_demo;
353 353
         global $menumanager;
354 354
 
355
-        if (! empty($conf->dol_no_mouse_hover)) $notooltip=1;   // Force disable tooltips
355
+        if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
356 356
 
357 357
         $result = '';
358 358
         $companylink = '';
359 359
 
360 360
         $this->ref = $this->login;
361 361
 
362
-        $label = '<u>' . $langs->trans("SocieteAccount") . '</u>';
363
-        $label.= '<br>';
364
-        $label.= '<b>' . $langs->trans('Login') . ':</b> ' . $this->ref;
362
+        $label = '<u>'.$langs->trans("SocieteAccount").'</u>';
363
+        $label .= '<br>';
364
+        $label .= '<b>'.$langs->trans('Login').':</b> '.$this->ref;
365 365
         //$label.= '<b>' . $langs->trans('WebSite') . ':</b> ' . $this->ref;
366 366
 
367
-        $url = dol_buildpath('/website/websiteaccount_card.php',1).'?id='.$this->id;
367
+        $url = dol_buildpath('/website/websiteaccount_card.php', 1).'?id='.$this->id;
368 368
 
369 369
         if ($option != 'nolink')
370 370
         {
371 371
 	        // Add param to save lastsearch_values or not
372
-	        $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
373
-	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
374
-	        if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
372
+	        $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
373
+	        if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
374
+	        if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
375 375
         }
376 376
 
377
-        $linkclose='';
377
+        $linkclose = '';
378 378
         if (empty($notooltip))
379 379
         {
380
-            if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
380
+            if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
381 381
             {
382
-                $label=$langs->trans("ShowsocieteAccount");
383
-                $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
382
+                $label = $langs->trans("ShowsocieteAccount");
383
+                $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
384 384
             }
385
-            $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
386
-            $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
385
+            $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
386
+            $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
387 387
         }
388
-        else $linkclose = ($morecss?' class="'.$morecss.'"':'');
388
+        else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
389 389
 
390 390
 		$linkstart = '<a href="'.$url.'"';
391
-		$linkstart.=$linkclose.'>';
392
-		$linkend='</a>';
391
+		$linkstart .= $linkclose.'>';
392
+		$linkend = '</a>';
393 393
 
394 394
 		$result .= $linkstart;
395
-		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);
396
-		if ($withpicto != 2) $result.= $this->ref;
395
+		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);
396
+		if ($withpicto != 2) $result .= $this->ref;
397 397
 		$result .= $linkend;
398 398
 
399 399
 		return $result;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @param	int				$withpicto			Add download picto into link
406 406
 	 * @return	string			HTML link to file
407 407
 	 */
408
-	function getDirectExternalLink($withpicto=0)
408
+	function getDirectExternalLink($withpicto = 0)
409 409
 	{
410 410
 		return 'todo';
411 411
 	}
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
417 417
 	 *  @return	string 			       Label of status
418 418
 	 */
419
-	function getLibStatut($mode=0)
419
+	function getLibStatut($mode = 0)
420 420
 	{
421
-		return $this->LibStatut($this->status,$mode);
421
+		return $this->LibStatut($this->status, $mode);
422 422
 	}
423 423
 
424 424
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
 	 *  @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
430 430
 	 *  @return string 			       	Label of status
431 431
 	 */
432
-	static function LibStatut($status,$mode=0)
432
+	static function LibStatut($status, $mode = 0)
433 433
 	{
434 434
         // phpcs:enable
435 435
 		global $langs;
436 436
 
437 437
 		if ($mode == 0)
438 438
 		{
439
-			$prefix='';
439
+			$prefix = '';
440 440
 			if ($status == 1) return $langs->trans('Enabled');
441 441
 			elseif ($status == 0) return $langs->trans('Disabled');
442 442
 		}
@@ -447,28 +447,28 @@  discard block
 block discarded – undo
447 447
 		}
448 448
 		elseif ($mode == 2)
449 449
 		{
450
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
451
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
450
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
451
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
452 452
 		}
453 453
 		elseif ($mode == 3)
454 454
 		{
455
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
456
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
455
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
456
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
457 457
 		}
458 458
 		elseif ($mode == 4)
459 459
 		{
460
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
461
-			elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
460
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
461
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
462 462
 		}
463 463
 		elseif ($mode == 5)
464 464
 		{
465
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
466
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
465
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
466
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
467 467
 		}
468 468
 		elseif ($mode == 6)
469 469
 		{
470
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
471
-			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
470
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
471
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
472 472
 		}
473 473
 	}
474 474
 
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	function info($id)
482 482
 	{
483 483
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
484
-		$sql.= ' fk_user_creat, fk_user_modif';
485
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
-		$sql.= ' WHERE t.rowid = '.$id;
487
-		$result=$this->db->query($sql);
484
+		$sql .= ' fk_user_creat, fk_user_modif';
485
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
486
+		$sql .= ' WHERE t.rowid = '.$id;
487
+		$result = $this->db->query($sql);
488 488
 		if ($result)
489 489
 		{
490 490
 			if ($this->db->num_rows($result))
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 				{
496 496
 					$cuser = new User($this->db);
497 497
 					$cuser->fetch($obj->fk_user_author);
498
-					$this->user_creation   = $cuser;
498
+					$this->user_creation = $cuser;
499 499
 				}
500 500
 
501 501
 				if ($obj->fk_user_valid)
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 				{
510 510
 					$cluser = new User($this->db);
511 511
 					$cluser->fetch($obj->fk_user_cloture);
512
-					$this->user_cloture   = $cluser;
512
+					$this->user_cloture = $cluser;
513 513
 				}
514 514
 
515 515
 				$this->date_creation     = $this->db->jdate($obj->datec);
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/client.class.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class Client extends Societe
31 31
 {
32
-    public $next_prev_filter="te.client in (1,2,3)";	// Used to add a filter in Form::showrefnav method
32
+    public $next_prev_filter = "te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method
33 33
 
34
-    public $cacheprospectstatus=array();
34
+    public $cacheprospectstatus = array();
35 35
 
36 36
 
37 37
 	/**
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
         // phpcs:enable
59 59
         global $user;
60 60
 
61
-        $this->nb=array("customers" => 0,"prospects" => 0);
61
+        $this->nb = array("customers" => 0, "prospects" => 0);
62 62
         $clause = "WHERE";
63 63
 
64 64
         $sql = "SELECT count(s.rowid) as nb, s.client";
65
-        $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
65
+        $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
66 66
         if (!$user->rights->societe->client->voir && !$user->societe_id)
67 67
         {
68
-        	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
69
-        	$sql.= " WHERE sc.fk_user = " .$user->id;
68
+        	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
69
+        	$sql .= " WHERE sc.fk_user = ".$user->id;
70 70
         	$clause = "AND";
71 71
         }
72
-        $sql.= " ".$clause." s.client IN (1,2,3)";
73
-        $sql.= ' AND s.entity IN ('.getEntity($this->element).')';
74
-        $sql.= " GROUP BY s.client";
72
+        $sql .= " ".$clause." s.client IN (1,2,3)";
73
+        $sql .= ' AND s.entity IN ('.getEntity($this->element).')';
74
+        $sql .= " GROUP BY s.client";
75 75
 
76
-        $resql=$this->db->query($sql);
76
+        $resql = $this->db->query($sql);
77 77
         if ($resql)
78 78
         {
79
-            while ($obj=$this->db->fetch_object($resql))
79
+            while ($obj = $this->db->fetch_object($resql))
80 80
             {
81
-                if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"]+=$obj->nb;
82
-                if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"]+=$obj->nb;
81
+                if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb;
82
+                if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb;
83 83
             }
84 84
             $this->db->free($resql);
85 85
             return 1;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         else
88 88
         {
89 89
             dol_print_error($this->db);
90
-            $this->error=$this->db->lasterror();
90
+            $this->error = $this->db->lasterror();
91 91
             return -1;
92 92
         }
93 93
     }
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	 *  @param	int		$active     1=Active only, 0=Not active only, -1=All
99 99
 	 *  @return int					<0 if KO, >0 if OK
100 100
 	 */
101
-    function loadCacheOfProspStatus($active=1)
101
+    function loadCacheOfProspStatus($active = 1)
102 102
     {
103 103
     	global $langs;
104 104
 
105
-   		$sql="SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm";
106
-   		if ($active >= 0) $sql.=" WHERE active = ".$active;
107
-		$resql=$this->db->query($sql);
108
-		$num=$this->db->num_rows($resql);
109
-		$i=0;
105
+   		$sql = "SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm";
106
+   		if ($active >= 0) $sql .= " WHERE active = ".$active;
107
+		$resql = $this->db->query($sql);
108
+		$num = $this->db->num_rows($resql);
109
+		$i = 0;
110 110
 		while ($i < $num)
111 111
 		{
112
-			$obj=$this->db->fetch_object($resql);
113
-			$this->cacheprospectstatus[$obj->id]=array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code))=="ST_".strtoupper($obj->code))?$obj->label:$langs->trans("ST_".strtoupper($obj->code)));
112
+			$obj = $this->db->fetch_object($resql);
113
+			$this->cacheprospectstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)));
114 114
 			$i++;
115 115
 		}
116 116
 		return 1;
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/class/api_thirdparties.class.php 1 patch
Spacing   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 		$this->company = new Societe($this->db);
58 58
 
59
-		if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) {
59
+		if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) {
60 60
 			static::$FIELDS[] = 'email';
61 61
 		}
62 62
 	}
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	function get($id)
75 75
 	{
76
-		if(! DolibarrApiAccess::$user->rights->societe->lire) {
76
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
77 77
 			throw new RestException(401);
78 78
 		}
79 79
 
80 80
 		$result = $this->company->fetch($id);
81
-		if( ! $result ) {
81
+		if (!$result) {
82 82
 			throw new RestException(404, 'Thirdparty not found');
83 83
 		}
84 84
 
85
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
85
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
86 86
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
87 87
 		}
88 88
 
89
-		if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
89
+		if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
90 90
 			$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
91 91
 			$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
92 92
 		} else {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param   string  $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')"
118 118
 	 * @return  array               Array of thirdparty objects
119 119
 	 */
120
-	function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode=0, $sqlfilters = '')
120
+	function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '')
121 121
     {
122 122
 		global $db, $conf;
123 123
 
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 
129 129
 		// If the internal user must only see his customers, force searching by him
130 130
 		$search_sale = 0;
131
-		if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
131
+		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
132 132
 
133 133
 		$sql = "SELECT t.rowid";
134 134
 		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
135
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as t";
136
-
137
-		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
138
-		$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
139
-		$sql.= " WHERE t.fk_stcomm = st.id";
140
-		if ($mode == 1) $sql.= " AND t.client IN (1, 3)";
141
-		if ($mode == 2) $sql.= " AND t.client IN (2, 3)";
142
-		if ($mode == 3) $sql.= " AND t.client IN (0)";
143
-		$sql.= ' AND t.entity IN ('.getEntity('societe').')';
144
-		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc";
135
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
136
+
137
+		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
138
+		$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
139
+		$sql .= " WHERE t.fk_stcomm = st.id";
140
+		if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
141
+		if ($mode == 2) $sql .= " AND t.client IN (2, 3)";
142
+		if ($mode == 3) $sql .= " AND t.client IN (0)";
143
+		$sql .= ' AND t.entity IN ('.getEntity('societe').')';
144
+		if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
145 145
 		//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
146
-		if ($socid) $sql.= " AND t.rowid IN (".$socids.")";
147
-		if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc";		// Join for the needed table to filter by sale
146
+		if ($socid) $sql .= " AND t.rowid IN (".$socids.")";
147
+		if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
148 148
 		// Insert sale filter
149 149
 		if ($search_sale > 0)
150 150
 		{
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 		// Add sql filters
154 154
 		if ($sqlfilters)
155 155
 		{
156
-			if (! DolibarrApi::_checkFilters($sqlfilters))
156
+			if (!DolibarrApi::_checkFilters($sqlfilters))
157 157
 			{
158 158
 				throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
159 159
 			}
160
-			$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
161
-			$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
160
+			$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
161
+			$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
162 162
 		}
163 163
 
164
-		$sql.= $db->order($sortfield, $sortorder);
164
+		$sql .= $db->order($sortfield, $sortorder);
165 165
 
166 166
 		if ($limit) {
167 167
 			if ($page < 0)
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			}
171 171
 			$offset = $limit * $page;
172 172
 
173
-			$sql.= $db->plimit($limit + 1, $offset);
173
+			$sql .= $db->plimit($limit + 1, $offset);
174 174
 		}
175 175
 
176 176
 		$result = $db->query($sql);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			{
183 183
 				$obj = $db->fetch_object($result);
184 184
 				$soc_static = new Societe($db);
185
-				if($soc_static->fetch($obj->rowid)) {
185
+				if ($soc_static->fetch($obj->rowid)) {
186 186
 					$obj_ret[] = $this->_cleanObjectDatas($soc_static);
187 187
 				}
188 188
 				$i++;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		else {
192 192
 			throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror());
193 193
 		}
194
-		if( ! count($obj_ret)) {
194
+		if (!count($obj_ret)) {
195 195
 			throw new RestException(404, 'Thirdparties not found');
196 196
 		}
197 197
 		return $obj_ret;
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	function post($request_data = null)
207 207
 	{
208
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
208
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
209 209
 			throw new RestException(401);
210 210
 		}
211 211
 		// Check mandatory fields
212 212
 		$result = $this->_validate($request_data);
213 213
 
214
-		foreach($request_data as $field => $value) {
214
+		foreach ($request_data as $field => $value) {
215 215
 			$this->company->$field = $value;
216 216
 		}
217 217
 		if ($this->company->create(DolibarrApiAccess::$user) < 0)
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	function put($id, $request_data = null)
231 231
 	{
232
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
232
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
233 233
 			throw new RestException(401);
234 234
 		}
235 235
 
236 236
 		$result = $this->company->fetch($id);
237
-		if( ! $result ) {
237
+		if (!$result) {
238 238
 			throw new RestException(404, 'Thirdparty not found');
239 239
 		}
240 240
 
241
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
241
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
242 242
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
243 243
 		}
244 244
 
245
-		foreach($request_data as $field => $value) {
245
+		foreach ($request_data as $field => $value) {
246 246
 			if ($field == 'id') continue;
247 247
 			$this->company->$field = $value;
248 248
 		}
249 249
 
250
-		if($this->company->update($id, DolibarrApiAccess::$user,1,'','','update'))
250
+		if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
251 251
 			return $this->get($id);
252 252
 
253 253
 		return false;
@@ -278,27 +278,27 @@  discard block
 block discarded – undo
278 278
 			throw new RestException(400, 'Try to merge a thirdparty into itself');
279 279
 		}
280 280
 
281
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
281
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
282 282
 			throw new RestException(401);
283 283
 		}
284 284
 
285
-		$result = $this->company->fetch($id);	// include the fetch of extra fields
286
-		if( ! $result ) {
285
+		$result = $this->company->fetch($id); // include the fetch of extra fields
286
+		if (!$result) {
287 287
 			throw new RestException(404, 'Thirdparty not found');
288 288
 		}
289 289
 
290
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
290
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
291 291
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
292 292
 		}
293 293
 
294 294
 		$this->companytoremove = new Societe($db);
295 295
 
296
-		$result = $this->companytoremove->fetch($idtodelete);	// include the fetch of extra fields
297
-		if( ! $result ) {
296
+		$result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields
297
+		if (!$result) {
298 298
 			throw new RestException(404, 'Thirdparty not found');
299 299
 		}
300 300
 
301
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->companytoremove->id)) {
301
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) {
302 302
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
303 303
 		}
304 304
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		// Recopy some data
316 316
 		$object->client = $object->client | $soc_origin->client;
317 317
 		$object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
318
-		$listofproperties=array(
318
+		$listofproperties = array(
319 319
 			'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
320 320
 			'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
321 321
 			'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 
331 331
 		// Concat some data
332
-		$listofproperties=array(
332
+		$listofproperties = array(
333 333
 			'note_public', 'note_private'
334 334
 		);
335 335
 		foreach ($listofproperties as $property)
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 		}
374 374
 
375 375
 		// Move links
376
-		if (! $error)
376
+		if (!$error)
377 377
 		{
378 378
 			$objects = array(
379 379
 				'Adherent' => '/adherents/class/adherent.class.php',
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 		}
429 429
 
430 430
 
431
-		if (! $error)
431
+		if (!$error)
432 432
 		{
433
-			$object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id);
433
+			$object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id);
434 434
 
435 435
 			// Call trigger
436
-			$result=$object->call_trigger('COMPANY_MODIFY',$user);
436
+			$result = $object->call_trigger('COMPANY_MODIFY', $user);
437 437
 			if ($result < 0)
438 438
 			{
439 439
 				//setEventMessages($object->error, $object->errors, 'errors');
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			// End call triggers
443 443
 		}
444 444
 
445
-		if (! $error)
445
+		if (!$error)
446 446
 		{
447 447
 			//We finally remove the old thirdparty
448 448
 			if ($soc_origin->delete($soc_origin->id, $user) < 1)
@@ -475,14 +475,14 @@  discard block
 block discarded – undo
475 475
 	 */
476 476
 	function delete($id)
477 477
 	{
478
-		if(! DolibarrApiAccess::$user->rights->societe->supprimer) {
478
+		if (!DolibarrApiAccess::$user->rights->societe->supprimer) {
479 479
 			throw new RestException(401);
480 480
 		}
481 481
 		$result = $this->company->fetch($id);
482
-		if( ! $result ) {
482
+		if (!$result) {
483 483
 			throw new RestException(404, 'Thirdparty not found');
484 484
 		}
485
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
485
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
486 486
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
487 487
 		}
488 488
 		return $this->company->delete($id);
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
505 505
 	{
506
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
506
+		if (!DolibarrApiAccess::$user->rights->categorie->lire) {
507 507
 			throw new RestException(401);
508 508
 		}
509 509
 
510 510
 		$result = $this->company->fetch($id);
511
-		if( ! $result )
511
+		if (!$result)
512 512
 		{
513 513
 			throw new RestException(404, 'Thirdparty not found');
514 514
 		}
@@ -542,28 +542,28 @@  discard block
 block discarded – undo
542 542
 	 */
543 543
 	function addCategory($id, $category_id)
544 544
 	{
545
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
545
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
546 546
 			throw new RestException(401);
547 547
 		}
548 548
 
549 549
 		$result = $this->company->fetch($id);
550
-		if( ! $result ) {
550
+		if (!$result) {
551 551
 			throw new RestException(404, 'Thirdparty not found');
552 552
 		}
553 553
 		$category = new Categorie($this->db);
554 554
 		$result = $category->fetch($category_id);
555
-		if( ! $result ) {
555
+		if (!$result) {
556 556
 			throw new RestException(404, 'category not found');
557 557
 		}
558 558
 
559
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
559
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
560 560
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
561 561
 		}
562
-		if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) {
562
+		if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
563 563
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
564 564
 		}
565 565
 
566
-		$category->add_type($this->company,'customer');
566
+		$category->add_type($this->company, 'customer');
567 567
 
568 568
 		return $this->_cleanObjectDatas($this->company);
569 569
 	}
@@ -580,28 +580,28 @@  discard block
 block discarded – undo
580 580
 	 */
581 581
 	function deleteCategory($id, $category_id)
582 582
 	{
583
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
583
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
584 584
 			throw new RestException(401);
585 585
 		}
586 586
 
587 587
 		$result = $this->company->fetch($id);
588
-		if( ! $result ) {
588
+		if (!$result) {
589 589
 			throw new RestException(404, 'Thirdparty not found');
590 590
 		}
591 591
 		$category = new Categorie($this->db);
592 592
 		$result = $category->fetch($category_id);
593
-		if( ! $result ) {
593
+		if (!$result) {
594 594
 			throw new RestException(404, 'category not found');
595 595
 		}
596 596
 
597
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
597
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
598 598
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
599 599
 		}
600
-		if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) {
600
+		if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
601 601
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
602 602
 		}
603 603
 
604
-		$category->del_type($this->company,'customer');
604
+		$category->del_type($this->company, 'customer');
605 605
 
606 606
 		return $this->_cleanObjectDatas($this->company);
607 607
 	}
@@ -621,12 +621,12 @@  discard block
 block discarded – undo
621 621
 	 */
622 622
 	function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
623 623
 	{
624
-		if (! DolibarrApiAccess::$user->rights->categorie->lire) {
624
+		if (!DolibarrApiAccess::$user->rights->categorie->lire) {
625 625
 			throw new RestException(401);
626 626
 		}
627 627
 
628 628
 		$result = $this->company->fetch($id);
629
-		if( ! $result )
629
+		if (!$result)
630 630
 		{
631 631
 			throw new RestException(404, 'Thirdparty not found');
632 632
 		}
@@ -660,28 +660,28 @@  discard block
 block discarded – undo
660 660
 	 */
661 661
 	function addSupplierCategory($id, $category_id)
662 662
 	{
663
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
663
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
664 664
 			throw new RestException(401);
665 665
 		}
666 666
 
667 667
 		$result = $this->company->fetch($id);
668
-		if( ! $result ) {
668
+		if (!$result) {
669 669
 			throw new RestException(404, 'Thirdparty not found');
670 670
 		}
671 671
 		$category = new Categorie($this->db);
672 672
 		$result = $category->fetch($category_id);
673
-		if( ! $result ) {
673
+		if (!$result) {
674 674
 			throw new RestException(404, 'category not found');
675 675
 		}
676 676
 
677
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
677
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
678 678
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
679 679
 		}
680
-		if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) {
680
+		if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
681 681
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
682 682
 		}
683 683
 
684
-		$category->add_type($this->company,'supplier');
684
+		$category->add_type($this->company, 'supplier');
685 685
 
686 686
 		return $this->_cleanObjectDatas($this->company);
687 687
 	}
@@ -698,28 +698,28 @@  discard block
 block discarded – undo
698 698
 	 */
699 699
 	function deleteSupplierCategory($id, $category_id)
700 700
 	{
701
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
701
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
702 702
 			throw new RestException(401);
703 703
 		}
704 704
 
705 705
 		$result = $this->company->fetch($id);
706
-		if( ! $result ) {
706
+		if (!$result) {
707 707
 			throw new RestException(404, 'Thirdparty not found');
708 708
 		}
709 709
 		$category = new Categorie($this->db);
710 710
 		$result = $category->fetch($category_id);
711
-		if( ! $result ) {
711
+		if (!$result) {
712 712
 			throw new RestException(404, 'category not found');
713 713
 		}
714 714
 
715
-		if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
715
+		if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
716 716
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
717 717
 		}
718
-		if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) {
718
+		if (!DolibarrApi::_checkAccessToResource('category', $category->id)) {
719 719
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
720 720
 		}
721 721
 
722
-		$category->del_type($this->company,'supplier');
722
+		$category->del_type($this->company, 'supplier');
723 723
 
724 724
 		return $this->_cleanObjectDatas($this->company);
725 725
 	}
@@ -739,24 +739,24 @@  discard block
 block discarded – undo
739 739
 	 * @throws 401
740 740
 	 * @throws 404
741 741
 	 */
742
-	function getOutStandingProposals($id, $mode='customer')
742
+	function getOutStandingProposals($id, $mode = 'customer')
743 743
 	{
744 744
 		$obj_ret = array();
745 745
 
746
-		if(! DolibarrApiAccess::$user->rights->societe->lire) {
746
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
747 747
 			throw new RestException(401);
748 748
 		}
749 749
 
750
-		if(empty($id)) {
750
+		if (empty($id)) {
751 751
 			throw new RestException(400, 'Thirdparty ID is mandatory');
752 752
 		}
753 753
 
754
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
754
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
755 755
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
756 756
 		}
757 757
 
758 758
 		$result = $this->company->fetch($id);
759
-		if( ! $result ) {
759
+		if (!$result) {
760 760
 			throw new RestException(404, 'Thirdparty not found');
761 761
 		}
762 762
 
@@ -783,24 +783,24 @@  discard block
 block discarded – undo
783 783
 	 * @throws 401
784 784
 	 * @throws 404
785 785
 	 */
786
-	function getOutStandingOrder($id, $mode='customer')
786
+	function getOutStandingOrder($id, $mode = 'customer')
787 787
 	{
788 788
 		$obj_ret = array();
789 789
 
790
-		if(! DolibarrApiAccess::$user->rights->societe->lire) {
790
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
791 791
 			throw new RestException(401);
792 792
 		}
793 793
 
794
-		if(empty($id)) {
794
+		if (empty($id)) {
795 795
 			throw new RestException(400, 'Thirdparty ID is mandatory');
796 796
 		}
797 797
 
798
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
798
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
799 799
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
800 800
 		}
801 801
 
802 802
 		$result = $this->company->fetch($id);
803
-		if( ! $result ) {
803
+		if (!$result) {
804 804
 			throw new RestException(404, 'Thirdparty not found');
805 805
 		}
806 806
 
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
 	 * @throws 401
827 827
 	 * @throws 404
828 828
 	 */
829
-	function getOutStandingInvoices($id, $mode='customer')
829
+	function getOutStandingInvoices($id, $mode = 'customer')
830 830
 	{
831 831
 		$obj_ret = array();
832 832
 
833
-		if(! DolibarrApiAccess::$user->rights->societe->lire) {
833
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
834 834
 			throw new RestException(401);
835 835
 		}
836 836
 
837
-		if(empty($id)) {
837
+		if (empty($id)) {
838 838
 			throw new RestException(400, 'Thirdparty ID is mandatory');
839 839
 		}
840 840
 
841
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
841
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
842 842
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
843 843
 		}
844 844
 
845 845
 		$result = $this->company->fetch($id);
846
-		if( ! $result ) {
846
+		if (!$result) {
847 847
 			throw new RestException(404, 'Thirdparty not found');
848 848
 		}
849 849
 
@@ -872,24 +872,24 @@  discard block
 block discarded – undo
872 872
 	 * @throws 404
873 873
 	 * @throws 503
874 874
 	 */
875
-	function getFixedAmountDiscounts($id, $filter="none", $sortfield = "f.type", $sortorder = 'ASC')
875
+	function getFixedAmountDiscounts($id, $filter = "none", $sortfield = "f.type", $sortorder = 'ASC')
876 876
 	{
877 877
 		$obj_ret = array();
878 878
 
879
-		if(! DolibarrApiAccess::$user->rights->societe->lire) {
879
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
880 880
 			throw new RestException(401);
881 881
 		}
882 882
 
883
-		if(empty($id)) {
883
+		if (empty($id)) {
884 884
 			throw new RestException(400, 'Thirdparty ID is mandatory');
885 885
 		}
886 886
 
887
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
887
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
888 888
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
889 889
 		}
890 890
 
891 891
 		$result = $this->company->fetch($id);
892
-		if( ! $result ) {
892
+		if (!$result) {
893 893
 			throw new RestException(404, 'Thirdparty not found');
894 894
 		}
895 895
 
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 		if ($filter == "available")  $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
901 901
 		if ($filter == "used")  $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
902 902
 
903
-		$sql.= $this->db->order($sortfield, $sortorder);
903
+		$sql .= $this->db->order($sortfield, $sortorder);
904 904
 
905 905
 		$result = $this->db->query($sql);
906
-		if( ! $result ) {
906
+		if (!$result) {
907 907
 			throw new RestException(503, $this->db->lasterror());
908 908
 		} else {
909 909
 			$num = $this->db->num_rows($result);
910
-			while ( $obj = $this->db->fetch_object($result) ) {
910
+			while ($obj = $this->db->fetch_object($result)) {
911 911
 				$obj_ret[] = $obj;
912 912
 			}
913 913
 		}
@@ -932,14 +932,14 @@  discard block
 block discarded – undo
932 932
 	 */
933 933
 	function getInvoicesQualifiedForReplacement($id)
934 934
     {
935
-		if(! DolibarrApiAccess::$user->rights->facture->lire) {
935
+		if (!DolibarrApiAccess::$user->rights->facture->lire) {
936 936
 			throw new RestException(401);
937 937
 		}
938
-		if(empty($id)) {
938
+		if (empty($id)) {
939 939
 			throw new RestException(400, 'Thirdparty ID is mandatory');
940 940
 		}
941 941
 
942
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
942
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
943 943
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
944 944
 		}
945 945
 
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		$invoice = new Facture($this->db);
952 952
 		$result = $invoice->list_replacable_invoices($id);
953
-		if( $result < 0) {
953
+		if ($result < 0) {
954 954
 			throw new RestException(405, $this->thirdparty->error);
955 955
 		}
956 956
 
@@ -974,14 +974,14 @@  discard block
 block discarded – undo
974 974
 	 */
975 975
 	function getInvoicesQualifiedForCreditNote($id)
976 976
     {
977
-		if(! DolibarrApiAccess::$user->rights->facture->lire) {
977
+		if (!DolibarrApiAccess::$user->rights->facture->lire) {
978 978
 			throw new RestException(401);
979 979
 		}
980
-		if(empty($id)) {
980
+		if (empty($id)) {
981 981
 			throw new RestException(400, 'Thirdparty ID is mandatory');
982 982
 		}
983 983
 
984
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
984
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
985 985
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
986 986
 		}
987 987
 
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 
993 993
 		$invoice = new Facture($this->db);
994 994
 		$result = $invoice->list_qualified_avoir_invoices($id);
995
-		if( $result < 0) {
995
+		if ($result < 0) {
996 996
 			throw new RestException(405, $this->thirdparty->error);
997 997
 		}
998 998
 
@@ -1012,14 +1012,14 @@  discard block
 block discarded – undo
1012 1012
     {
1013 1013
 		global $db, $conf;
1014 1014
 
1015
-		if(! DolibarrApiAccess::$user->rights->facture->lire) {
1015
+		if (!DolibarrApiAccess::$user->rights->facture->lire) {
1016 1016
 			throw new RestException(401);
1017 1017
 		}
1018
-		if(empty($id)) {
1018
+		if (empty($id)) {
1019 1019
 			throw new RestException(400, 'Thirdparty ID is mandatory');
1020 1020
 		}
1021 1021
 
1022
-		if( ! DolibarrApi::_checkAccessToResource('societe',$id)) {
1022
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
1023 1023
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
1024 1024
 		}
1025 1025
 
@@ -1028,20 +1028,20 @@  discard block
 block discarded – undo
1028 1028
 		 */
1029 1029
 
1030 1030
 		$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
1031
-		$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
1032
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
1033
-		if ($id) $sql.= " WHERE fk_soc  = ".$id." ";
1031
+		$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
1032
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
1033
+		if ($id) $sql .= " WHERE fk_soc  = ".$id." ";
1034 1034
 
1035 1035
 
1036 1036
 		$result = $db->query($sql);
1037 1037
 
1038
-		if($result->num_rows == 0 ){
1038
+		if ($result->num_rows == 0) {
1039 1039
 			throw new RestException(404, 'Account not found');
1040 1040
 		}
1041 1041
 
1042
-		$i=0;
1042
+		$i = 0;
1043 1043
 
1044
-		$accounts =[];
1044
+		$accounts = [];
1045 1045
 
1046 1046
 		if ($result)
1047 1047
 		{
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 			{
1051 1051
 				$obj = $db->fetch_object($result);
1052 1052
 				$account = new CompanyBankAccount($db);
1053
-				if($account->fetch($obj->rowid)) {
1053
+				if ($account->fetch($obj->rowid)) {
1054 1054
 					$accounts[] = $account;
1055 1055
 				}
1056 1056
 				$i++;
1057 1057
 			}
1058 1058
 		}
1059
-		else{
1059
+		else {
1060 1060
 			throw new RestException(404, 'Account not found');
1061 1061
 		}
1062 1062
 
@@ -1065,10 +1065,10 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
 		$returnAccounts = [];
1067 1067
 
1068
-		foreach($accounts as $account){
1069
-			$object= [];
1070
-			foreach($account as $key => $value)
1071
-				if(in_array($key, $fields)){
1068
+		foreach ($accounts as $account) {
1069
+			$object = [];
1070
+			foreach ($account as $key => $value)
1071
+				if (in_array($key, $fields)) {
1072 1072
 					$object[$key] = $value;
1073 1073
 				}
1074 1074
 			$returnAccounts[] = $object;
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 	 */
1089 1089
 	function createCompanyBankAccount($id, $request_data = null)
1090 1090
 	{
1091
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1091
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1092 1092
 			throw new RestException(401);
1093 1093
 		}
1094 1094
 
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 		$account->socid = $id;
1098 1098
 
1099
-		foreach($request_data as $field => $value) {
1099
+		foreach ($request_data as $field => $value) {
1100 1100
 			$account->$field = $value;
1101 1101
 		}
1102 1102
 
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	 */
1124 1124
 	function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null)
1125 1125
 	{
1126
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1126
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1127 1127
 			throw new RestException(401);
1128 1128
 		}
1129 1129
 
@@ -1131,12 +1131,12 @@  discard block
 block discarded – undo
1131 1131
 
1132 1132
 		$account->fetch($bankaccount_id, $id, -1, '');
1133 1133
 
1134
-		if($account->socid != $id){
1134
+		if ($account->socid != $id) {
1135 1135
 			throw new RestException(401);
1136 1136
 		}
1137 1137
 
1138 1138
 
1139
-		foreach($request_data as $field => $value) {
1139
+		foreach ($request_data as $field => $value) {
1140 1140
 			$account->$field = $value;
1141 1141
 		}
1142 1142
 
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 	 */
1159 1159
 	function deleteCompanyBankAccount($id, $bankaccount_id)
1160 1160
     {
1161
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1161
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1162 1162
 			throw new RestException(401);
1163 1163
 		}
1164 1164
 
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 
1167 1167
 		$account->fetch($bankaccount_id);
1168 1168
 
1169
-		if(!$account->socid == $id)
1169
+		if (!$account->socid == $id)
1170 1170
 			throw new RestException(401);
1171 1171
 
1172 1172
 		return $account->delete(DolibarrApiAccess::$user);
@@ -1186,12 +1186,12 @@  discard block
 block discarded – undo
1186 1186
 	{
1187 1187
 		global $conf;
1188 1188
 
1189
-		$this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals"));
1189
+		$this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals"));
1190 1190
 
1191 1191
 		$this->company->fetch($id);
1192 1192
 
1193 1193
 		$action = 'builddoc';
1194
-		if(! DolibarrApiAccess::$user->rights->societe->creer)
1194
+		if (!DolibarrApiAccess::$user->rights->societe->creer)
1195 1195
 			throw new RestException(401);
1196 1196
 
1197 1197
 		$this->company->setDocModel(DolibarrApiAccess::$user, $model);
@@ -1199,32 +1199,32 @@  discard block
 block discarded – undo
1199 1199
 		$this->company->fk_bank = $this->company->fk_account;
1200 1200
 
1201 1201
 		$outputlangs = $this->langs;
1202
-		$newlang='';
1202
+		$newlang = '';
1203 1203
 
1204
-		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
1205
-		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang;  // for proposal, order, invoice, ...
1206
-		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang;                  // for thirdparty
1207
-		if (! empty($newlang)) {
1208
-			$outputlangs = new Translate("",$conf);
1204
+		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
1205
+		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ...
1206
+		if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty
1207
+		if (!empty($newlang)) {
1208
+			$outputlangs = new Translate("", $conf);
1209 1209
 			$outputlangs->setDefaultLang($newlang);
1210 1210
 		}
1211 1211
 
1212 1212
 		// To be sure vars is defined
1213 1213
 		$hidedetails = $hidedesc = $hideref = 0;
1214
-		$moreparams=null;
1215
-		if (empty($hidedetails)) $hidedetails=0;
1216
-		if (empty($hidedesc)) $hidedesc=0;
1217
-		if (empty($hideref)) $hideref=0;
1218
-		if (empty($moreparams)) $moreparams=null;
1214
+		$moreparams = null;
1215
+		if (empty($hidedetails)) $hidedetails = 0;
1216
+		if (empty($hidedesc)) $hidedesc = 0;
1217
+		if (empty($hideref)) $hideref = 0;
1218
+		if (empty($moreparams)) $moreparams = null;
1219 1219
 
1220 1220
 
1221 1221
 		$sql = "SELECT rowid";
1222
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
1223
-		if ($id) $sql.= " WHERE fk_soc  = ".$id." ";
1224
-		if ($companybankid) $sql.= " AND id = ".$companybankid."";
1222
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
1223
+		if ($id) $sql .= " WHERE fk_soc  = ".$id." ";
1224
+		if ($companybankid) $sql .= " AND id = ".$companybankid."";
1225 1225
 
1226
-		$i=0;
1227
-		$accounts=array();
1226
+		$i = 0;
1227
+		$accounts = array();
1228 1228
 
1229 1229
 		$result = $this->db->query($sql);
1230 1230
 		if ($result)
@@ -1281,15 +1281,15 @@  discard block
 block discarded – undo
1281 1281
 	 *
1282 1282
 	 * @url GET {id}/gateways/
1283 1283
 	 */
1284
-	function getSocieteAccounts($id, $site=null)
1284
+	function getSocieteAccounts($id, $site = null)
1285 1285
     {
1286 1286
 		global $db, $conf;
1287 1287
 
1288
-		if(!DolibarrApiAccess::$user->rights->societe->lire) {
1288
+		if (!DolibarrApiAccess::$user->rights->societe->lire) {
1289 1289
 			throw new RestException(401);
1290 1290
 		}
1291 1291
 
1292
-		if(!DolibarrApi::_checkAccessToResource('societe',$id)) {
1292
+		if (!DolibarrApi::_checkAccessToResource('societe', $id)) {
1293 1293
 			throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
1294 1294
 		}
1295 1295
 
@@ -1297,18 +1297,18 @@  discard block
 block discarded – undo
1297 1297
 		 * We select all the records that match the socid
1298 1298
 		 */
1299 1299
 		$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
1300
-		$sql.= " WHERE fk_soc = $id";
1301
-		if($site) $sql .= " AND site ='$site'";
1300
+		$sql .= " WHERE fk_soc = $id";
1301
+		if ($site) $sql .= " AND site ='$site'";
1302 1302
 
1303 1303
 		$result = $db->query($sql);
1304 1304
 
1305
-		if($result->num_rows == 0){
1305
+		if ($result->num_rows == 0) {
1306 1306
 			throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.');
1307 1307
 		}
1308 1308
 
1309
-		$i=0;
1309
+		$i = 0;
1310 1310
 
1311
-		$accounts =[];
1311
+		$accounts = [];
1312 1312
 
1313 1313
 		$num = $db->num_rows($result);
1314 1314
 		while ($i < $num)
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 			$obj = $db->fetch_object($result);
1317 1317
 			$account = new SocieteAccount($db);
1318 1318
 
1319
-			if($account->fetch($obj->rowid)) {
1319
+			if ($account->fetch($obj->rowid)) {
1320 1320
 				$accounts[] = $account;
1321 1321
 			}
1322 1322
 			$i++;
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
 		$returnAccounts = [];
1328 1328
 
1329
-		foreach($accounts as $account){
1330
-			$object= [];
1331
-			foreach($account as $key => $value)
1332
-				if(in_array($key, $fields)){
1329
+		foreach ($accounts as $account) {
1330
+			$object = [];
1331
+			foreach ($account as $key => $value)
1332
+				if (in_array($key, $fields)) {
1333 1333
 					$object[$key] = $value;
1334 1334
 				}
1335 1335
 			$returnAccounts[] = $object;
@@ -1361,25 +1361,25 @@  discard block
 block discarded – undo
1361 1361
 	{
1362 1362
 		global $db;
1363 1363
 
1364
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1364
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1365 1365
 			throw new RestException(401);
1366 1366
 		}
1367 1367
 
1368
-		if(!isset($request_data['site'])) {
1368
+		if (!isset($request_data['site'])) {
1369 1369
 			throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !');
1370 1370
 		}
1371 1371
 
1372
-		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '". $request_data['site']."' ";
1372
+		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '".$request_data['site']."' ";
1373 1373
 		$result = $db->query($sql);
1374 1374
 
1375
-		if($result->num_rows == 0 ){
1375
+		if ($result->num_rows == 0) {
1376 1376
 			$account = new SocieteAccount($this->db);
1377
-			if(!isset($request_data['login'])) {
1377
+			if (!isset($request_data['login'])) {
1378 1378
 				$account->login = "";
1379 1379
 			}
1380 1380
 			$account->fk_soc = $id;
1381 1381
 
1382
-			foreach($request_data as $field => $value) {
1382
+			foreach ($request_data as $field => $value) {
1383 1383
 				$account->$field = $value;
1384 1384
 			}
1385 1385
 
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 	{
1421 1421
 		global $db;
1422 1422
 
1423
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1423
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1424 1424
 			throw new RestException(401);
1425 1425
 		}
1426 1426
 
@@ -1428,16 +1428,16 @@  discard block
 block discarded – undo
1428 1428
 		$result = $db->query($sql);
1429 1429
 
1430 1430
 		// We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one.
1431
-		if($result->num_rows == 0 ){
1432
-			if(!isset($request_data['key_account'])) {
1431
+		if ($result->num_rows == 0) {
1432
+			if (!isset($request_data['key_account'])) {
1433 1433
 				throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !');
1434 1434
 			}
1435 1435
 			$account = new SocieteAccount($this->db);
1436
-			if(!isset($request_data['login'])) {
1436
+			if (!isset($request_data['login'])) {
1437 1437
 				$account->login = "";
1438 1438
 			}
1439 1439
 
1440
-			foreach($request_data as $field => $value) {
1440
+			foreach ($request_data as $field => $value) {
1441 1441
 				$account->$field = $value;
1442 1442
 			}
1443 1443
 
@@ -1449,12 +1449,12 @@  discard block
 block discarded – undo
1449 1449
 		// We found an existing SocieteAccount entity, we are replacing it
1450 1450
 		} else {
1451 1451
 
1452
-			if(isset($request_data['site']) && $request_data['site'] !== $site) {
1453
-				$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '". $request_data['site']."' ";
1452
+			if (isset($request_data['site']) && $request_data['site'] !== $site) {
1453
+				$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '".$request_data['site']."' ";
1454 1454
 				$result = $db->query($sql);
1455 1455
 
1456
-				if($result->num_rows !== 0)
1457
-					throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key.");
1456
+				if ($result->num_rows !== 0)
1457
+					throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key.");
1458 1458
 			}
1459 1459
 
1460 1460
 			$obj = $db->fetch_object($result);
@@ -1463,13 +1463,13 @@  discard block
 block discarded – undo
1463 1463
 			$account->id = $obj->rowid;
1464 1464
 			$account->fk_soc = $id;
1465 1465
 			$account->site = $site;
1466
-			if(!isset($request_data['login'])) {
1466
+			if (!isset($request_data['login'])) {
1467 1467
 				$account->login = "";
1468 1468
 			}
1469 1469
 			$account->fk_user_creat = $obj->fk_user_creat;
1470 1470
 			$account->date_creation = $obj->date_creation;
1471 1471
 
1472
-			foreach($request_data as $field => $value) {
1472
+			foreach ($request_data as $field => $value) {
1473 1473
 				$account->$field = $value;
1474 1474
 			}
1475 1475
 
@@ -1501,31 +1501,31 @@  discard block
 block discarded – undo
1501 1501
 	{
1502 1502
 		global $db;
1503 1503
 
1504
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1504
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1505 1505
 			throw new RestException(401);
1506 1506
 		}
1507 1507
 
1508 1508
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = $id AND site = '$site' ";
1509 1509
 		$result = $db->query($sql);
1510 1510
 
1511
-		if($result->num_rows == 0 ){
1511
+		if ($result->num_rows == 0) {
1512 1512
 			throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist.");
1513 1513
 		} else {
1514 1514
 
1515 1515
 			// If the user tries to edit the site member, we check first if
1516
-			if(isset($request_data['site']) && $request_data['site'] !== $site) {
1517
-				$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '". $request_data['site']."' ";
1516
+			if (isset($request_data['site']) && $request_data['site'] !== $site) {
1517
+				$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '".$request_data['site']."' ";
1518 1518
 				$result = $db->query($sql);
1519 1519
 
1520
-				if($result->num_rows !== 0)
1521
-					throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key.");
1520
+				if ($result->num_rows !== 0)
1521
+					throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
1522 1522
 			}
1523 1523
 
1524 1524
 			$obj = $db->fetch_object($result);
1525 1525
 			$account = new SocieteAccount($this->db);
1526 1526
 			$account->fetch($obj->rowid);
1527 1527
 
1528
-			foreach($request_data as $field => $value) {
1528
+			foreach ($request_data as $field => $value) {
1529 1529
 				$account->$field = $value;
1530 1530
 			}
1531 1531
 
@@ -1556,21 +1556,21 @@  discard block
 block discarded – undo
1556 1556
 		global /** @var Database $db */
1557 1557
 		$db;
1558 1558
 
1559
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1559
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1560 1560
 			throw new RestException(401);
1561 1561
 		}
1562 1562
 
1563 1563
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = $id AND site = '$site' ";
1564 1564
 		$result = $db->query($sql);
1565 1565
 
1566
-		if($result->num_rows == 0 ){
1566
+		if ($result->num_rows == 0) {
1567 1567
 			throw new RestException(404);
1568 1568
 		} else {
1569 1569
 			$obj = $db->fetch_object($result);
1570 1570
 			$account = new SocieteAccount($this->db);
1571 1571
 			$account->fetch($obj->rowid);
1572 1572
 
1573
-			if($account->delete(DolibarrApiAccess::$user) < 0) {
1573
+			if ($account->delete(DolibarrApiAccess::$user) < 0) {
1574 1574
 				throw new RestException(500, "Error while deleting $site gateway attached to this third party");
1575 1575
 			}
1576 1576
 		}
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 		global /** @var Database $db */
1594 1594
 		$db;
1595 1595
 
1596
-		if(! DolibarrApiAccess::$user->rights->societe->creer) {
1596
+		if (!DolibarrApiAccess::$user->rights->societe->creer) {
1597 1597
 			throw new RestException(401);
1598 1598
 		}
1599 1599
 
@@ -1602,14 +1602,14 @@  discard block
 block discarded – undo
1602 1602
 		 */
1603 1603
 
1604 1604
 		$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms";
1605
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = $id ";
1605
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = $id ";
1606 1606
 
1607 1607
 		$result = $db->query($sql);
1608 1608
 
1609
-		if($result->num_rows == 0 ){
1609
+		if ($result->num_rows == 0) {
1610 1610
 			throw new RestException(404, 'This third party does not have any gateway attached or does not exist.');
1611 1611
 		} else {
1612
-			$i=0;
1612
+			$i = 0;
1613 1613
 
1614 1614
 			$num = $db->num_rows($result);
1615 1615
 			while ($i < $num)
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 				$account = new SocieteAccount($db);
1619 1619
 				$account->fetch($obj->rowid);
1620 1620
 
1621
-				if($account->delete(DolibarrApiAccess::$user) < 0) {
1621
+				if ($account->delete(DolibarrApiAccess::$user) < 0) {
1622 1622
 					throw new RestException(500, 'Error while deleting gateways attached to this third party');
1623 1623
 				}
1624 1624
 				$i++;
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
     {
1637 1637
 		$object = parent::_cleanObjectDatas($object);
1638 1638
 
1639
-		unset($object->nom);	// ->name already defined and nom deprecated
1639
+		unset($object->nom); // ->name already defined and nom deprecated
1640 1640
 
1641 1641
 		unset($object->total_ht);
1642 1642
 		unset($object->total_tva);
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/societecontact.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 
35 35
 $langs->loadLangs(array("orders", "companies"));
36 36
 
37
-$id=GETPOST('id','int')?GETPOST('id','int'):GETPOST('socid','int');
38
-$ref=GETPOST('ref','alpha');
39
-$action=GETPOST('action','alpha');
37
+$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
38
+$ref = GETPOST('ref', 'alpha');
39
+$action = GETPOST('action', 'alpha');
40 40
 
41 41
 // Security check
42
-if ($user->societe_id) $socid=$user->societe_id;
43
-$result = restrictedArea($user, 'societe', $id,'');
42
+if ($user->societe_id) $socid = $user->societe_id;
43
+$result = restrictedArea($user, 'societe', $id, '');
44 44
 
45 45
 $object = new Societe($db);
46 46
 
47 47
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
48
-$hookmanager->initHooks(array('contactthirdparty','globalcard'));
48
+$hookmanager->initHooks(array('contactthirdparty', 'globalcard'));
49 49
 
50 50
 
51 51
 /*
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     if ($result > 0 && $id > 0)
60 60
     {
61
-    	$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
61
+    	$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
62 62
   		$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
63 63
     }
64 64
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 {
87 87
 	if ($object->fetch($id))
88 88
 	{
89
-	    $result=$object->swapContactStatus(GETPOST('ligne'));
89
+	    $result = $object->swapContactStatus(GETPOST('ligne'));
90 90
 	}
91 91
 	else
92 92
 	{
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
  * View
123 123
  */
124 124
 
125
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
126
-llxHeader('',$langs->trans("ThirdParty"),$help_url);
125
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
126
+llxHeader('', $langs->trans("ThirdParty"), $help_url);
127 127
 
128 128
 
129 129
 $form = new Form($db);
130 130
 $formcompany = new FormCompany($db);
131 131
 $formother = new FormOther($db);
132
-$contactstatic=new Contact($db);
133
-$userstatic=new User($db);
132
+$contactstatic = new Contact($db);
133
+$userstatic = new User($db);
134 134
 
135 135
 
136 136
 /* *************************************************************************** */
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 /*                                                                             */
140 140
 /* *************************************************************************** */
141 141
 
142
-if ($id > 0 || ! empty($ref))
142
+if ($id > 0 || !empty($ref))
143 143
 {
144 144
 	if ($object->fetch($id, $ref) > 0)
145 145
 	{
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
156 156
 
157
-        dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
157
+        dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
158 158
 
159 159
     	print '<div class="fichecenter">';
160 160
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     	print yn($object->fournisseur);
172 172
     	print '</td></tr>';*/
173 173
 
174
-		if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
174
+		if (!empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
175 175
 		{
176 176
 		    print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
177 177
 		}
@@ -201,31 +201,31 @@  discard block
 block discarded – undo
201 201
 		print '<br>';
202 202
 
203 203
 		// Contacts lines (modules that overwrite templates must declare this into descriptor)
204
-		$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
205
-		foreach($dirtpls as $reldir)
204
+		$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
205
+		foreach ($dirtpls as $reldir)
206 206
 		{
207
-			$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
207
+			$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
208 208
 			if ($res) break;
209 209
 		}
210 210
 
211 211
 		// additionnal list with adherents of company
212
-		if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire)
212
+		if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire)
213 213
 		{
214 214
 			require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
215 215
 			require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
216 216
 
217
-			$membertypestatic=new AdherentType($db);
218
-			$memberstatic=new Adherent($db);
217
+			$membertypestatic = new AdherentType($db);
218
+			$memberstatic = new Adherent($db);
219 219
 
220 220
 			$langs->load("members");
221 221
 			$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
222
-			$sql.= " d.datefin,";
223
-			$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
224
-			$sql.= " t.libelle as type, t.subscription";
225
-			$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
226
-			$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
227
-			$sql.= " WHERE d.fk_soc = ".$id;
228
-			$sql.= " AND d.fk_adherent_type = t.rowid";
222
+			$sql .= " d.datefin,";
223
+			$sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
224
+			$sql .= " t.libelle as type, t.subscription";
225
+			$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
226
+			$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
227
+			$sql .= " WHERE d.fk_soc = ".$id;
228
+			$sql .= " AND d.fk_adherent_type = t.rowid";
229 229
 
230 230
 			dol_syslog("get list sql=".$sql);
231 231
 			$resql = $db->query($sql);
@@ -233,39 +233,39 @@  discard block
 block discarded – undo
233 233
 			{
234 234
 				$num = $db->num_rows($resql);
235 235
 
236
-				if ($num  > 0 )
236
+				if ($num > 0)
237 237
 				{
238
-					$titre=$langs->trans("MembersListOfTiers");
238
+					$titre = $langs->trans("MembersListOfTiers");
239 239
 					print '<br>';
240 240
 
241
-					print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
241
+					print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
242 242
 
243 243
 					print "<table class=\"noborder\" width=\"100%\">";
244 244
 					print '<tr class="liste_titre">';
245
-					print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder);
246
-					print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
247
-					print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
248
-					print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder);
249
-					print_liste_field_titre("Person",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
250
-					print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
251
-					print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
252
-					print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
245
+					print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", $param, "", "", $sortfield, $sortorder);
246
+					print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"), $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
247
+					print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
248
+					print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "t.libelle", $param, "", "", $sortfield, $sortorder);
249
+					print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
250
+					print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
251
+					print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
252
+					print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
253 253
 					print "</tr>\n";
254 254
 
255
-					$i=0;
255
+					$i = 0;
256 256
 					while ($i < $num && $i < $conf->liste_limit)
257 257
 					{
258 258
 						$objp = $db->fetch_object($resql);
259 259
 
260
-						$datefin=$db->jdate($objp->datefin);
261
-						$memberstatic->id=$objp->rowid;
262
-						$memberstatic->ref=$objp->rowid;
263
-						$memberstatic->lastname=$objp->lastname;
264
-						$memberstatic->firstname=$objp->firstname;
265
-						$memberstatic->statut=$objp->statut;
266
-						$memberstatic->datefin=$db->jdate($objp->datefin);
260
+						$datefin = $db->jdate($objp->datefin);
261
+						$memberstatic->id = $objp->rowid;
262
+						$memberstatic->ref = $objp->rowid;
263
+						$memberstatic->lastname = $objp->lastname;
264
+						$memberstatic->firstname = $objp->firstname;
265
+						$memberstatic->statut = $objp->statut;
266
+						$memberstatic->datefin = $db->jdate($objp->datefin);
267 267
 
268
-						$companyname=$objp->company;
268
+						$companyname = $objp->company;
269 269
 
270 270
 						print '<tr class="oddeven">';
271 271
 
@@ -276,37 +276,37 @@  discard block
 block discarded – undo
276 276
 
277 277
 						// Lastname
278 278
 						print "<td><a href=\"card.php?rowid=$objp->rowid\">";
279
-						print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
280
-						print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : '');
281
-						print (! empty($companyname) ? dol_trunc($companyname, 32) : '');
279
+						print ((!empty($objp->lastname) || !empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
280
+						print (((!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname)) ? ' / ' : '');
281
+						print (!empty($companyname) ? dol_trunc($companyname, 32) : '');
282 282
 						print "</a></td>\n";
283 283
 
284 284
 						// Login
285 285
 						print "<td>".$objp->login."</td>\n";
286 286
 
287 287
 						// Type
288
-						$membertypestatic->id=$objp->type_id;
289
-						$membertypestatic->libelle=$objp->type;
288
+						$membertypestatic->id = $objp->type_id;
289
+						$membertypestatic->libelle = $objp->type;
290 290
 						print '<td class="nowrap">';
291
-						print $membertypestatic->getNomUrl(1,32);
291
+						print $membertypestatic->getNomUrl(1, 32);
292 292
 						print '</td>';
293 293
 
294 294
 						// Moral/Physique
295 295
 						print "<td>".$memberstatic->getmorphylib($objp->morphy)."</td>\n";
296 296
 
297 297
 						// EMail
298
-						print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
298
+						print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
299 299
 
300 300
 						// Statut
301 301
 						print '<td class="nowrap">';
302
-						print $memberstatic->LibStatut($objp->statut,$objp->subscription,$datefin,2);
302
+						print $memberstatic->LibStatut($objp->statut, $objp->subscription, $datefin, 2);
303 303
 						print "</td>";
304 304
 
305 305
 						// End of subscription date
306 306
 						if ($datefin)
307 307
 						{
308 308
 							print '<td align="center" class="nowrap">';
309
-							print dol_print_date($datefin,'day');
309
+							print dol_print_date($datefin, 'day');
310 310
 							if ($memberstatic->hasDelay()) {
311 311
 								print " ".img_warning($langs->trans("SubscriptionLate"));
312 312
 							}
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/project.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 $langs->loadLangs(array("companies", "projects"));
35 35
 
36 36
 // Security check
37
-$socid = GETPOST('socid','int');
38
-if ($user->societe_id) $socid=$user->societe_id;
37
+$socid = GETPOST('socid', 'int');
38
+if ($user->societe_id) $socid = $user->societe_id;
39 39
 $result = restrictedArea($user, 'societe', $socid, '&societe');
40 40
 
41 41
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  *	Actions
47 47
  */
48 48
 
49
-$parameters=array('id'=>$socid);
50
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
49
+$parameters = array('id'=>$socid);
50
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
51 51
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
52 52
 
53 53
 
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	$object = new Societe($db);
72 72
 	$result = $object->fetch($socid);
73 73
 
74
-	$title=$langs->trans("Projects");
75
-	if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
76
-	llxHeader('',$title);
74
+	$title = $langs->trans("Projects");
75
+	if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
76
+	llxHeader('', $title);
77 77
 
78
-	if (! empty($conf->notification->enabled)) $langs->load("mails");
78
+	if (!empty($conf->notification->enabled)) $langs->load("mails");
79 79
 	$head = societe_prepare_head($object);
80 80
 
81 81
 	dol_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
82 82
 
83 83
     $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
84 84
 
85
-    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
85
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
86 86
 
87 87
     print '<div class="fichecenter">';
88 88
 
89 89
     print '<div class="underbanner clearboth"></div>';
90 90
 	print '<table class="border centpercent">';
91 91
 
92
-    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
92
+    if (!empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
93 93
     {
94 94
         print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
95 95
     }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 	// Projects list
146
-	$result=show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $addbutton);
146
+	$result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $addbutton);
147 147
 }
148 148
 
149 149
 // End of page
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/notify/card.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -32,32 +32,32 @@  discard block
 block discarded – undo
32 32
 
33 33
 $langs->loadLangs(array("companies", "mails", "admin", "other"));
34 34
 
35
-$socid = GETPOST("socid",'int');
36
-$action = GETPOST('action','aZ09');
37
-$contactid=GETPOST('contactid');    // May be an int or 'thirdparty'
38
-$actionid=GETPOST('actionid');
35
+$socid = GETPOST("socid", 'int');
36
+$action = GETPOST('action', 'aZ09');
37
+$contactid = GETPOST('contactid'); // May be an int or 'thirdparty'
38
+$actionid = GETPOST('actionid');
39 39
 
40 40
 // Security check
41
-if ($user->societe_id) $socid=$user->societe_id;
42
-$result = restrictedArea($user, 'societe','','');
43
-
44
-$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
45
-$sortfield=GETPOST("sortfield",'alpha');
46
-$sortorder=GETPOST("sortorder",'alpha');
47
-$page=GETPOST("page",'int');
48
-if (! $sortorder) $sortorder="DESC";
49
-if (! $sortfield) $sortfield="n.daten";
41
+if ($user->societe_id) $socid = $user->societe_id;
42
+$result = restrictedArea($user, 'societe', '', '');
43
+
44
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
45
+$sortfield = GETPOST("sortfield", 'alpha');
46
+$sortorder = GETPOST("sortorder", 'alpha');
47
+$page = GETPOST("page", 'int');
48
+if (!$sortorder) $sortorder = "DESC";
49
+if (!$sortfield) $sortfield = "n.daten";
50 50
 if (empty($page) || $page == -1) { $page = 0; }
51 51
 $offset = $limit * $page;
52 52
 $pageprev = $page - 1;
53 53
 $pagenext = $page + 1;
54 54
 
55
-$now=dol_now();
55
+$now = dol_now();
56 56
 
57 57
 $object = new Societe($db);
58 58
 
59 59
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
60
-$hookmanager->initHooks(array('thirdpartynotification','globalcard'));
60
+$hookmanager->initHooks(array('thirdpartynotification', 'globalcard'));
61 61
 
62 62
 
63 63
 
@@ -65,29 +65,29 @@  discard block
 block discarded – undo
65 65
  * Actions
66 66
  */
67 67
 
68
-$parameters=array('id'=>$socid);
69
-$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
68
+$parameters = array('id'=>$socid);
69
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
70 70
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
71 71
 
72 72
 if (empty($reshook))
73 73
 {
74
-    $error=0;
74
+    $error = 0;
75 75
 
76 76
     // Add a notification
77 77
     if ($action == 'add')
78 78
     {
79 79
         if (empty($contactid))
80 80
         {
81
-    	    setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Contact")), null, 'errors');
81
+    	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
82 82
             $error++;
83 83
         }
84 84
         if ($actionid <= 0)
85 85
         {
86
-    	    setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), null, 'errors');
86
+    	    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Action")), null, 'errors');
87 87
             $error++;
88 88
         }
89 89
 
90
-        if (! $error)
90
+        if (!$error)
91 91
         {
92 92
             $db->begin();
93 93
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
99 99
                 $sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
100 100
 
101
-                if (! $db->query($sql))
101
+                if (!$db->query($sql))
102 102
                 {
103 103
                     $error++;
104 104
                     dol_print_error($db);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 dol_print_error($db);
110 110
             }
111 111
 
112
-            if (! $error)
112
+            if (!$error)
113 113
             {
114 114
                 $db->commit();
115 115
             }
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 $form = new Form($db);
138 138
 
139 139
 $object = new Societe($db);
140
-$result=$object->fetch($socid);
140
+$result = $object->fetch($socid);
141 141
 
142
-$title=$langs->trans("ThirdParty").' - '.$langs->trans("Notification");
143
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notification");
144
-$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
145
-llxHeader('',$title,$help_url);
142
+$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notification");
143
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notification");
144
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
145
+llxHeader('', $title, $help_url);
146 146
 
147 147
 
148 148
 if ($result > 0)
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
     $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
157 157
 
158
-    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
158
+    dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom');
159 159
 
160 160
     print '<div class="fichecenter">';
161 161
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     print '<table class="border centpercent">';
164 164
 
165 165
     // Prefix
166
-    if (! empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
166
+    if (!empty($conf->global->SOCIETE_USEPREFIX))  // Old not used prefix field
167 167
     {
168 168
         print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
169 169
     }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         print '</td></tr>';
178 178
     }
179 179
 
180
-    if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire))
180
+    if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire))
181 181
     {
182 182
         print '<tr><td class="titlefield">';
183 183
         print $langs->trans('SupplierCode').'</td><td colspan="3">';
@@ -218,37 +218,37 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
     // Add notification form
221
-    print load_fiche_titre($langs->trans("AddNewNotification"),'','');
221
+    print load_fiche_titre($langs->trans("AddNewNotification"), '', '');
222 222
 
223 223
     print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$socid.'" method="post">';
224 224
     print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
225 225
     print '<input type="hidden" name="action" value="add">';
226 226
 
227
-    $param="&socid=".$socid;
227
+    $param = "&socid=".$socid;
228 228
 
229 229
     // Line with titles
230 230
     print '<table width="100%" class="noborder">';
231 231
     print '<tr class="liste_titre">';
232
-    print_liste_field_titre("Target",$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder);
233
-    print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder);
234
-    print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder);
232
+    print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
233
+    print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
234
+    print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
235 235
     print_liste_field_titre('');
236 236
 	print "</tr>\n";
237 237
 
238
-    $var=false;
239
-    $listofemails=$object->thirdparty_and_contact_email_array();
238
+    $var = false;
239
+    $listofemails = $object->thirdparty_and_contact_email_array();
240 240
     if (count($listofemails) > 0)
241 241
     {
242
-        $actions=array();
242
+        $actions = array();
243 243
 
244 244
         // Load array of available notifications
245
-        $notificationtrigger=new InterfaceNotification($db);
246
-        $listofmanagedeventfornotification=$notificationtrigger->getListOfManagedEvents();
245
+        $notificationtrigger = new InterfaceNotification($db);
246
+        $listofmanagedeventfornotification = $notificationtrigger->getListOfManagedEvents();
247 247
 
248
-        foreach($listofmanagedeventfornotification as $managedeventfornotification)
248
+        foreach ($listofmanagedeventfornotification as $managedeventfornotification)
249 249
         {
250
- 			$label=($langs->trans("Notify_".$managedeventfornotification['code'])!="Notify_".$managedeventfornotification['code']?$langs->trans("Notify_".$managedeventfornotification['code']):$managedeventfornotification['label']);
251
-            $actions[$managedeventfornotification['rowid']]=$label;
250
+ 			$label = ($langs->trans("Notify_".$managedeventfornotification['code']) != "Notify_".$managedeventfornotification['code'] ? $langs->trans("Notify_".$managedeventfornotification['code']) : $managedeventfornotification['label']);
251
+            $actions[$managedeventfornotification['rowid']] = $label;
252 252
         }
253 253
         print '<tr class="oddeven"><td class="maxwidthonsmartphone">';
254 254
         print $form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone');
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
         print $form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone');
258 258
         print '</td>';
259 259
         print '<td>';
260
-        $type=array('email'=>$langs->trans("EMail"));
261
-        print $form->selectarray("typeid",$type);
260
+        $type = array('email'=>$langs->trans("EMail"));
261
+        print $form->selectarray("typeid", $type);
262 262
         print '</td>';
263 263
         print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
264 264
         print '</tr>';
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 
280 280
     // List of notifications enabled for contacts
281 281
     $sql = "SELECT n.rowid, n.type,";
282
-    $sql.= " a.code, a.label,";
283
-    $sql.= " c.rowid as contactid, c.lastname, c.firstname, c.email";
284
-    $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
285
-    $sql.= " ".MAIN_DB_PREFIX."notify_def as n,";
286
-    $sql.= " ".MAIN_DB_PREFIX."socpeople c";
287
-    $sql.= " WHERE a.rowid = n.fk_action";
288
-    $sql.= " AND c.rowid = n.fk_contact";
289
-    $sql.= " AND c.fk_soc = ".$object->id;
290
-
291
-    $resql=$db->query($sql);
282
+    $sql .= " a.code, a.label,";
283
+    $sql .= " c.rowid as contactid, c.lastname, c.firstname, c.email";
284
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
285
+    $sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
286
+    $sql .= " ".MAIN_DB_PREFIX."socpeople c";
287
+    $sql .= " WHERE a.rowid = n.fk_action";
288
+    $sql .= " AND c.rowid = n.fk_contact";
289
+    $sql .= " AND c.fk_soc = ".$object->id;
290
+
291
+    $resql = $db->query($sql);
292 292
     if ($resql)
293 293
     {
294 294
         $num = $db->num_rows($resql);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
     }
300 300
 
301 301
     // List of active notifications
302
-    print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')','','');
302
+    print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')', '', '');
303 303
 
304 304
     // Line with titles
305 305
     print '<table width="100%" class="noborder">';
306 306
     print '<tr class="liste_titre">';
307
-    print_liste_field_titre("Target",$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder);
308
-    print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder);
309
-    print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder);
310
-    print_liste_field_titre('','','');
307
+    print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '"width="45%"', $sortfield, $sortorder);
308
+    print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '"width="35%"', $sortfield, $sortorder);
309
+    print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '"width="10%"', $sortfield, $sortorder);
310
+    print_liste_field_titre('', '', '');
311 311
     print '</tr>';
312 312
 
313 313
 	$langs->load("errors");
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
     {
318 318
         $i = 0;
319 319
 
320
-        $contactstatic=new Contact($db);
320
+        $contactstatic = new Contact($db);
321 321
 
322 322
         while ($i < $num)
323 323
         {
324 324
             $obj = $db->fetch_object($resql);
325 325
 
326
-            $contactstatic->id=$obj->contactid;
327
-            $contactstatic->lastname=$obj->lastname;
328
-            $contactstatic->firstname=$obj->firstname;
326
+            $contactstatic->id = $obj->contactid;
327
+            $contactstatic->lastname = $obj->lastname;
328
+            $contactstatic->firstname = $obj->firstname;
329 329
             print '<tr class="oddeven"><td>'.$contactstatic->getNomUrl(1);
330 330
             if ($obj->type == 'email')
331 331
             {
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
                 else
337 337
                 {
338 338
                     $langs->load("errors");
339
-                    print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail",$obj->email);
339
+                    print ' &nbsp; '.img_warning().' '.$langs->trans("ErrorBadEMail", $obj->email);
340 340
                 }
341 341
             }
342 342
             print '</td>';
343 343
             print '<td>';
344
-            $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
344
+            $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
345 345
             print $label;
346 346
             print '</td>';
347 347
             print '<td>';
@@ -414,14 +414,14 @@  discard block
 block discarded – undo
414 414
 
415 415
     // List
416 416
     $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,";
417
-    $sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
418
-    $sql.= " a.code, a.label";
419
-    $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
420
-    $sql.= " ".MAIN_DB_PREFIX."notify as n ";
421
-    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid";
422
-    $sql.= " WHERE a.rowid = n.fk_action";
423
-    $sql.= " AND n.fk_soc = ".$object->id;
424
-    $sql.= $db->order($sortfield, $sortorder);
417
+    $sql .= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,";
418
+    $sql .= " a.code, a.label";
419
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a,";
420
+    $sql .= " ".MAIN_DB_PREFIX."notify as n ";
421
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid";
422
+    $sql .= " WHERE a.rowid = n.fk_action";
423
+    $sql .= " AND n.fk_soc = ".$object->id;
424
+    $sql .= $db->order($sortfield, $sortorder);
425 425
 
426 426
     // Count total nb of records
427 427
     $nbtotalofrecords = '';
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
         }
437 437
     }
438 438
 
439
-    $sql.= $db->plimit($limit+1, $offset);
439
+    $sql .= $db->plimit($limit + 1, $offset);
440 440
 
441
-    $resql=$db->query($sql);
441
+    $resql = $db->query($sql);
442 442
     if ($resql)
443 443
     {
444 444
         $num = $db->num_rows($resql);
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
         dol_print_error($db);
449 449
     }
450 450
 
451
-    $param='&socid='.$object->id;
452
-    if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
453
-    if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
451
+    $param = '&socid='.$object->id;
452
+    if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
453
+    if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
454 454
 
455 455
     print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
456 456
     if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
     // Line with titles
468 468
     print '<table width="100%" class="noborder">';
469 469
     print '<tr class="liste_titre">';
470
-    print_liste_field_titre("Target",$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'',$sortfield,$sortorder);
471
-    print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder);
472
-    print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"n.type",'',$param,'',$sortfield,$sortorder);
470
+    print_liste_field_titre("Target", $_SERVER["PHP_SELF"], "c.lastname,c.firstname", '', $param, '', $sortfield, $sortorder);
471
+    print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder);
472
+    print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "n.type", '', $param, '', $sortfield, $sortorder);
473 473
     //print_liste_field_titre("Object",$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder);
474
-    print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"n.daten",'',$param,'align="right"',$sortfield,$sortorder);
474
+    print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "n.daten", '', $param, 'align="right"', $sortfield, $sortorder);
475 475
     print '</tr>';
476 476
 
477 477
     if ($num > 0)
478 478
     {
479 479
         $i = 0;
480 480
 
481
-        $contactstatic=new Contact($db);
481
+        $contactstatic = new Contact($db);
482 482
 
483 483
         while ($i < $num)
484 484
         {
@@ -487,11 +487,11 @@  discard block
 block discarded – undo
487 487
             print '<tr class="oddeven"><td>';
488 488
             if ($obj->id > 0)
489 489
             {
490
-	            $contactstatic->id=$obj->id;
491
-	            $contactstatic->lastname=$obj->lastname;
492
-	            $contactstatic->firstname=$obj->firstname;
490
+	            $contactstatic->id = $obj->id;
491
+	            $contactstatic->lastname = $obj->lastname;
492
+	            $contactstatic->firstname = $obj->firstname;
493 493
 	            print $contactstatic->getNomUrl(1);
494
-	            print $obj->email?' &lt;'.$obj->email.'&gt;':$langs->trans("NoMail");
494
+	            print $obj->email ? ' &lt;'.$obj->email.'&gt;' : $langs->trans("NoMail");
495 495
             }
496 496
             else
497 497
 			{
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
             }
500 500
             print '</td>';
501 501
             print '<td>';
502
-            $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
502
+            $label = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
503 503
             print $label;
504 504
             print '</td>';
505 505
             print '<td>';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
     print '</form>';
529 529
 }
530
-else dol_print_error('','RecordNotFound');
530
+else dol_print_error('', 'RecordNotFound');
531 531
 
532 532
 // End of page
533 533
 llxFooter();
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/notify/index.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 
35 35
 if ($sortorder == "")
36 36
 {
37
-  $sortorder="ASC";
37
+  $sortorder = "ASC";
38 38
 }
39 39
 if ($sortfield == "")
40 40
 {
41
-  $sortfield="s.nom";
41
+  $sortfield = "s.nom";
42 42
 }
43 43
 
44
-if ($page == -1 || $page == null) { $page = 0 ; }
44
+if ($page == -1 || $page == null) { $page = 0; }
45 45
 
46
-$offset = $conf->liste_limit * $page ;
46
+$offset = $conf->liste_limit * $page;
47 47
 $pageprev = $page - 1;
48 48
 $pagenext = $page + 1;
49 49
 
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
 llxHeader();
57 57
 
58 58
 $sql = "SELECT s.nom as name, s.rowid as socid, c.lastname, c.firstname, a.label, n.rowid";
59
-$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
60
-$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
61
-$sql.= " ".MAIN_DB_PREFIX."notify_def as n,";
62
-$sql.= " ".MAIN_DB_PREFIX."societe as s";
63
-$sql.= " WHERE n.fk_contact = c.rowid";
64
-$sql.= " AND a.rowid = n.fk_action";
65
-$sql.= " AND n.fk_soc = s.rowid";
66
-$sql.= " AND s.entity IN (".getEntity('societe').")";
67
-if ($socid > 0)	$sql.= " AND s.rowid = " . $user->societe_id;
68
-
69
-$sql.= $db->order($sortfield,$sortorder);
70
-$sql.= $db->plimit($conf->liste_limit, $offset);
59
+$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
60
+$sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
61
+$sql .= " ".MAIN_DB_PREFIX."notify_def as n,";
62
+$sql .= " ".MAIN_DB_PREFIX."societe as s";
63
+$sql .= " WHERE n.fk_contact = c.rowid";
64
+$sql .= " AND a.rowid = n.fk_action";
65
+$sql .= " AND n.fk_soc = s.rowid";
66
+$sql .= " AND s.entity IN (".getEntity('societe').")";
67
+if ($socid > 0)	$sql .= " AND s.rowid = ".$user->societe_id;
68
+
69
+$sql .= $db->order($sortfield, $sortorder);
70
+$sql .= $db->plimit($conf->liste_limit, $offset);
71 71
 
72 72
 $result = $db->query($sql);
73 73
 if ($result)
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	$num = $db->num_rows($result);
76 76
 	$i = 0;
77 77
 
78
-	$paramlist='';
79
-	print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $paramlist, $sortfield,$sortorder,'',$num);
78
+	$paramlist = '';
79
+	print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, $_SERVER["PHP_SELF"], $paramlist, $sortfield, $sortorder, '', $num);
80 80
 
81 81
 	print '<table class="noborder" width="100%">';
82 82
 	print '<tr class="liste_titre">';
83
-	print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom","","",'valign="center"',$sortfield,$sortorder);
84
-	print_liste_field_titre("Contact",$_SERVER["PHP_SELF"],"c.lastname","","",'valign="center"',$sortfield,$sortorder);
85
-	print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"a.titre","","",'valign="center"',$sortfield,$sortorder);
83
+	print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
84
+	print_liste_field_titre("Contact", $_SERVER["PHP_SELF"], "c.lastname", "", "", 'valign="center"', $sortfield, $sortorder);
85
+	print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "a.titre", "", "", 'valign="center"', $sortfield, $sortorder);
86 86
 	print "</tr>\n";
87 87
 
88 88
 	while ($i < $num)
Please login to merge, or discard this patch.