Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/public/donations/donateurs_code.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *		\brief      Page to list donators
22 22
  */
23 23
 
24
-define("NOLOGIN",1);		// This means this output page does not require to be logged.
25
-define("NOCSRFCHECK",1);	// We accept to go on this page from external web site.
24
+define("NOLOGIN", 1); // This means this output page does not require to be logged.
25
+define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
26 26
 
27 27
 // C'est un wrapper, donc header vierge
28 28
 /**
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 function llxFooterVierge() { print '</body></html>'; }
40 40
 
41 41
 require '../../main.inc.php';
42
-require_once DOL_DOCUMENT_ROOT .'/don/class/don.class.php';
42
+require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
43 43
 
44 44
 // Security check
45
-if (empty($conf->don->enabled)) accessforbidden('',0,0,1);
45
+if (empty($conf->don->enabled)) accessforbidden('', 0, 0, 1);
46 46
 
47 47
 
48 48
 $langs->load("donations");
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 llxHeaderVierge();
56 56
 
57 57
 $sql = "SELECT d.datedon as datedon, d.lastname, d.firstname, d.amount, d.public, d.societe";
58
-$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
59
-$sql.= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
58
+$sql .= " FROM ".MAIN_DB_PREFIX."don as d";
59
+$sql .= " WHERE d.fk_statut in (2, 3) ORDER BY d.datedon DESC";
60 60
 
61
-$resql=$db->query($sql);
61
+$resql = $db->query($sql);
62 62
 if ($resql)
63 63
 {
64 64
 	$num = $db->num_rows($resql);
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 		print "<td align=\"right\">".$langs->trans("Amount")."</TD>";
74 74
 		print "</TR>\n";
75 75
 
76
-		$var=True;
77
-		$bc[1]='bgcolor="#f5f5f5"';
78
-		$bc[0]='bgcolor="#f0f0f0"';
76
+		$var = True;
77
+		$bc[1] = 'bgcolor="#f5f5f5"';
78
+		$bc[0] = 'bgcolor="#f0f0f0"';
79 79
 		while ($i < $num)
80 80
 		{
81 81
 			$objp = $db->fetch_object($resql);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				print "<td>Anonyme Anonyme</td>\n";
92 92
 			}
93 93
 			print "<td>".dol_print_date($db->jdate($objp->datedon))."</td>\n";
94
-			print '<td align="right">'.number_format($objp->amount,2,'.',' ').' '.$langs->trans("Currency".$conf->currency).'</td>';
94
+			print '<td align="right">'.number_format($objp->amount, 2, '.', ' ').' '.$langs->trans("Currency".$conf->currency).'</td>';
95 95
 			print "</tr>";
96 96
 			$i++;
97 97
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 require_once DOL_DOCUMENT_ROOT .'/don/class/don.class.php';
43 43
 
44 44
 // Security check
45
-if (empty($conf->don->enabled)) accessforbidden('',0,0,1);
45
+if (empty($conf->don->enabled)) {
46
+	accessforbidden('',0,0,1);
47
+}
46 48
 
47 49
 
48 50
 $langs->load("donations");
@@ -85,8 +87,7 @@  discard block
 block discarded – undo
85 87
 			if ($objp->public)
86 88
 			{
87 89
 				print "<td>".dolGetFirstLastname($objp->firstname, $objp->lastname)." ".$objp->societe."</td>\n";
88
-			}
89
-			else
90
+			} else
90 91
 			{
91 92
 				print "<td>Anonyme Anonyme</td>\n";
92 93
 			}
@@ -97,13 +98,11 @@  discard block
 block discarded – undo
97 98
 		}
98 99
 		print "</table>";
99 100
 
100
-	}
101
-	else
101
+	} else
102 102
 	{
103 103
 		print "Aucun don publique";
104 104
 	}
105
-}
106
-else
105
+} else
107 106
 {
108 107
 	dol_print_error($db);
109 108
 }
Please login to merge, or discard this patch.
htdocs/webservices/server_user.php 3 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 // Enable and test if module web services is enabled
39 39
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
40 40
 {
41
-    $langs->load("admin");
42
-    dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
43
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
44
-    print $langs->trans("ToActivateModule");
45
-    exit;
41
+	$langs->load("admin");
42
+	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
43
+	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
44
+	print $langs->trans("ToActivateModule");
45
+	exit;
46 46
 }
47 47
 
48 48
 // Create the soap Object
@@ -56,70 +56,70 @@  discard block
 block discarded – undo
56 56
 
57 57
 // Define WSDL Authentication object
58 58
 $server->wsdl->addComplexType(
59
-    'authentication',
60
-    'complexType',
61
-    'struct',
62
-    'all',
63
-    '',
64
-    array(
65
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
68
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
69
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
70
-    )
59
+	'authentication',
60
+	'complexType',
61
+	'struct',
62
+	'all',
63
+	'',
64
+	array(
65
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
+		'login' => array('name'=>'login','type'=>'xsd:string'),
68
+		'password' => array('name'=>'password','type'=>'xsd:string'),
69
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
70
+	)
71 71
 );
72 72
 
73 73
 // Define WSDL Return object
74 74
 $server->wsdl->addComplexType(
75
-    'result',
76
-    'complexType',
77
-    'struct',
78
-    'all',
79
-    '',
80
-    array(
81
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
82
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
83
-    )
75
+	'result',
76
+	'complexType',
77
+	'struct',
78
+	'all',
79
+	'',
80
+	array(
81
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
82
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
83
+	)
84 84
 );
85 85
 
86 86
 // Define other specific objects
87 87
 $server->wsdl->addComplexType(
88
-    'user',
89
-    'complexType',
90
-    'struct',
91
-    'all',
92
-    '',
93
-    array(
94
-        'element' => array('name'=>'element','type'=>'xsd:string'),
95
-        'id' => array('name'=>'id','type'=>'xsd:string'),
96
-        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
97
-        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
98
-        'note' => array('name'=>'note','type'=>'xsd:string'),
99
-        'email' => array('name'=>'email','type'=>'xsd:string'),
100
-        'signature' => array('name'=>'signature','type'=>'xsd:string'),
101
-        'office_phone' => array('name'=>'office_phone','type'=>'xsd:string'),
102
-        'office_fax' => array('name'=>'office_fax','type'=>'xsd:string'),
103
-        'user_mobile' => array('name'=>'user_mobile','type'=>'xsd:string'),
104
-        'admin' => array('name'=>'admin','type'=>'xsd:string'),
105
-        'login' => array('name'=>'login','type'=>'xsd:string'),
106
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
107
-        'pass_indatabase' => array('name'=>'pass_indatabase','type'=>'xsd:string'),
108
-        'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted','type'=>'xsd:string'),
109
-        'datec' => array('name'=>'datec','type'=>'xsd:dateTime'),
110
-        'datem' => array('name'=>'datem','type'=>'xsd:dateTime'),
111
-        'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:string'),
112
-        'fk_contact' => array('name'=>'fk_contact','type'=>'xsd:string'),
113
-        'fk_member' => array('name'=>'fk_member','type'=>'xsd:string'),
114
-        'datelastlogin' => array('name'=>'datelastlogin','type'=>'xsd:dateTime'),
115
-        'datepreviouslogin' => array('name'=>'datepreviouslogin','type'=>'xsd:dateTime'),
116
-        'statut' => array('name'=>'statut','type'=>'xsd:string'),
117
-        'photo' => array('name'=>'photo','type'=>'xsd:string'),
118
-        'lang' => array('name'=>'lang','type'=>'xsd:string'),
119
-        'entrepots' => array('name'=>'entrepots','type'=>'xsd:string'),
120
-        //'rights' => array('name'=>'rights','type'=>'xsd:string'),
121
-        'canvas' => array('name'=>'canvas','type'=>'xsd:string')
122
-    )
88
+	'user',
89
+	'complexType',
90
+	'struct',
91
+	'all',
92
+	'',
93
+	array(
94
+		'element' => array('name'=>'element','type'=>'xsd:string'),
95
+		'id' => array('name'=>'id','type'=>'xsd:string'),
96
+		'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
97
+		'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
98
+		'note' => array('name'=>'note','type'=>'xsd:string'),
99
+		'email' => array('name'=>'email','type'=>'xsd:string'),
100
+		'signature' => array('name'=>'signature','type'=>'xsd:string'),
101
+		'office_phone' => array('name'=>'office_phone','type'=>'xsd:string'),
102
+		'office_fax' => array('name'=>'office_fax','type'=>'xsd:string'),
103
+		'user_mobile' => array('name'=>'user_mobile','type'=>'xsd:string'),
104
+		'admin' => array('name'=>'admin','type'=>'xsd:string'),
105
+		'login' => array('name'=>'login','type'=>'xsd:string'),
106
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
107
+		'pass_indatabase' => array('name'=>'pass_indatabase','type'=>'xsd:string'),
108
+		'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted','type'=>'xsd:string'),
109
+		'datec' => array('name'=>'datec','type'=>'xsd:dateTime'),
110
+		'datem' => array('name'=>'datem','type'=>'xsd:dateTime'),
111
+		'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:string'),
112
+		'fk_contact' => array('name'=>'fk_contact','type'=>'xsd:string'),
113
+		'fk_member' => array('name'=>'fk_member','type'=>'xsd:string'),
114
+		'datelastlogin' => array('name'=>'datelastlogin','type'=>'xsd:dateTime'),
115
+		'datepreviouslogin' => array('name'=>'datepreviouslogin','type'=>'xsd:dateTime'),
116
+		'statut' => array('name'=>'statut','type'=>'xsd:string'),
117
+		'photo' => array('name'=>'photo','type'=>'xsd:string'),
118
+		'lang' => array('name'=>'lang','type'=>'xsd:string'),
119
+		'entrepots' => array('name'=>'entrepots','type'=>'xsd:string'),
120
+		//'rights' => array('name'=>'rights','type'=>'xsd:string'),
121
+		'canvas' => array('name'=>'canvas','type'=>'xsd:string')
122
+	)
123 123
 );
124 124
 
125 125
 // Define other specific objects
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
 
238 238
 // Register WSDL
239 239
 $server->register(
240
-    'getUser',
241
-    // Entry values
242
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
243
-    // Exit values
244
-    array('result'=>'tns:result','user'=>'tns:user'),
245
-    $ns,
246
-    $ns.'#getUser',
247
-    $styledoc,
248
-    $styleuse,
249
-    'WS to get user'
240
+	'getUser',
241
+	// Entry values
242
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
243
+	// Exit values
244
+	array('result'=>'tns:result','user'=>'tns:user'),
245
+	$ns,
246
+	$ns.'#getUser',
247
+	$styledoc,
248
+	$styleuse,
249
+	'WS to get user'
250 250
 );
251 251
 
252 252
 $server->register(
@@ -302,41 +302,41 @@  discard block
 block discarded – undo
302 302
  */
303 303
 function getUser($authentication,$id,$ref='',$ref_ext='')
304 304
 {
305
-    global $db,$conf,$langs;
306
-
307
-    dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
308
-
309
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
310
-
311
-    // Init and check authentication
312
-    $objectresp=array();
313
-    $errorcode='';$errorlabel='';
314
-    $error=0;
315
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
316
-    // Check parameters
317
-    if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
318
-    {
319
-        $error++;
320
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
321
-    }
322
-
323
-    if (! $error)
324
-    {
325
-        $fuser->getrights();
326
-
327
-        if ($fuser->rights->user->user->lire
328
-        	|| ($fuser->rights->user->self->creer && $id && $id==$fuser->id)
329
-        	|| ($fuser->rights->user->self->creer && $ref && $ref==$fuser->login)
330
-        	|| ($fuser->rights->user->self->creer && $ref_ext && $ref_ext==$fuser->ref_ext))
331
-        {
332
-            $user=new User($db);
333
-            $result=$user->fetch($id,$ref,$ref_ext);
334
-            if ($result > 0)
335
-            {
336
-                // Create
337
-                $objectresp = array(
338
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
339
-			        'user'=>array(
305
+	global $db,$conf,$langs;
306
+
307
+	dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
308
+
309
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
310
+
311
+	// Init and check authentication
312
+	$objectresp=array();
313
+	$errorcode='';$errorlabel='';
314
+	$error=0;
315
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
316
+	// Check parameters
317
+	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
318
+	{
319
+		$error++;
320
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
321
+	}
322
+
323
+	if (! $error)
324
+	{
325
+		$fuser->getrights();
326
+
327
+		if ($fuser->rights->user->user->lire
328
+			|| ($fuser->rights->user->self->creer && $id && $id==$fuser->id)
329
+			|| ($fuser->rights->user->self->creer && $ref && $ref==$fuser->login)
330
+			|| ($fuser->rights->user->self->creer && $ref_ext && $ref_ext==$fuser->ref_ext))
331
+		{
332
+			$user=new User($db);
333
+			$result=$user->fetch($id,$ref,$ref_ext);
334
+			if ($result > 0)
335
+			{
336
+				// Create
337
+				$objectresp = array(
338
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
339
+					'user'=>array(
340 340
 						'id' => $user->id,
341 341
 						'lastname' => $user->lastname,
342 342
 						'firstname' => $user->firstname,
@@ -363,28 +363,28 @@  discard block
 block discarded – undo
363 363
 						'lang' => $user->lang,
364 364
 						//'rights' => $user->rights,
365 365
 						'canvas' => $user->canvas
366
-                    )
367
-                );
368
-            }
369
-            else
370
-            {
371
-                $error++;
372
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
373
-            }
374
-        }
375
-        else
376
-        {
377
-            $error++;
378
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
379
-        }
380
-    }
381
-
382
-    if ($error)
383
-    {
384
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
385
-    }
386
-
387
-    return $objectresp;
366
+					)
367
+				);
368
+			}
369
+			else
370
+			{
371
+				$error++;
372
+				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
373
+			}
374
+		}
375
+		else
376
+		{
377
+			$error++;
378
+			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
379
+		}
380
+	}
381
+
382
+	if ($error)
383
+	{
384
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
385
+	}
386
+
387
+	return $objectresp;
388 388
 }
389 389
 
390 390
 /**
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
24 24
 
25 25
 require_once '../master.inc.php';
26
-require_once NUSOAP_PATH.'/nusoap.php';		// Include SOAP
26
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
27 27
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
28 28
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 {
41 41
     $langs->load("admin");
42 42
     dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
43
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
43
+    print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
44 44
     print $langs->trans("ToActivateModule");
45 45
     exit;
46 46
 }
47 47
 
48 48
 // Create the soap Object
49 49
 $server = new nusoap_server();
50
-$server->soap_defencoding='UTF-8';
51
-$server->decode_utf8=false;
52
-$ns='http://www.dolibarr.org/ns/';
53
-$server->configureWSDL('WebServicesDolibarrUser',$ns);
54
-$server->wsdl->schemaTargetNamespace=$ns;
50
+$server->soap_defencoding = 'UTF-8';
51
+$server->decode_utf8 = false;
52
+$ns = 'http://www.dolibarr.org/ns/';
53
+$server->configureWSDL('WebServicesDolibarrUser', $ns);
54
+$server->wsdl->schemaTargetNamespace = $ns;
55 55
 
56 56
 
57 57
 // Define WSDL Authentication object
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     'all',
63 63
     '',
64 64
     array(
65
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
68
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
69
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
65
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
66
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
67
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
68
+    	'password' => array('name'=>'password', 'type'=>'xsd:string'),
69
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
70 70
     )
71 71
 );
72 72
 
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
     'all',
79 79
     '',
80 80
     array(
81
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
82
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
81
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
82
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
83 83
     )
84 84
 );
85 85
 
@@ -91,34 +91,34 @@  discard block
 block discarded – undo
91 91
     'all',
92 92
     '',
93 93
     array(
94
-        'element' => array('name'=>'element','type'=>'xsd:string'),
95
-        'id' => array('name'=>'id','type'=>'xsd:string'),
96
-        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
97
-        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
98
-        'note' => array('name'=>'note','type'=>'xsd:string'),
99
-        'email' => array('name'=>'email','type'=>'xsd:string'),
100
-        'signature' => array('name'=>'signature','type'=>'xsd:string'),
101
-        'office_phone' => array('name'=>'office_phone','type'=>'xsd:string'),
102
-        'office_fax' => array('name'=>'office_fax','type'=>'xsd:string'),
103
-        'user_mobile' => array('name'=>'user_mobile','type'=>'xsd:string'),
104
-        'admin' => array('name'=>'admin','type'=>'xsd:string'),
105
-        'login' => array('name'=>'login','type'=>'xsd:string'),
106
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
107
-        'pass_indatabase' => array('name'=>'pass_indatabase','type'=>'xsd:string'),
108
-        'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted','type'=>'xsd:string'),
109
-        'datec' => array('name'=>'datec','type'=>'xsd:dateTime'),
110
-        'datem' => array('name'=>'datem','type'=>'xsd:dateTime'),
111
-        'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:string'),
112
-        'fk_contact' => array('name'=>'fk_contact','type'=>'xsd:string'),
113
-        'fk_member' => array('name'=>'fk_member','type'=>'xsd:string'),
114
-        'datelastlogin' => array('name'=>'datelastlogin','type'=>'xsd:dateTime'),
115
-        'datepreviouslogin' => array('name'=>'datepreviouslogin','type'=>'xsd:dateTime'),
116
-        'statut' => array('name'=>'statut','type'=>'xsd:string'),
117
-        'photo' => array('name'=>'photo','type'=>'xsd:string'),
118
-        'lang' => array('name'=>'lang','type'=>'xsd:string'),
119
-        'entrepots' => array('name'=>'entrepots','type'=>'xsd:string'),
94
+        'element' => array('name'=>'element', 'type'=>'xsd:string'),
95
+        'id' => array('name'=>'id', 'type'=>'xsd:string'),
96
+        'lastname' => array('name'=>'lastname', 'type'=>'xsd:string'),
97
+        'firstname' => array('name'=>'firstname', 'type'=>'xsd:string'),
98
+        'note' => array('name'=>'note', 'type'=>'xsd:string'),
99
+        'email' => array('name'=>'email', 'type'=>'xsd:string'),
100
+        'signature' => array('name'=>'signature', 'type'=>'xsd:string'),
101
+        'office_phone' => array('name'=>'office_phone', 'type'=>'xsd:string'),
102
+        'office_fax' => array('name'=>'office_fax', 'type'=>'xsd:string'),
103
+        'user_mobile' => array('name'=>'user_mobile', 'type'=>'xsd:string'),
104
+        'admin' => array('name'=>'admin', 'type'=>'xsd:string'),
105
+        'login' => array('name'=>'login', 'type'=>'xsd:string'),
106
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
107
+        'pass_indatabase' => array('name'=>'pass_indatabase', 'type'=>'xsd:string'),
108
+        'pass_indatabase_crypted' => array('name'=>'pass_indatabase_crypted', 'type'=>'xsd:string'),
109
+        'datec' => array('name'=>'datec', 'type'=>'xsd:dateTime'),
110
+        'datem' => array('name'=>'datem', 'type'=>'xsd:dateTime'),
111
+        'fk_thirdparty' => array('name'=>'fk_thirdparty', 'type'=>'xsd:string'),
112
+        'fk_contact' => array('name'=>'fk_contact', 'type'=>'xsd:string'),
113
+        'fk_member' => array('name'=>'fk_member', 'type'=>'xsd:string'),
114
+        'datelastlogin' => array('name'=>'datelastlogin', 'type'=>'xsd:dateTime'),
115
+        'datepreviouslogin' => array('name'=>'datepreviouslogin', 'type'=>'xsd:dateTime'),
116
+        'statut' => array('name'=>'statut', 'type'=>'xsd:string'),
117
+        'photo' => array('name'=>'photo', 'type'=>'xsd:string'),
118
+        'lang' => array('name'=>'lang', 'type'=>'xsd:string'),
119
+        'entrepots' => array('name'=>'entrepots', 'type'=>'xsd:string'),
120 120
         //'rights' => array('name'=>'rights','type'=>'xsd:string'),
121
-        'canvas' => array('name'=>'canvas','type'=>'xsd:string')
121
+        'canvas' => array('name'=>'canvas', 'type'=>'xsd:string')
122 122
     )
123 123
 );
124 124
 
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 	'all',
131 131
 	'',
132 132
 	array(
133
-	'name' => array('name'=>'name','type'=>'xsd:string'),
134
-	'id' => array('name'=>'id','type'=>'xsd:string'),
135
-	'datec' => array('name'=>'datec','type'=>'xsd:string'),
136
-	'nb' => array('name'=>'nb','type'=>'xsd:string')
133
+	'name' => array('name'=>'name', 'type'=>'xsd:string'),
134
+	'id' => array('name'=>'id', 'type'=>'xsd:string'),
135
+	'datec' => array('name'=>'datec', 'type'=>'xsd:string'),
136
+	'nb' => array('name'=>'nb', 'type'=>'xsd:string')
137 137
 	)
138 138
 );
139 139
 
@@ -145,61 +145,61 @@  discard block
 block discarded – undo
145 145
 	'SOAP-ENC:Array',
146 146
 	array(),
147 147
 	array(
148
-	array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:group[]')
148
+	array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:group[]')
149 149
 	),
150 150
 	'tns:group'
151 151
 );
152 152
 
153 153
 $thirdpartywithuser_fields = array(
154 154
 	// For thirdparty and contact
155
-	'name' => array('name'=>'name','type'=>'xsd:string'),
156
-	'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
157
-	'name_thirdparty' => array('name'=>'name_thirdparty','type'=>'xsd:string'),
158
-	'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
159
-	'client' => array('name'=>'client','type'=>'xsd:string'),
160
-	'fournisseur' => array('name'=>'fournisseur','type'=>'xsd:string'),
161
-	'address' => array('name'=>'address','type'=>'xsd:string'),
162
-	'zip' => array('name'=>'zip','type'=>'xsd:string'),
163
-	'town' => array('name'=>'town','type'=>'xsd:string'),
164
-	'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
165
-	'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
166
-	'phone' => array('name'=>'phone','type'=>'xsd:string'),
167
-	'phone_mobile' => array('name'=>'phone_mobile','type'=>'xsd:string'),
168
-	'fax' => array('name'=>'fax','type'=>'xsd:string'),
169
-	'email' => array('name'=>'email','type'=>'xsd:string'),
170
-	'url' => array('name'=>'url','type'=>'xsd:string'),
171
-	'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
172
-	'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
173
-	'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
174
-	'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
175
-	'profid5' => array('name'=>'profid5','type'=>'xsd:string'),
176
-	'profid6' => array('name'=>'profid6','type'=>'xsd:string'),
177
-	'capital' => array('name'=>'capital','type'=>'xsd:string'),
178
-	'tva_assuj' => array('name'=>'tva_assuj','type'=>'xsd:string'),
179
-	'tva_intra' => array('name'=>'tva_intra','type'=>'xsd:string'),
155
+	'name' => array('name'=>'name', 'type'=>'xsd:string'),
156
+	'firstname' => array('name'=>'firstname', 'type'=>'xsd:string'),
157
+	'name_thirdparty' => array('name'=>'name_thirdparty', 'type'=>'xsd:string'),
158
+	'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
159
+	'client' => array('name'=>'client', 'type'=>'xsd:string'),
160
+	'fournisseur' => array('name'=>'fournisseur', 'type'=>'xsd:string'),
161
+	'address' => array('name'=>'address', 'type'=>'xsd:string'),
162
+	'zip' => array('name'=>'zip', 'type'=>'xsd:string'),
163
+	'town' => array('name'=>'town', 'type'=>'xsd:string'),
164
+	'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'),
165
+	'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'),
166
+	'phone' => array('name'=>'phone', 'type'=>'xsd:string'),
167
+	'phone_mobile' => array('name'=>'phone_mobile', 'type'=>'xsd:string'),
168
+	'fax' => array('name'=>'fax', 'type'=>'xsd:string'),
169
+	'email' => array('name'=>'email', 'type'=>'xsd:string'),
170
+	'url' => array('name'=>'url', 'type'=>'xsd:string'),
171
+	'profid1' => array('name'=>'profid1', 'type'=>'xsd:string'),
172
+	'profid2' => array('name'=>'profid2', 'type'=>'xsd:string'),
173
+	'profid3' => array('name'=>'profid3', 'type'=>'xsd:string'),
174
+	'profid4' => array('name'=>'profid4', 'type'=>'xsd:string'),
175
+	'profid5' => array('name'=>'profid5', 'type'=>'xsd:string'),
176
+	'profid6' => array('name'=>'profid6', 'type'=>'xsd:string'),
177
+	'capital' => array('name'=>'capital', 'type'=>'xsd:string'),
178
+	'tva_assuj' => array('name'=>'tva_assuj', 'type'=>'xsd:string'),
179
+	'tva_intra' => array('name'=>'tva_intra', 'type'=>'xsd:string'),
180 180
 	// 	For user
181
-	'login' => array('name'=>'login','type'=>'xsd:string'),
182
-	'password' => array('name'=>'password','type'=>'xsd:string'),
183
-	'group_id' => array('name'=>'group_id','type'=>'xsd:string')
181
+	'login' => array('name'=>'login', 'type'=>'xsd:string'),
182
+	'password' => array('name'=>'password', 'type'=>'xsd:string'),
183
+	'group_id' => array('name'=>'group_id', 'type'=>'xsd:string')
184 184
 );
185 185
 
186 186
 //Retreive all extrafield for contact
187 187
 // fetch optionals attributes and labels
188
-$extrafields=new ExtraFields($db);
189
-$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
190
-if (count($extrafields)>0) {
188
+$extrafields = new ExtraFields($db);
189
+$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
190
+if (count($extrafields) > 0) {
191 191
 	$extrafield_array = array();
192 192
 }
193
-foreach($extrafields->attribute_label as $key=>$label)
193
+foreach ($extrafields->attribute_label as $key=>$label)
194 194
 {
195
-	$type =$extrafields->attribute_type[$key];
196
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
197
-	else {$type='xsd:string';}
195
+	$type = $extrafields->attribute_type[$key];
196
+	if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
197
+	else {$type = 'xsd:string'; }
198 198
 
199
-	$extrafield_array['contact_options_'.$key]=array('name'=>'contact_options_'.$key,'type'=>$type);
199
+	$extrafield_array['contact_options_'.$key] = array('name'=>'contact_options_'.$key, 'type'=>$type);
200 200
 }
201 201
 
202
-$thirdpartywithuser_fields=array_merge($thirdpartywithuser_fields,$extrafield_array);
202
+$thirdpartywithuser_fields = array_merge($thirdpartywithuser_fields, $extrafield_array);
203 203
 
204 204
 
205 205
 $server->wsdl->addComplexType(
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	'all',
220 220
 	'',
221 221
 	array(
222
-	'login' => array('name'=>'login','type'=>'xsd:string'),
223
-	'password' => array('name'=>'password','type'=>'xsd:string'),
224
-	'entity' => array('name'=>'entity','type'=>'xsd:string'),
222
+	'login' => array('name'=>'login', 'type'=>'xsd:string'),
223
+	'password' => array('name'=>'password', 'type'=>'xsd:string'),
224
+	'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
225 225
 	)
226 226
 );
227 227
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
231 231
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
232 232
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
233
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
234
-$styleuse='encoded';   // encoded/literal/literal wrapped
233
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
234
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
235 235
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
236 236
 
237 237
 
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 $server->register(
240 240
     'getUser',
241 241
     // Entry values
242
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
242
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
243 243
     // Exit values
244
-    array('result'=>'tns:result','user'=>'tns:user'),
244
+    array('result'=>'tns:result', 'user'=>'tns:user'),
245 245
     $ns,
246 246
     $ns.'#getUser',
247 247
     $styledoc,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	// Entry values
255 255
 	array('authentication'=>'tns:authentication'),
256 256
 	// Exit values
257
-	array('result'=>'tns:result','groups'=>'tns:GroupsArray'),
257
+	array('result'=>'tns:result', 'groups'=>'tns:GroupsArray'),
258 258
 	$ns,
259 259
 	$ns.'#getListOfGroups',
260 260
 	$styledoc,
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 $server->register(
266 266
 	'createUserFromThirdparty',
267 267
 	// Entry values
268
-	array('authentication'=>'tns:authentication','thirdpartywithuser'=>'tns:thirdpartywithuser'),
268
+	array('authentication'=>'tns:authentication', 'thirdpartywithuser'=>'tns:thirdpartywithuser'),
269 269
 	// Exit values
270
-	array('result'=>'tns:result','id'=>'xsd:string'),
270
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
271 271
 	$ns,
272 272
 	$ns.'#createUserFromThirdparty',
273 273
 	$styledoc,
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 $server->register(
279 279
 	'setUserPassword',
280 280
 	// Entry values
281
-	array('authentication'=>'tns:authentication','shortuser'=>'tns:shortuser'),
281
+	array('authentication'=>'tns:authentication', 'shortuser'=>'tns:shortuser'),
282 282
 	// Exit values
283
-	array('result'=>'tns:result','id'=>'xsd:string'),
283
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
284 284
 	$ns,
285 285
 	$ns.'#setUserPassword',
286 286
 	$styledoc,
@@ -300,37 +300,37 @@  discard block
 block discarded – undo
300 300
  * @param	string		$ref_ext			Ref external of object
301 301
  * @return	mixed
302 302
  */
303
-function getUser($authentication,$id,$ref='',$ref_ext='')
303
+function getUser($authentication, $id, $ref = '', $ref_ext = '')
304 304
 {
305
-    global $db,$conf,$langs;
305
+    global $db, $conf, $langs;
306 306
 
307 307
     dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
308 308
 
309
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
309
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
310 310
 
311 311
     // Init and check authentication
312
-    $objectresp=array();
313
-    $errorcode='';$errorlabel='';
314
-    $error=0;
315
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
312
+    $objectresp = array();
313
+    $errorcode = ''; $errorlabel = '';
314
+    $error = 0;
315
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
316 316
     // Check parameters
317
-    if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
317
+    if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
318 318
     {
319 319
         $error++;
320
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
320
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
321 321
     }
322 322
 
323
-    if (! $error)
323
+    if (!$error)
324 324
     {
325 325
         $fuser->getrights();
326 326
 
327 327
         if ($fuser->rights->user->user->lire
328
-        	|| ($fuser->rights->user->self->creer && $id && $id==$fuser->id)
329
-        	|| ($fuser->rights->user->self->creer && $ref && $ref==$fuser->login)
330
-        	|| ($fuser->rights->user->self->creer && $ref_ext && $ref_ext==$fuser->ref_ext))
328
+        	|| ($fuser->rights->user->self->creer && $id && $id == $fuser->id)
329
+        	|| ($fuser->rights->user->self->creer && $ref && $ref == $fuser->login)
330
+        	|| ($fuser->rights->user->self->creer && $ref_ext && $ref_ext == $fuser->ref_ext))
331 331
         {
332
-            $user=new User($db);
333
-            $result=$user->fetch($id,$ref,$ref_ext);
332
+            $user = new User($db);
333
+            $result = $user->fetch($id, $ref, $ref_ext);
334 334
             if ($result > 0)
335 335
             {
336 336
                 // Create
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 						'entity' => $user->entity,
352 352
 						'pass_indatabase' => $user->pass_indatabase,
353 353
 						'pass_indatabase_crypted' => $user->pass_indatabase_crypted,
354
-						'datec' => dol_print_date($user->datec,'dayhourrfc'),
355
-						'datem' => dol_print_date($user->datem,'dayhourrfc'),
354
+						'datec' => dol_print_date($user->datec, 'dayhourrfc'),
355
+						'datem' => dol_print_date($user->datem, 'dayhourrfc'),
356 356
 						'fk_thirdparty' => $user->societe_id,
357 357
 						'fk_contact' => $user->contact_id,
358 358
 						'fk_member' => $user->fk_member,
359
-						'datelastlogin' => dol_print_date($user->datelastlogin,'dayhourrfc'),
360
-						'datepreviouslogin' => dol_print_date($user->datepreviouslogin,'dayhourrfc'),
359
+						'datelastlogin' => dol_print_date($user->datelastlogin, 'dayhourrfc'),
360
+						'datepreviouslogin' => dol_print_date($user->datepreviouslogin, 'dayhourrfc'),
361 361
 						'statut' => $user->statut,
362 362
 						'photo' => $user->photo,
363 363
 						'lang' => $user->lang,
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
             else
370 370
             {
371 371
                 $error++;
372
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
372
+                $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
373 373
             }
374 374
         }
375 375
         else
376 376
         {
377 377
             $error++;
378
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
378
+            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
379 379
         }
380 380
     }
381 381
 
@@ -395,54 +395,54 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function getListOfGroups($authentication)
397 397
 {
398
-	global $db,$conf,$langs;
398
+	global $db, $conf, $langs;
399 399
 
400
-	$now=dol_now();
400
+	$now = dol_now();
401 401
 
402 402
 	dol_syslog("Function: getListOfGroups login=".$authentication['login']);
403 403
 
404
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
404
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
405 405
 
406 406
 	// Init and check authentication
407
-	$objectresp=array();
408
-	$arraygroups=array();
409
-	$errorcode='';$errorlabel='';
410
-	$error=0;
411
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
407
+	$objectresp = array();
408
+	$arraygroups = array();
409
+	$errorcode = ''; $errorlabel = '';
410
+	$error = 0;
411
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
412 412
 	// Check parameters
413 413
 
414
-	if (! $error)
414
+	if (!$error)
415 415
 	{
416 416
 		$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
417
-		$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
418
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
419
-		if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
417
+		$sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
418
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
419
+		if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity)))
420 420
 		{
421
-			$sql.= " WHERE g.entity IS NOT NULL";
421
+			$sql .= " WHERE g.entity IS NOT NULL";
422 422
 		}
423 423
 		else
424 424
 		{
425
-			$sql.= " WHERE g.entity IN (0,".$conf->entity.")";
425
+			$sql .= " WHERE g.entity IN (0,".$conf->entity.")";
426 426
 		}
427
-		$sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
428
-		$resql=$db->query($sql);
427
+		$sql .= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
428
+		$resql = $db->query($sql);
429 429
 		if ($resql)
430 430
 		{
431
-			$num=$db->num_rows($resql);
431
+			$num = $db->num_rows($resql);
432 432
 
433
-			$i=0;
433
+			$i = 0;
434 434
 			while ($i < $num)
435 435
 			{
436
-				$obj=$db->fetch_object($resql);
437
-				$arraygroups[]=array('id'=>$obj->rowid,'name'=>$obj->name,'datec'=>$obj->datec,'nb'=>$obj->nb);
436
+				$obj = $db->fetch_object($resql);
437
+				$arraygroups[] = array('id'=>$obj->rowid, 'name'=>$obj->name, 'datec'=>$obj->datec, 'nb'=>$obj->nb);
438 438
 				$i++;
439 439
 			}
440 440
 		}
441 441
 		else
442 442
 		{
443 443
 			$error++;
444
-			$errorcode=$db->lasterrno();
445
-			$errorlabel=$db->lasterror();
444
+			$errorcode = $db->lasterrno();
445
+			$errorlabel = $db->lasterror();
446 446
 		}
447 447
 	}
448 448
 
@@ -472,43 +472,43 @@  discard block
 block discarded – undo
472 472
  * @param	array		$thirdpartywithuser Datas
473 473
  * @return	mixed
474 474
  */
475
-function createUserFromThirdparty($authentication,$thirdpartywithuser)
475
+function createUserFromThirdparty($authentication, $thirdpartywithuser)
476 476
 {
477
-	global $db,$conf,$langs;
477
+	global $db, $conf, $langs;
478 478
 
479 479
 	dol_syslog("Function: createUserFromThirdparty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
480 480
 
481
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
481
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
482 482
 
483
-	$objectresp=array();
484
-	$errorcode='';$errorlabel='';
485
-	$error=0;
483
+	$objectresp = array();
484
+	$errorcode = ''; $errorlabel = '';
485
+	$error = 0;
486 486
 
487
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
487
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
488 488
 
489
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
489
+	if ($fuser->societe_id) $socid = $fuser->societe_id;
490 490
 
491
-	if (! $error && ! $thirdpartywithuser)
491
+	if (!$error && !$thirdpartywithuser)
492 492
 	{
493 493
 		$error++;
494
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter thirdparty must be provided.";
494
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter thirdparty must be provided.";
495 495
 	}
496 496
 
497
-	if (! $error)
497
+	if (!$error)
498 498
 	{
499 499
 		$fuser->getrights();
500 500
 
501 501
 		if ($fuser->rights->societe->creer)
502 502
 		{
503
-			$thirdparty=new Societe($db);
503
+			$thirdparty = new Societe($db);
504 504
 
505 505
 			// If a contact / company already exists with the email, return the corresponding socid
506 506
 			$sql = "SELECT s.rowid as societe_id FROM ".MAIN_DB_PREFIX."societe as s";
507
-			$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
508
-			$sql.= " WHERE s.entity=".$conf->entity;
509
-			$sql.= " AND s.email='".$db->escape($thirdpartywithuser['email'])."'";
510
-			$sql.= " OR sp.email='".$db->escape($thirdpartywithuser['email'])."'";
511
-			$sql.= $db->plimit(1);
507
+			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
508
+			$sql .= " WHERE s.entity=".$conf->entity;
509
+			$sql .= " AND s.email='".$db->escape($thirdpartywithuser['email'])."'";
510
+			$sql .= " OR sp.email='".$db->escape($thirdpartywithuser['email'])."'";
511
+			$sql .= $db->plimit(1);
512 512
 
513 513
 			$resql = $db->query($sql);
514 514
 			if ($resql)
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 				if ($row)
519 519
 				{
520 520
 					$error++;
521
-					$errorcode='ALREADY_EXIST'; $errorlabel='Object not create : company or contact exists '.$thirdpartywithuser['email'];
521
+					$errorcode = 'ALREADY_EXIST'; $errorlabel = 'Object not create : company or contact exists '.$thirdpartywithuser['email'];
522 522
 				}
523 523
 				else
524 524
 				{
@@ -526,48 +526,48 @@  discard block
 block discarded – undo
526 526
 					/*
527 527
 					 * Company creation
528 528
 					 */
529
-					$thirdparty->name=$thirdpartywithuser['name_thirdparty'];
530
-					$thirdparty->ref_ext=$thirdpartywithuser['ref_ext'];
531
-					$thirdparty->address=$thirdpartywithuser['address'];
532
-					$thirdparty->zip=$thirdpartywithuser['zip'];
533
-					$thirdparty->town=$thirdpartywithuser['town'];
534
-					$thirdparty->country_id=$thirdpartywithuser['country_id'];
535
-					$thirdparty->country_code=$thirdpartywithuser['country_code'];
529
+					$thirdparty->name = $thirdpartywithuser['name_thirdparty'];
530
+					$thirdparty->ref_ext = $thirdpartywithuser['ref_ext'];
531
+					$thirdparty->address = $thirdpartywithuser['address'];
532
+					$thirdparty->zip = $thirdpartywithuser['zip'];
533
+					$thirdparty->town = $thirdpartywithuser['town'];
534
+					$thirdparty->country_id = $thirdpartywithuser['country_id'];
535
+					$thirdparty->country_code = $thirdpartywithuser['country_code'];
536 536
 
537 537
 					// find the country id by code
538 538
 					$langs->load("dict");
539 539
 
540 540
 					$sql = "SELECT rowid";
541
-					$sql.= " FROM ".MAIN_DB_PREFIX."c_country";
542
-					$sql.= " WHERE active = 1";
543
-					$sql.= " AND code='".$thirdparty->country_code."'";
541
+					$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
542
+					$sql .= " WHERE active = 1";
543
+					$sql .= " AND code='".$thirdparty->country_code."'";
544 544
 
545
-					$resql=$db->query($sql);
545
+					$resql = $db->query($sql);
546 546
 					if ($resql)
547 547
 					{
548 548
 						$num = $db->num_rows($resql);
549 549
 						if ($num)
550 550
 						{
551 551
 							$obj = $db->fetch_object($resql);
552
-							$thirdparty->country_id      = $obj->rowid;
552
+							$thirdparty->country_id = $obj->rowid;
553 553
 						}
554 554
 					}
555
-					$thirdparty->phone=$thirdpartywithuser['phone'];
556
-					$thirdparty->fax=$thirdpartywithuser['fax'];
557
-					$thirdparty->email=$thirdpartywithuser['email'];
558
-					$thirdparty->url=$thirdpartywithuser['url'];
559
-					$thirdparty->ape=$thirdpartywithuser['ape'];
560
-					$thirdparty->idprof1=$thirdpartywithuser['prof1'];
561
-					$thirdparty->idprof2=$thirdpartywithuser['prof2'];
562
-					$thirdparty->idprof3=$thirdpartywithuser['prof3'];
563
-					$thirdparty->idprof4=$thirdpartywithuser['prof4'];
564
-					$thirdparty->idprof5=$thirdpartywithuser['prof5'];
565
-					$thirdparty->idprof6=$thirdpartywithuser['prof6'];
566
-
567
-					$thirdparty->client=$thirdpartywithuser['client'];
568
-					$thirdparty->fournisseur=$thirdpartywithuser['fournisseur'];
569
-
570
-					$socid_return=$thirdparty->create($fuser);
555
+					$thirdparty->phone = $thirdpartywithuser['phone'];
556
+					$thirdparty->fax = $thirdpartywithuser['fax'];
557
+					$thirdparty->email = $thirdpartywithuser['email'];
558
+					$thirdparty->url = $thirdpartywithuser['url'];
559
+					$thirdparty->ape = $thirdpartywithuser['ape'];
560
+					$thirdparty->idprof1 = $thirdpartywithuser['prof1'];
561
+					$thirdparty->idprof2 = $thirdpartywithuser['prof2'];
562
+					$thirdparty->idprof3 = $thirdpartywithuser['prof3'];
563
+					$thirdparty->idprof4 = $thirdpartywithuser['prof4'];
564
+					$thirdparty->idprof5 = $thirdpartywithuser['prof5'];
565
+					$thirdparty->idprof6 = $thirdpartywithuser['prof6'];
566
+
567
+					$thirdparty->client = $thirdpartywithuser['client'];
568
+					$thirdparty->fournisseur = $thirdpartywithuser['fournisseur'];
569
+
570
+					$socid_return = $thirdparty->create($fuser);
571 571
 
572 572
 					if ($socid_return > 0)
573 573
 					{
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
 
596 596
 						//Retreive all extrafield for thirdsparty
597 597
 						// fetch optionals attributes and labels
598
-						$extrafields=new ExtraFields($db);
599
-						$extralabels=$extrafields->fetch_name_optionals_label('socpeople',true);
600
-						foreach($extrafields->attribute_label as $key=>$label)
598
+						$extrafields = new ExtraFields($db);
599
+						$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
600
+						foreach ($extrafields->attribute_label as $key=>$label)
601 601
 						{
602
-							$key='contact_options_'.$key;
603
-							$key=substr($key,8);   // Remove 'contact_' prefix
604
-							$contact->array_options[$key]=$thirdpartywithuser[$key];
602
+							$key = 'contact_options_'.$key;
603
+							$key = substr($key, 8); // Remove 'contact_' prefix
604
+							$contact->array_options[$key] = $thirdpartywithuser[$key];
605 605
 						}
606 606
 
607
-						$contact_id =  $contact->create($fuser);
607
+						$contact_id = $contact->create($fuser);
608 608
 
609 609
 						if ($contact_id > 0)
610 610
 						{
@@ -614,36 +614,36 @@  discard block
 block discarded – undo
614 614
 							*/
615 615
 							$edituser = new User($db);
616 616
 
617
-							$id = $edituser->create_from_contact($contact,$thirdpartywithuser["login"]);
617
+							$id = $edituser->create_from_contact($contact, $thirdpartywithuser["login"]);
618 618
 							if ($id > 0)
619 619
 							{
620
-								$edituser->setPassword($fuser,trim($thirdpartywithuser['password']));
620
+								$edituser->setPassword($fuser, trim($thirdpartywithuser['password']));
621 621
 
622
-								if($thirdpartywithuser['group_id'] > 0 )
623
-									$edituser->SetInGroup($thirdpartywithuser['group_id'],$conf->entity);
622
+								if ($thirdpartywithuser['group_id'] > 0)
623
+									$edituser->SetInGroup($thirdpartywithuser['group_id'], $conf->entity);
624 624
 							}
625 625
 							else
626 626
 							{
627 627
 								$error++;
628
-								$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$edituser->error;
628
+								$errorcode = 'NOT_CREATE'; $errorlabel = 'Object not create : '.$edituser->error;
629 629
 							}
630 630
 						}
631 631
 						else
632 632
 						{
633 633
 							$error++;
634
-							$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$contact->error;
634
+							$errorcode = 'NOT_CREATE'; $errorlabel = 'Object not create : '.$contact->error;
635 635
 						}
636 636
 
637
-						if(!$error) {
637
+						if (!$error) {
638 638
 							$db->commit();
639
-							$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'),'id'=>$socid_return);
640
-							$error=0;
639
+							$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'), 'id'=>$socid_return);
640
+							$error = 0;
641 641
 						}
642 642
 					}
643 643
 					else
644 644
 					{
645 645
 						$error++;
646
-						$errors=($thirdparty->error?array($thirdparty->error):$thirdparty->errors);
646
+						$errors = ($thirdparty->error ? array($thirdparty->error) : $thirdparty->errors);
647 647
 					}
648 648
 				}
649 649
 			}
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 			{
652 652
 				// retour creation KO
653 653
 				$error++;
654
-				$errorcode='NOT_CREATE'; $errorlabel='Object not create';
654
+				$errorcode = 'NOT_CREATE'; $errorlabel = 'Object not create';
655 655
 			}
656 656
 		}
657 657
 		else
658 658
 		{
659 659
 			$error++;
660
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
660
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
661 661
 		}
662 662
 	}
663 663
 
@@ -680,40 +680,40 @@  discard block
 block discarded – undo
680 680
  * @param	array		$shortuser			Array of login/password info
681 681
  * @return	mixed
682 682
  */
683
-function setUserPassword($authentication,$shortuser) {
683
+function setUserPassword($authentication, $shortuser) {
684 684
 
685
-	global $db,$conf,$langs;
685
+	global $db, $conf, $langs;
686 686
 
687 687
 	dol_syslog("Function: setUserPassword login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
688 688
 
689
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
689
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
690 690
 
691
-	$objectresp=array();
692
-	$errorcode='';$errorlabel='';
693
-	$error=0;
691
+	$objectresp = array();
692
+	$errorcode = ''; $errorlabel = '';
693
+	$error = 0;
694 694
 
695
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
695
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
696 696
 
697
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
697
+	if ($fuser->societe_id) $socid = $fuser->societe_id;
698 698
 
699
-	if (! $error && ! $shortuser)
699
+	if (!$error && !$shortuser)
700 700
 	{
701 701
 		$error++;
702
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter shortuser must be provided.";
702
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter shortuser must be provided.";
703 703
 	}
704 704
 
705
-	if (! $error)
705
+	if (!$error)
706 706
 	{
707 707
 		$fuser->getrights();
708 708
 
709 709
 		if ($fuser->rights->user->user->password || $fuser->rights->user->self->password)
710 710
 		{
711
-			$userstat=new User($db);
712
-			$res = $userstat->fetch('',$shortuser['login']);
713
-			if($res)
711
+			$userstat = new User($db);
712
+			$res = $userstat->fetch('', $shortuser['login']);
713
+			if ($res)
714 714
 			{
715
-				$res = $userstat->setPassword($userstat,$shortuser['password']);
716
-				if($res)
715
+				$res = $userstat->setPassword($userstat, $shortuser['password']);
716
+				if ($res)
717 717
 				{
718 718
 					$objectresp = array(
719 719
 						'result'=>array('result_code' => 'OK', 'result_label' => ''),
@@ -723,20 +723,20 @@  discard block
 block discarded – undo
723 723
 				else
724 724
 				{
725 725
 					$error++;
726
-					$errorcode='NOT_MODIFIED'; $errorlabel='Error when changing password';
726
+					$errorcode = 'NOT_MODIFIED'; $errorlabel = 'Error when changing password';
727 727
 				}
728 728
 			}
729 729
 			else
730 730
 			{
731 731
 				$error++;
732
-				$errorcode='NOT_FOUND'; $errorlabel='User not found';
732
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'User not found';
733 733
 			}
734 734
 
735 735
 		}
736 736
 		else
737 737
 		{
738 738
 			$error++;
739
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
739
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
740 740
 		}
741 741
 	}
742 742
 
Please login to merge, or discard this patch.
Braces   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (! defined("NOCSRFCHECK")) {
24
+	define("NOCSRFCHECK",'1');
25
+}
24 26
 
25 27
 require_once '../master.inc.php';
26 28
 require_once NUSOAP_PATH.'/nusoap.php';		// Include SOAP
@@ -193,8 +195,7 @@  discard block
 block discarded – undo
193 195
 foreach($extrafields->attribute_label as $key=>$label)
194 196
 {
195 197
 	$type =$extrafields->attribute_type[$key];
196
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
197
-	else {$type='xsd:string';}
198
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
198 199
 
199 200
 	$extrafield_array['contact_options_'.$key]=array('name'=>'contact_options_'.$key,'type'=>$type);
200 201
 }
@@ -306,7 +307,9 @@  discard block
 block discarded – undo
306 307
 
307 308
     dol_syslog("Function: getUser login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
308 309
 
309
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
310
+    if ($authentication['entity']) {
311
+    	$conf->entity=$authentication['entity'];
312
+    }
310 313
 
311 314
     // Init and check authentication
312 315
     $objectresp=array();
@@ -365,14 +368,12 @@  discard block
 block discarded – undo
365 368
 						'canvas' => $user->canvas
366 369
                     )
367 370
                 );
368
-            }
369
-            else
371
+            } else
370 372
             {
371 373
                 $error++;
372 374
                 $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
373 375
             }
374
-        }
375
-        else
376
+        } else
376 377
         {
377 378
             $error++;
378 379
             $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -401,7 +402,9 @@  discard block
 block discarded – undo
401 402
 
402 403
 	dol_syslog("Function: getListOfGroups login=".$authentication['login']);
403 404
 
404
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
405
+	if ($authentication['entity']) {
406
+		$conf->entity=$authentication['entity'];
407
+	}
405 408
 
406 409
 	// Init and check authentication
407 410
 	$objectresp=array();
@@ -419,8 +422,7 @@  discard block
 block discarded – undo
419 422
 		if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
420 423
 		{
421 424
 			$sql.= " WHERE g.entity IS NOT NULL";
422
-		}
423
-		else
425
+		} else
424 426
 		{
425 427
 			$sql.= " WHERE g.entity IN (0,".$conf->entity.")";
426 428
 		}
@@ -437,8 +439,7 @@  discard block
 block discarded – undo
437 439
 				$arraygroups[]=array('id'=>$obj->rowid,'name'=>$obj->name,'datec'=>$obj->datec,'nb'=>$obj->nb);
438 440
 				$i++;
439 441
 			}
440
-		}
441
-		else
442
+		} else
442 443
 		{
443 444
 			$error++;
444 445
 			$errorcode=$db->lasterrno();
@@ -452,8 +453,7 @@  discard block
 block discarded – undo
452 453
 		'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
453 454
 		'groups'=>$arraygroups
454 455
 		);
455
-	}
456
-	else
456
+	} else
457 457
 	{
458 458
 		$objectresp = array(
459 459
 		'result'=>array('result_code' => 'OK', 'result_label' => ''),
@@ -478,7 +478,9 @@  discard block
 block discarded – undo
478 478
 
479 479
 	dol_syslog("Function: createUserFromThirdparty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
480 480
 
481
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
481
+	if ($authentication['entity']) {
482
+		$conf->entity=$authentication['entity'];
483
+	}
482 484
 
483 485
 	$objectresp=array();
484 486
 	$errorcode='';$errorlabel='';
@@ -486,7 +488,9 @@  discard block
 block discarded – undo
486 488
 
487 489
 	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
488 490
 
489
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
491
+	if ($fuser->societe_id) {
492
+		$socid=$fuser->societe_id;
493
+	}
490 494
 
491 495
 	if (! $error && ! $thirdpartywithuser)
492 496
 	{
@@ -519,8 +523,7 @@  discard block
 block discarded – undo
519 523
 				{
520 524
 					$error++;
521 525
 					$errorcode='ALREADY_EXIST'; $errorlabel='Object not create : company or contact exists '.$thirdpartywithuser['email'];
522
-				}
523
-				else
526
+				} else
524 527
 				{
525 528
 					$db->begin();
526 529
 					/*
@@ -619,16 +622,15 @@  discard block
 block discarded – undo
619 622
 							{
620 623
 								$edituser->setPassword($fuser,trim($thirdpartywithuser['password']));
621 624
 
622
-								if($thirdpartywithuser['group_id'] > 0 )
623
-									$edituser->SetInGroup($thirdpartywithuser['group_id'],$conf->entity);
624
-							}
625
-							else
625
+								if($thirdpartywithuser['group_id'] > 0 ) {
626
+																	$edituser->SetInGroup($thirdpartywithuser['group_id'],$conf->entity);
627
+								}
628
+							} else
626 629
 							{
627 630
 								$error++;
628 631
 								$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$edituser->error;
629 632
 							}
630
-						}
631
-						else
633
+						} else
632 634
 						{
633 635
 							$error++;
634 636
 							$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$contact->error;
@@ -639,22 +641,19 @@  discard block
 block discarded – undo
639 641
 							$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'),'id'=>$socid_return);
640 642
 							$error=0;
641 643
 						}
642
-					}
643
-					else
644
+					} else
644 645
 					{
645 646
 						$error++;
646 647
 						$errors=($thirdparty->error?array($thirdparty->error):$thirdparty->errors);
647 648
 					}
648 649
 				}
649
-			}
650
-			else
650
+			} else
651 651
 			{
652 652
 				// retour creation KO
653 653
 				$error++;
654 654
 				$errorcode='NOT_CREATE'; $errorlabel='Object not create';
655 655
 			}
656
-		}
657
-		else
656
+		} else
658 657
 		{
659 658
 			$error++;
660 659
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -686,7 +685,9 @@  discard block
 block discarded – undo
686 685
 
687 686
 	dol_syslog("Function: setUserPassword login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
688 687
 
689
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
688
+	if ($authentication['entity']) {
689
+		$conf->entity=$authentication['entity'];
690
+	}
690 691
 
691 692
 	$objectresp=array();
692 693
 	$errorcode='';$errorlabel='';
@@ -694,7 +695,9 @@  discard block
 block discarded – undo
694 695
 
695 696
 	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
696 697
 
697
-	if ($fuser->societe_id) $socid=$fuser->societe_id;
698
+	if ($fuser->societe_id) {
699
+		$socid=$fuser->societe_id;
700
+	}
698 701
 
699 702
 	if (! $error && ! $shortuser)
700 703
 	{
@@ -719,21 +722,18 @@  discard block
 block discarded – undo
719 722
 						'result'=>array('result_code' => 'OK', 'result_label' => ''),
720 723
 						'groups'=>$arraygroups
721 724
 					);
722
-				}
723
-				else
725
+				} else
724 726
 				{
725 727
 					$error++;
726 728
 					$errorcode='NOT_MODIFIED'; $errorlabel='Error when changing password';
727 729
 				}
728
-			}
729
-			else
730
+			} else
730 731
 			{
731 732
 				$error++;
732 733
 				$errorcode='NOT_FOUND'; $errorlabel='User not found';
733 734
 			}
734 735
 
735
-		}
736
-		else
736
+		} else
737 737
 		{
738 738
 			$error++;
739 739
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
Please login to merge, or discard this patch.
htdocs/webservices/server_invoice.php 3 patches
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -58,57 +58,57 @@  discard block
 block discarded – undo
58 58
 
59 59
 // Define WSDL Authentication object
60 60
 $server->wsdl->addComplexType(
61
-    'authentication',
62
-    'complexType',
63
-    'struct',
64
-    'all',
65
-    '',
66
-    array(
67
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
68
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
69
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
70
-        'password' => array('name'=>'password','type'=>'xsd:string'),
71
-        'entity' => array('name'=>'entity','type'=>'xsd:string')
72
-    )
61
+	'authentication',
62
+	'complexType',
63
+	'struct',
64
+	'all',
65
+	'',
66
+	array(
67
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
68
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
69
+		'login' => array('name'=>'login','type'=>'xsd:string'),
70
+		'password' => array('name'=>'password','type'=>'xsd:string'),
71
+		'entity' => array('name'=>'entity','type'=>'xsd:string')
72
+	)
73 73
 );
74 74
 // Define WSDL Return object
75 75
 $server->wsdl->addComplexType(
76
-    'result',
77
-    'complexType',
78
-    'struct',
79
-    'all',
80
-    '',
81
-    array(
82
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
84
-    )
76
+	'result',
77
+	'complexType',
78
+	'struct',
79
+	'all',
80
+	'',
81
+	array(
82
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
84
+	)
85 85
 );
86 86
 
87 87
 // Define other specific objects
88 88
 $server->wsdl->addComplexType(
89
-    'line',
90
-    'complexType',
91
-    'struct',
92
-    'all',
93
-    '',
94
-    array(
95
-        'id' => array('name'=>'id','type'=>'xsd:string'),
96
-        'type' => array('name'=>'type','type'=>'xsd:int'),
97
-        'desc' => array('name'=>'desc','type'=>'xsd:string'),
98
-        'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
99
-        'qty' => array('name'=>'qty','type'=>'xsd:double'),
100
-        'unitprice' => array('name'=>'unitprice','type'=>'xsd:double'),
101
-        'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
102
-    	'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
103
-    	'total' => array('name'=>'total','type'=>'xsd:double'),
104
-        'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
105
-        'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
106
-        // From product
107
-        'product_id' => array('name'=>'product_id','type'=>'xsd:int'),
108
-        'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
109
-        'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
110
-        'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
111
-    )
89
+	'line',
90
+	'complexType',
91
+	'struct',
92
+	'all',
93
+	'',
94
+	array(
95
+		'id' => array('name'=>'id','type'=>'xsd:string'),
96
+		'type' => array('name'=>'type','type'=>'xsd:int'),
97
+		'desc' => array('name'=>'desc','type'=>'xsd:string'),
98
+		'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
99
+		'qty' => array('name'=>'qty','type'=>'xsd:double'),
100
+		'unitprice' => array('name'=>'unitprice','type'=>'xsd:double'),
101
+		'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
102
+		'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
103
+		'total' => array('name'=>'total','type'=>'xsd:double'),
104
+		'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
105
+		'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
106
+		// From product
107
+		'product_id' => array('name'=>'product_id','type'=>'xsd:int'),
108
+		'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
109
+		'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
110
+		'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
111
+	)
112 112
 );
113 113
 
114 114
 /*$server->wsdl->addComplexType(
@@ -124,55 +124,55 @@  discard block
 block discarded – undo
124 124
     'tns:line'
125 125
 );*/
126 126
 $server->wsdl->addComplexType(
127
-    'LinesArray2',
128
-    'complexType',
129
-    'array',
130
-    'sequence',
131
-    '',
132
-    array(
133
-        'line' => array(
134
-            'name' => 'line',
135
-            'type' => 'tns:line',
136
-            'minOccurs' => '0',
137
-            'maxOccurs' => 'unbounded'
138
-        )
139
-    ),
140
-    null,
141
-    'tns:line'
127
+	'LinesArray2',
128
+	'complexType',
129
+	'array',
130
+	'sequence',
131
+	'',
132
+	array(
133
+		'line' => array(
134
+			'name' => 'line',
135
+			'type' => 'tns:line',
136
+			'minOccurs' => '0',
137
+			'maxOccurs' => 'unbounded'
138
+		)
139
+	),
140
+	null,
141
+	'tns:line'
142 142
 );
143 143
 
144 144
 
145 145
 $server->wsdl->addComplexType(
146
-    'invoice',
147
-    'complexType',
148
-    'struct',
149
-    'all',
150
-    '',
151
-    array(
152
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
153
-        'ref' => array('name'=>'ref','type'=>'xsd:string'),
154
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
155
-        'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
156
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
157
-        'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:string'),
158
-        'date' => array('name'=>'date','type'=>'xsd:date'),
159
-        'date_due' => array('name'=>'date_due','type'=>'xsd:date'),
160
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
161
-        'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
162
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
163
-    	'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'),
164
-        'type' => array('name'=>'type','type'=>'xsd:int'),
165
-        'total_net' => array('name'=>'type','type'=>'xsd:double'),
166
-        'total_vat' => array('name'=>'type','type'=>'xsd:double'),
167
-        'total' => array('name'=>'type','type'=>'xsd:double'),
168
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
169
-        'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
170
-        'status' => array('name'=>'status','type'=>'xsd:int'),
171
-        'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
172
-        'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
173
-        'project_id' => array('name'=>'project_id','type'=>'xsd:string'),
174
-        'lines' => array('name'=>'lines','type'=>'tns:LinesArray2')
175
-    )
146
+	'invoice',
147
+	'complexType',
148
+	'struct',
149
+	'all',
150
+	'',
151
+	array(
152
+		'id' => array('name'=>'id','type'=>'xsd:string'),
153
+		'ref' => array('name'=>'ref','type'=>'xsd:string'),
154
+		'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
155
+		'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
156
+		'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
157
+		'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:string'),
158
+		'date' => array('name'=>'date','type'=>'xsd:date'),
159
+		'date_due' => array('name'=>'date_due','type'=>'xsd:date'),
160
+		'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
161
+		'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
162
+		'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
163
+		'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'),
164
+		'type' => array('name'=>'type','type'=>'xsd:int'),
165
+		'total_net' => array('name'=>'type','type'=>'xsd:double'),
166
+		'total_vat' => array('name'=>'type','type'=>'xsd:double'),
167
+		'total' => array('name'=>'type','type'=>'xsd:double'),
168
+		'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
169
+		'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
170
+		'status' => array('name'=>'status','type'=>'xsd:int'),
171
+		'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
172
+		'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
173
+		'project_id' => array('name'=>'project_id','type'=>'xsd:string'),
174
+		'lines' => array('name'=>'lines','type'=>'tns:LinesArray2')
175
+	)
176 176
 );
177 177
 /*
178 178
 $server->wsdl->addComplexType(
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
     'tns:invoice'
189 189
 );*/
190 190
 $server->wsdl->addComplexType(
191
-    'InvoicesArray2',
192
-    'complexType',
193
-    'array',
194
-    'sequence',
195
-    '',
196
-    array(
197
-        'invoice' => array(
198
-            'name' => 'invoice',
199
-            'type' => 'tns:invoice',
200
-            'minOccurs' => '0',
201
-            'maxOccurs' => 'unbounded'
202
-        )
203
-    ),
204
-    null,
205
-    'tns:invoice'
191
+	'InvoicesArray2',
192
+	'complexType',
193
+	'array',
194
+	'sequence',
195
+	'',
196
+	array(
197
+		'invoice' => array(
198
+			'name' => 'invoice',
199
+			'type' => 'tns:invoice',
200
+			'minOccurs' => '0',
201
+			'maxOccurs' => 'unbounded'
202
+		)
203
+	),
204
+	null,
205
+	'tns:invoice'
206 206
 );
207 207
 
208 208
 
@@ -216,40 +216,40 @@  discard block
 block discarded – undo
216 216
 
217 217
 // Register WSDL
218 218
 $server->register(
219
-    'getInvoice',
220
-    // Entry values
221
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
222
-    // Exit values
223
-    array('result'=>'tns:result','invoice'=>'tns:invoice'),
224
-    $ns,
225
-    $ns.'#getInvoice',
226
-    $styledoc,
227
-    $styleuse,
228
-    'WS to get a particular invoice'
219
+	'getInvoice',
220
+	// Entry values
221
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
222
+	// Exit values
223
+	array('result'=>'tns:result','invoice'=>'tns:invoice'),
224
+	$ns,
225
+	$ns.'#getInvoice',
226
+	$styledoc,
227
+	$styleuse,
228
+	'WS to get a particular invoice'
229 229
 );
230 230
 $server->register(
231
-    'getInvoicesForThirdParty',
232
-    // Entry values
233
-    array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
234
-    // Exit values
235
-    array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'),
236
-    $ns,
237
-    $ns.'#getInvoicesForThirdParty',
238
-    $styledoc,
239
-    $styleuse,
240
-    'WS to get all invoices of a third party'
231
+	'getInvoicesForThirdParty',
232
+	// Entry values
233
+	array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
234
+	// Exit values
235
+	array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'),
236
+	$ns,
237
+	$ns.'#getInvoicesForThirdParty',
238
+	$styledoc,
239
+	$styleuse,
240
+	'WS to get all invoices of a third party'
241 241
 );
242 242
 $server->register(
243
-    'createInvoice',
244
-    // Entry values
245
-    array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
246
-    // Exit values
247
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
248
-    $ns,
249
-    $ns.'#createInvoice',
250
-    $styledoc,
251
-    $styleuse,
252
-    'WS to create an invoice'
243
+	'createInvoice',
244
+	// Entry values
245
+	array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
246
+	// Exit values
247
+	array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
248
+	$ns,
249
+	$ns.'#createInvoice',
250
+	$styledoc,
251
+	$styleuse,
252
+	'WS to create an invoice'
253 253
 );
254 254
 $server->register(
255 255
 		'createInvoiceFromOrder',
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 		'WS to create an invoice from an order'
265 265
 );
266 266
 $server->register(
267
-    'updateInvoice',
268
-    // Entry values
269
-    array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
270
-    // Exit values
271
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
272
-    $ns,
273
-    $ns.'#updateInvoice',
274
-    $styledoc,
275
-    $styleuse,
276
-    'WS to update an invoice'
267
+	'updateInvoice',
268
+	// Entry values
269
+	array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
270
+	// Exit values
271
+	array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
272
+	$ns,
273
+	$ns.'#updateInvoice',
274
+	$styledoc,
275
+	$styleuse,
276
+	'WS to update an invoice'
277 277
 );
278 278
 
279 279
 
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 
295 295
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
296 296
 
297
-    // Init and check authentication
298
-    $objectresp=array();
299
-    $errorcode='';$errorlabel='';
300
-    $error=0;
301
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
302
-    // Check parameters
297
+	// Init and check authentication
298
+	$objectresp=array();
299
+	$errorcode='';$errorlabel='';
300
+	$error=0;
301
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
302
+	// Check parameters
303 303
 	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
304 304
 	{
305 305
 		$error++;
@@ -324,51 +324,51 @@  discard block
 block discarded – undo
324 324
 					$linesresp[]=array(
325 325
 						'id'=>$line->rowid,
326 326
 						'type'=>$line->product_type,
327
-                                                'desc'=>dol_htmlcleanlastbr($line->desc),
328
-                                                'total_net'=>$line->total_ht,
329
-                                                'total_vat'=>$line->total_tva,
330
-                                                'total'=>$line->total_ttc,
331
-                                                'vat_rate'=>$line->tva_tx,
332
-                                                'qty'=>$line->qty,
333
-                                                'unitprice'=> $line->subprice,
334
-                                                'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
335
-                                                'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
336
-                                                'product_id'=>$line->fk_product,
337
-                                                'product_ref'=>$line->product_ref,
338
-                                                'product_label'=>$line->product_label,
339
-                                                'product_desc'=>$line->product_desc,
327
+												'desc'=>dol_htmlcleanlastbr($line->desc),
328
+												'total_net'=>$line->total_ht,
329
+												'total_vat'=>$line->total_tva,
330
+												'total'=>$line->total_ttc,
331
+												'vat_rate'=>$line->tva_tx,
332
+												'qty'=>$line->qty,
333
+												'unitprice'=> $line->subprice,
334
+												'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
335
+												'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
336
+												'product_id'=>$line->fk_product,
337
+												'product_ref'=>$line->product_ref,
338
+												'product_label'=>$line->product_label,
339
+												'product_desc'=>$line->product_desc,
340 340
 					);
341 341
 					$i++;
342 342
 				}
343 343
 
344
-			    // Create invoice
345
-			    $objectresp = array(
346
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
347
-			        'invoice'=>array(
348
-				    	'id' => $invoice->id,
344
+				// Create invoice
345
+				$objectresp = array(
346
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
347
+					'invoice'=>array(
348
+						'id' => $invoice->id,
349 349
 			   			'ref' => $invoice->ref,
350
-			        	'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
351
-			        	'thirdparty_id' => $invoice->socid,
352
-			        	'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
353
-			        	'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
354
-			        	'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
355
-			        	'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
356
-			        	'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
357
-			        	'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
358
-			        	'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
359
-			        	'type' => $invoice->type,
360
-			        	'total_net' => $invoice->total_ht,
361
-			        	'total_vat' => $invoice->total_tva,
362
-			        	'total' => $invoice->total_ttc,
363
-			        	'note_private' => $invoice->note_private?$invoice->note_private:'',
364
-			        	'note_public' => $invoice->note_public?$invoice->note_public:'',
365
-			        	'status' => $invoice->statut,
350
+						'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
351
+						'thirdparty_id' => $invoice->socid,
352
+						'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
353
+						'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
354
+						'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
355
+						'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
356
+						'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
357
+						'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
358
+						'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
359
+						'type' => $invoice->type,
360
+						'total_net' => $invoice->total_ht,
361
+						'total_vat' => $invoice->total_tva,
362
+						'total' => $invoice->total_ttc,
363
+						'note_private' => $invoice->note_private?$invoice->note_private:'',
364
+						'note_public' => $invoice->note_public?$invoice->note_public:'',
365
+						'status' => $invoice->statut,
366 366
 					'project_id' => $invoic->fk_project,
367
-			        	'close_code' => $invoice->close_code?$invoice->close_code:'',
368
-			        	'close_note' => $invoice->close_note?$invoice->close_note:'',
369
-			        	'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
370
-			        	'lines' => $linesresp
371
-			        ));
367
+						'close_code' => $invoice->close_code?$invoice->close_code:'',
368
+						'close_note' => $invoice->close_note?$invoice->close_note:'',
369
+						'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
370
+						'lines' => $linesresp
371
+					));
372 372
 			}
373 373
 			else
374 374
 			{
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 
408 408
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
409 409
 
410
-    // Init and check authentication
411
-    $objectresp=array();
412
-    $errorcode='';$errorlabel='';
413
-    $error=0;
414
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
410
+	// Init and check authentication
411
+	$objectresp=array();
412
+	$errorcode='';$errorlabel='';
413
+	$error=0;
414
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
415 415
 
416 416
 	if ($fuser->socid) $socid=$fuser->socid;
417 417
 
@@ -438,76 +438,76 @@  discard block
 block discarded – undo
438 438
 			$i=0;
439 439
 			while ($i < $num)
440 440
 			{
441
-                // En attendant remplissage par boucle
442
-			    $obj=$db->fetch_object($resql);
443
-
444
-			    $invoice=new Facture($db);
445
-			    $invoice->fetch($obj->facid);
446
-
447
-			    // Sécurité pour utilisateur externe
448
-			    if( $socid && ( $socid != $invoice->socid) )
449
-			    {
450
-			    	$error++;
451
-			    	$errorcode='PERMISSION_DENIED'; $errorlabel=$invoice->socid.' User does not have permission for this request';
452
-			    }
453
-
454
-			    if(!$error)
455
-			    {
456
-			    	// Define lines of invoice
457
-			    	$linesresp=array();
458
-			    	foreach($invoice->lines as $line)
459
-			    	{
460
-			    		$linesresp[]=array(
461
-	    					'id'=>$line->rowid,
462
-	    					'type'=>$line->product_type,
463
-	    					'total_net'=>$line->total_ht,
464
-	    					'total_vat'=>$line->total_tva,
465
-	    					'total'=>$line->total_ttc,
466
-			    			'vat_rate'=>$line->tva_tx,
467
-			    			'qty'=>$line->qty,
468
-                                                'unitprice'=> $line->subprice,
469
-                                                'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
470
-                                                'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
471
-                                                'product_id'=>$line->fk_product,
472
-			    			'product_ref'=>$line->product_ref,
473
-			    			'product_label'=>$line->product_label,
474
-			    			'product_desc'=>$line->product_desc,
475
-			    		);
476
-			    	}
477
-
478
-			    	// Now define invoice
479
-			    	$linesinvoice[]=array(
480
-			    		'id' => $invoice->id,
481
-			    		'ref' => $invoice->ref,
482
-			    		'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
483
-			    		'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
484
-			    		'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
485
-			    		'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
486
-			    		'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
487
-                                        'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
488
-			    		'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
489
-			    		'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
490
-			    		'type' => $invoice->type,
491
-			    		'total_net' => $invoice->total_ht,
492
-			    		'total_vat' => $invoice->total_tva,
493
-			    		'total' => $invoice->total_ttc,
494
-			    		'note_private' => $invoice->note_private?$invoice->note_private:'',
495
-			    		'note_public' => $invoice->note_public?$invoice->note_public:'',
496
-			    		'status'=> $invoice->statut,
497
-                                        'project_id' => $invoic->fk_project,
498
-			    		'close_code' => $invoice->close_code?$invoice->close_code:'',
499
-			    		'close_note' => $invoice->close_note?$invoice->close_note:'',
500
-			    		'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
501
-			    		'lines' => $linesresp
502
-			    	);
503
-			    }
504
-
505
-			    $i++;
441
+				// En attendant remplissage par boucle
442
+				$obj=$db->fetch_object($resql);
443
+
444
+				$invoice=new Facture($db);
445
+				$invoice->fetch($obj->facid);
446
+
447
+				// Sécurité pour utilisateur externe
448
+				if( $socid && ( $socid != $invoice->socid) )
449
+				{
450
+					$error++;
451
+					$errorcode='PERMISSION_DENIED'; $errorlabel=$invoice->socid.' User does not have permission for this request';
452
+				}
453
+
454
+				if(!$error)
455
+				{
456
+					// Define lines of invoice
457
+					$linesresp=array();
458
+					foreach($invoice->lines as $line)
459
+					{
460
+						$linesresp[]=array(
461
+							'id'=>$line->rowid,
462
+							'type'=>$line->product_type,
463
+							'total_net'=>$line->total_ht,
464
+							'total_vat'=>$line->total_tva,
465
+							'total'=>$line->total_ttc,
466
+							'vat_rate'=>$line->tva_tx,
467
+							'qty'=>$line->qty,
468
+												'unitprice'=> $line->subprice,
469
+												'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
470
+												'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
471
+												'product_id'=>$line->fk_product,
472
+							'product_ref'=>$line->product_ref,
473
+							'product_label'=>$line->product_label,
474
+							'product_desc'=>$line->product_desc,
475
+						);
476
+					}
477
+
478
+					// Now define invoice
479
+					$linesinvoice[]=array(
480
+						'id' => $invoice->id,
481
+						'ref' => $invoice->ref,
482
+						'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
483
+						'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
484
+						'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
485
+						'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
486
+						'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
487
+										'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
488
+						'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
489
+						'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
490
+						'type' => $invoice->type,
491
+						'total_net' => $invoice->total_ht,
492
+						'total_vat' => $invoice->total_tva,
493
+						'total' => $invoice->total_ttc,
494
+						'note_private' => $invoice->note_private?$invoice->note_private:'',
495
+						'note_public' => $invoice->note_public?$invoice->note_public:'',
496
+						'status'=> $invoice->statut,
497
+										'project_id' => $invoic->fk_project,
498
+						'close_code' => $invoice->close_code?$invoice->close_code:'',
499
+						'close_note' => $invoice->close_note?$invoice->close_note:'',
500
+						'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
501
+						'lines' => $linesresp
502
+					);
503
+				}
504
+
505
+				$i++;
506 506
 			}
507 507
 
508 508
 			$objectresp=array(
509
-		    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
510
-		        'invoices'=>$linesinvoice
509
+				'result'=>array('result_code'=>'OK', 'result_label'=>''),
510
+				'invoices'=>$linesinvoice
511 511
 
512 512
 			);
513 513
 		}
@@ -536,114 +536,114 @@  discard block
 block discarded – undo
536 536
  */
537 537
 function createInvoice($authentication,$invoice)
538 538
 {
539
-    global $db,$conf,$langs;
539
+	global $db,$conf,$langs;
540 540
 
541
-    $now=dol_now();
541
+	$now=dol_now();
542 542
 
543
-    dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
544
-    		", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
543
+	dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
544
+			", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
545 545
 
546
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
546
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
547 547
 
548
-    // Init and check authentication
549
-    $objectresp=array();
550
-    $errorcode='';$errorlabel='';
551
-    $error=0;
552
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
548
+	// Init and check authentication
549
+	$objectresp=array();
550
+	$errorcode='';$errorlabel='';
551
+	$error=0;
552
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
553 553
 
554
-    // Check parameters
555
-    if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext']))	{
556
-    	$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
557
-    }
554
+	// Check parameters
555
+	if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext']))	{
556
+		$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
557
+	}
558 558
     
559
-    if (! $error)
560
-    {
561
-        $new_invoice=new Facture($db);
562
-        $new_invoice->socid=$invoice['thirdparty_id'];
563
-        $new_invoice->type=$invoice['type'];
564
-        $new_invoice->ref_ext=$invoice['ref_ext'];
565
-        $new_invoice->date=dol_stringtotime($invoice['date'],'dayrfc');
566
-        $new_invoice->note_private=$invoice['note_private'];
567
-        $new_invoice->note_public=$invoice['note_public'];
568
-        $new_invoice->statut= Facture::STATUS_DRAFT;	// We start with status draft
569
-        $new_invoice->fk_project=$invoice['project_id'];
570
-        $new_invoice->date_creation=$now;
559
+	if (! $error)
560
+	{
561
+		$new_invoice=new Facture($db);
562
+		$new_invoice->socid=$invoice['thirdparty_id'];
563
+		$new_invoice->type=$invoice['type'];
564
+		$new_invoice->ref_ext=$invoice['ref_ext'];
565
+		$new_invoice->date=dol_stringtotime($invoice['date'],'dayrfc');
566
+		$new_invoice->note_private=$invoice['note_private'];
567
+		$new_invoice->note_public=$invoice['note_public'];
568
+		$new_invoice->statut= Facture::STATUS_DRAFT;	// We start with status draft
569
+		$new_invoice->fk_project=$invoice['project_id'];
570
+		$new_invoice->date_creation=$now;
571 571
         
572 572
 	//take mode_reglement and cond_reglement from thirdparty
573
-        $soc = new Societe($db);
574
-        $res=$soc->fetch($new_invoice->socid);
575
-        if ($res > 0) {
576
-    	    $new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
577
-            $new_invoice->cond_reglement_id  = $soc->cond_reglement_id; 
578
-        }
579
-        else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
580
-
581
-        // Trick because nusoap does not store data with same structure if there is one or several lines
582
-        $arrayoflines=array();
583
-        if (isset($invoice['lines']['line'][0])) $arrayoflines=$invoice['lines']['line'];
584
-        else $arrayoflines=$invoice['lines'];
585
-
586
-        foreach($arrayoflines as $key => $line)
587
-        {
588
-            // $key can be 'line' or '0','1',...
589
-            $newline=new FactureLigne($db);
590
-            $newline->product_type=$line['type'];
591
-            $newline->desc=$line['desc'];
592
-            $newline->fk_product=$line['fk_product'];
593
-            $newline->tva_tx=$line['vat_rate'];
594
-            $newline->qty=$line['qty'];
595
-            $newline->subprice=$line['unitprice'];
596
-            $newline->total_ht=$line['total_net'];
597
-            $newline->total_tva=$line['total_vat'];
598
-            $newline->total_ttc=$line['total'];
599
-            $newline->date_start=dol_stringtotime($line['date_start']);
600
-            $newline->date_end=dol_stringtotime($line['date_end']);
601
-            $newline->fk_product=$line['product_id'];
602
-            $new_invoice->lines[]=$newline;
603
-        }
604
-        //var_dump($newobject->date_lim_reglement); exit;
605
-        //var_dump($invoice['lines'][0]['type']);
606
-
607
-        $db->begin();
608
-
609
-        $result=$new_invoice->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
610
-        if ($result < 0)
611
-        {
612
-            $error++;
613
-        }
614
-
615
-        if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED)   // We want invoice to have status validated
616
-        {
617
-            $result=$new_invoice->validate($fuser);
618
-            if ($result < 0)
619
-            {
620
-                $error++;
621
-            }
622
-        }
623
-
624
-        if (! $error)
625
-        {
626
-            $db->commit();
627
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
628
-            		'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
629
-        }
630
-        else
631
-        {
632
-            $db->rollback();
633
-            $error++;
634
-            $errorcode='KO';
635
-            $errorlabel=$new_invoice->error;
636
-            dol_syslog("Function: createInvoice error while creating".$errorlabel);
637
-        }
638
-
639
-    }
640
-
641
-    if ($error)
642
-    {
643
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
644
-    }
645
-
646
-    return $objectresp;
573
+		$soc = new Societe($db);
574
+		$res=$soc->fetch($new_invoice->socid);
575
+		if ($res > 0) {
576
+			$new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
577
+			$new_invoice->cond_reglement_id  = $soc->cond_reglement_id; 
578
+		}
579
+		else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
580
+
581
+		// Trick because nusoap does not store data with same structure if there is one or several lines
582
+		$arrayoflines=array();
583
+		if (isset($invoice['lines']['line'][0])) $arrayoflines=$invoice['lines']['line'];
584
+		else $arrayoflines=$invoice['lines'];
585
+
586
+		foreach($arrayoflines as $key => $line)
587
+		{
588
+			// $key can be 'line' or '0','1',...
589
+			$newline=new FactureLigne($db);
590
+			$newline->product_type=$line['type'];
591
+			$newline->desc=$line['desc'];
592
+			$newline->fk_product=$line['fk_product'];
593
+			$newline->tva_tx=$line['vat_rate'];
594
+			$newline->qty=$line['qty'];
595
+			$newline->subprice=$line['unitprice'];
596
+			$newline->total_ht=$line['total_net'];
597
+			$newline->total_tva=$line['total_vat'];
598
+			$newline->total_ttc=$line['total'];
599
+			$newline->date_start=dol_stringtotime($line['date_start']);
600
+			$newline->date_end=dol_stringtotime($line['date_end']);
601
+			$newline->fk_product=$line['product_id'];
602
+			$new_invoice->lines[]=$newline;
603
+		}
604
+		//var_dump($newobject->date_lim_reglement); exit;
605
+		//var_dump($invoice['lines'][0]['type']);
606
+
607
+		$db->begin();
608
+
609
+		$result=$new_invoice->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
610
+		if ($result < 0)
611
+		{
612
+			$error++;
613
+		}
614
+
615
+		if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED)   // We want invoice to have status validated
616
+		{
617
+			$result=$new_invoice->validate($fuser);
618
+			if ($result < 0)
619
+			{
620
+				$error++;
621
+			}
622
+		}
623
+
624
+		if (! $error)
625
+		{
626
+			$db->commit();
627
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
628
+					'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
629
+		}
630
+		else
631
+		{
632
+			$db->rollback();
633
+			$error++;
634
+			$errorcode='KO';
635
+			$errorlabel=$new_invoice->error;
636
+			dol_syslog("Function: createInvoice error while creating".$errorlabel);
637
+		}
638
+
639
+	}
640
+
641
+	if ($error)
642
+	{
643
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
644
+	}
645
+
646
+	return $objectresp;
647 647
 }
648 648
 
649 649
 /**
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	$errorcode='';$errorlabel='';
672 672
 	$error=0;
673 673
 	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
674
-    if ($fuser->socid) $socid=$fuser->socid;
674
+	if ($fuser->socid) $socid=$fuser->socid;
675 675
 
676 676
 	// Check parameters
677 677
 	if (empty($id_order) && empty($ref_order) && empty($ref_ext_order))	{
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	global $db,$conf,$langs;
748 748
 
749 749
 	dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id'].
750
-    		", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
750
+			", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
751 751
 
752 752
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
753 753
 
Please login to merge, or discard this patch.
Braces   +48 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (! defined("NOCSRFCHECK")) {
25
+	define("NOCSRFCHECK",'1');
26
+}
25 27
 
26 28
 require_once '../master.inc.php';
27 29
 require_once NUSOAP_PATH.'/nusoap.php';		// Include SOAP
@@ -292,7 +294,9 @@  discard block
 block discarded – undo
292 294
 
293 295
 	dol_syslog("Function: getInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
294 296
 
295
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
297
+	if ($authentication['entity']) {
298
+		$conf->entity=$authentication['entity'];
299
+	}
296 300
 
297 301
     // Init and check authentication
298 302
     $objectresp=array();
@@ -369,14 +373,12 @@  discard block
 block discarded – undo
369 373
 			        	'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
370 374
 			        	'lines' => $linesresp
371 375
 			        ));
372
-			}
373
-			else
376
+			} else
374 377
 			{
375 378
 				$error++;
376 379
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
377 380
 			}
378
-		}
379
-		else
381
+		} else
380 382
 		{
381 383
 			$error++;
382 384
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -405,7 +407,9 @@  discard block
 block discarded – undo
405 407
 
406 408
 	dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
407 409
 
408
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
410
+	if ($authentication['entity']) {
411
+		$conf->entity=$authentication['entity'];
412
+	}
409 413
 
410 414
     // Init and check authentication
411 415
     $objectresp=array();
@@ -413,7 +417,9 @@  discard block
 block discarded – undo
413 417
     $error=0;
414 418
     $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
415 419
 
416
-	if ($fuser->socid) $socid=$fuser->socid;
420
+	if ($fuser->socid) {
421
+		$socid=$fuser->socid;
422
+	}
417 423
 
418 424
 	// Check parameters
419 425
 	if (! $error && empty($idthirdparty))
@@ -429,7 +435,9 @@  discard block
 block discarded – undo
429 435
 		$sql ='SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva';
430 436
 		$sql.=' FROM '.MAIN_DB_PREFIX.'facture as f';
431 437
 		$sql.=" WHERE f.entity = ".$conf->entity;
432
-		if ($idthirdparty != 'all' ) $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
438
+		if ($idthirdparty != 'all' ) {
439
+			$sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
440
+		}
433 441
 
434 442
 		$resql=$db->query($sql);
435 443
 		if ($resql)
@@ -510,8 +518,7 @@  discard block
 block discarded – undo
510 518
 		        'invoices'=>$linesinvoice
511 519
 
512 520
 			);
513
-		}
514
-		else
521
+		} else
515 522
 		{
516 523
 			$error++;
517 524
 			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
@@ -543,7 +550,9 @@  discard block
 block discarded – undo
543 550
     dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
544 551
     		", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
545 552
 
546
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
553
+    if ($authentication['entity']) {
554
+    	$conf->entity=$authentication['entity'];
555
+    }
547 556
 
548 557
     // Init and check authentication
549 558
     $objectresp=array();
@@ -575,13 +584,17 @@  discard block
 block discarded – undo
575 584
         if ($res > 0) {
576 585
     	    $new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
577 586
             $new_invoice->cond_reglement_id  = $soc->cond_reglement_id; 
587
+        } else {
588
+        	$new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
578 589
         }
579
-        else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
580 590
 
581 591
         // Trick because nusoap does not store data with same structure if there is one or several lines
582 592
         $arrayoflines=array();
583
-        if (isset($invoice['lines']['line'][0])) $arrayoflines=$invoice['lines']['line'];
584
-        else $arrayoflines=$invoice['lines'];
593
+        if (isset($invoice['lines']['line'][0])) {
594
+        	$arrayoflines=$invoice['lines']['line'];
595
+        } else {
596
+        	$arrayoflines=$invoice['lines'];
597
+        }
585 598
 
586 599
         foreach($arrayoflines as $key => $line)
587 600
         {
@@ -612,9 +625,11 @@  discard block
 block discarded – undo
612 625
             $error++;
613 626
         }
614 627
 
615
-        if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED)   // We want invoice to have status validated
628
+        if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED) {
629
+        	// We want invoice to have status validated
616 630
         {
617 631
             $result=$new_invoice->validate($fuser);
632
+        }
618 633
             if ($result < 0)
619 634
             {
620 635
                 $error++;
@@ -626,8 +641,7 @@  discard block
 block discarded – undo
626 641
             $db->commit();
627 642
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
628 643
             		'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
629
-        }
630
-        else
644
+        } else
631 645
         {
632 646
             $db->rollback();
633 647
             $error++;
@@ -664,14 +678,18 @@  discard block
 block discarded – undo
664 678
 	dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.
665 679
 			", ref=".$ref_order.", ref_ext=".$ref_ext_order);
666 680
 
667
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
681
+	if ($authentication['entity']) {
682
+		$conf->entity=$authentication['entity'];
683
+	}
668 684
 
669 685
 	// Init and check authentication
670 686
 	$objectresp=array();
671 687
 	$errorcode='';$errorlabel='';
672 688
 	$error=0;
673 689
 	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
674
-    if ($fuser->socid) $socid=$fuser->socid;
690
+    if ($fuser->socid) {
691
+    	$socid=$fuser->socid;
692
+    }
675 693
 
676 694
 	// Check parameters
677 695
 	if (empty($id_order) && empty($ref_order) && empty($ref_ext_order))	{
@@ -709,14 +727,12 @@  discard block
 block discarded – undo
709 727
 					}
710 728
 					
711 729
 				}
712
-			}
713
-			else
730
+			} else
714 731
 			{
715 732
 				$error++;
716 733
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id_order.' nor ref='.$ref_order.' nor ref_ext='.$ref_ext_order;
717 734
 			}
718
-		}
719
-		else
735
+		} else
720 736
 		{
721 737
 			$error++;
722 738
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -726,8 +742,7 @@  discard block
 block discarded – undo
726 742
 	if ($error)
727 743
 	{
728 744
 		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
729
-	}
730
-	else
745
+	} else
731 746
 	{
732 747
 		$objectresp= array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref,'ref_ext'=>$newobject->ref_ext);
733 748
 	}
@@ -749,7 +764,9 @@  discard block
 block discarded – undo
749 764
 	dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id'].
750 765
     		", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
751 766
 
752
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
767
+	if ($authentication['entity']) {
768
+		$conf->entity=$authentication['entity'];
769
+	}
753 770
 
754 771
 	// Init and check authentication
755 772
 	$objectresp=array();
@@ -796,8 +813,9 @@  discard block
 block discarded – undo
796 813
 				{
797 814
 					$result = $object->set_paid($fuser,$invoice->close_code,$invoice->close_note);			
798 815
 				}
799
-				if ($invoice['status'] == Facture::STATUS_ABANDONED)
800
-					$result = $object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
816
+				if ($invoice['status'] == Facture::STATUS_ABANDONED) {
817
+									$result = $object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
818
+				}
801 819
 			}
802 820
 		}
803 821
 	
@@ -810,8 +828,7 @@  discard block
 block discarded – undo
810 828
 					'ref'=>$object->ref,
811 829
 					'ref_ext'=>$object->ref_ext
812 830
 			);
813
-		}
814
-		elseif ($objectfound)
831
+		} elseif ($objectfound)
815 832
 		{
816 833
 			$db->rollback();
817 834
 			$error++;
Please login to merge, or discard this patch.
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
25 25
 
26 26
 require_once '../master.inc.php';
27
-require_once NUSOAP_PATH.'/nusoap.php';		// Include SOAP
27
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
28 28
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 {
43 43
 	$langs->load("admin");
44 44
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
45
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
46 46
 	print $langs->trans("ToActivateModule");
47 47
 	exit;
48 48
 }
49 49
 
50 50
 // Create the soap Object
51 51
 $server = new nusoap_server();
52
-$server->soap_defencoding='UTF-8';
53
-$server->decode_utf8=false;
54
-$ns='http://www.dolibarr.org/ns/';
55
-$server->configureWSDL('WebServicesDolibarrInvoice',$ns);
56
-$server->wsdl->schemaTargetNamespace=$ns;
52
+$server->soap_defencoding = 'UTF-8';
53
+$server->decode_utf8 = false;
54
+$ns = 'http://www.dolibarr.org/ns/';
55
+$server->configureWSDL('WebServicesDolibarrInvoice', $ns);
56
+$server->wsdl->schemaTargetNamespace = $ns;
57 57
 
58 58
 
59 59
 // Define WSDL Authentication object
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
     'all',
65 65
     '',
66 66
     array(
67
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
68
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
69
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
70
-        'password' => array('name'=>'password','type'=>'xsd:string'),
71
-        'entity' => array('name'=>'entity','type'=>'xsd:string')
67
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
68
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
69
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
70
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
71
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string')
72 72
     )
73 73
 );
74 74
 // Define WSDL Return object
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     'all',
80 80
     '',
81 81
     array(
82
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
82
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
83
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
84 84
     )
85 85
 );
86 86
 
@@ -92,22 +92,22 @@  discard block
 block discarded – undo
92 92
     'all',
93 93
     '',
94 94
     array(
95
-        'id' => array('name'=>'id','type'=>'xsd:string'),
96
-        'type' => array('name'=>'type','type'=>'xsd:int'),
97
-        'desc' => array('name'=>'desc','type'=>'xsd:string'),
98
-        'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
99
-        'qty' => array('name'=>'qty','type'=>'xsd:double'),
100
-        'unitprice' => array('name'=>'unitprice','type'=>'xsd:double'),
101
-        'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
102
-    	'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
103
-    	'total' => array('name'=>'total','type'=>'xsd:double'),
104
-        'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
105
-        'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
95
+        'id' => array('name'=>'id', 'type'=>'xsd:string'),
96
+        'type' => array('name'=>'type', 'type'=>'xsd:int'),
97
+        'desc' => array('name'=>'desc', 'type'=>'xsd:string'),
98
+        'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:double'),
99
+        'qty' => array('name'=>'qty', 'type'=>'xsd:double'),
100
+        'unitprice' => array('name'=>'unitprice', 'type'=>'xsd:double'),
101
+        'total_net' => array('name'=>'total_net', 'type'=>'xsd:double'),
102
+    	'total_vat' => array('name'=>'total_vat', 'type'=>'xsd:double'),
103
+    	'total' => array('name'=>'total', 'type'=>'xsd:double'),
104
+        'date_start' => array('name'=>'date_start', 'type'=>'xsd:date'),
105
+        'date_end' => array('name'=>'date_end', 'type'=>'xsd:date'),
106 106
         // From product
107
-        'product_id' => array('name'=>'product_id','type'=>'xsd:int'),
108
-        'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
109
-        'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
110
-        'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
107
+        'product_id' => array('name'=>'product_id', 'type'=>'xsd:int'),
108
+        'product_ref' => array('name'=>'product_ref', 'type'=>'xsd:string'),
109
+        'product_label' => array('name'=>'product_label', 'type'=>'xsd:string'),
110
+        'product_desc' => array('name'=>'product_desc', 'type'=>'xsd:string')
111 111
     )
112 112
 );
113 113
 
@@ -149,29 +149,29 @@  discard block
 block discarded – undo
149 149
     'all',
150 150
     '',
151 151
     array(
152
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
153
-        'ref' => array('name'=>'ref','type'=>'xsd:string'),
154
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
155
-        'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
156
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
157
-        'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:string'),
158
-        'date' => array('name'=>'date','type'=>'xsd:date'),
159
-        'date_due' => array('name'=>'date_due','type'=>'xsd:date'),
160
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
161
-        'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
162
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
163
-    	'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'),
164
-        'type' => array('name'=>'type','type'=>'xsd:int'),
165
-        'total_net' => array('name'=>'type','type'=>'xsd:double'),
166
-        'total_vat' => array('name'=>'type','type'=>'xsd:double'),
167
-        'total' => array('name'=>'type','type'=>'xsd:double'),
168
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
169
-        'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
170
-        'status' => array('name'=>'status','type'=>'xsd:int'),
171
-        'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
172
-        'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
173
-        'project_id' => array('name'=>'project_id','type'=>'xsd:string'),
174
-        'lines' => array('name'=>'lines','type'=>'tns:LinesArray2')
152
+    	'id' => array('name'=>'id', 'type'=>'xsd:string'),
153
+        'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
154
+        'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
155
+        'thirdparty_id' => array('name'=>'thirdparty_id', 'type'=>'xsd:int'),
156
+        'fk_user_author' => array('name'=>'fk_user_author', 'type'=>'xsd:string'),
157
+        'fk_user_valid' => array('name'=>'fk_user_valid', 'type'=>'xsd:string'),
158
+        'date' => array('name'=>'date', 'type'=>'xsd:date'),
159
+        'date_due' => array('name'=>'date_due', 'type'=>'xsd:date'),
160
+        'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'),
161
+        'date_validation' => array('name'=>'date_validation', 'type'=>'xsd:dateTime'),
162
+        'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'),
163
+    	'payment_mode_id' => array('name'=>'payment_mode_id', 'type'=>'xsd:string'),
164
+        'type' => array('name'=>'type', 'type'=>'xsd:int'),
165
+        'total_net' => array('name'=>'type', 'type'=>'xsd:double'),
166
+        'total_vat' => array('name'=>'type', 'type'=>'xsd:double'),
167
+        'total' => array('name'=>'type', 'type'=>'xsd:double'),
168
+        'note_private' => array('name'=>'note_private', 'type'=>'xsd:string'),
169
+        'note_public' => array('name'=>'note_public', 'type'=>'xsd:string'),
170
+        'status' => array('name'=>'status', 'type'=>'xsd:int'),
171
+        'close_code' => array('name'=>'close_code', 'type'=>'xsd:string'),
172
+        'close_note' => array('name'=>'close_note', 'type'=>'xsd:string'),
173
+        'project_id' => array('name'=>'project_id', 'type'=>'xsd:string'),
174
+        'lines' => array('name'=>'lines', 'type'=>'tns:LinesArray2')
175 175
     )
176 176
 );
177 177
 /*
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
211 211
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
212 212
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
213
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
214
-$styleuse='encoded';   // encoded/literal/literal wrapped
213
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
214
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
215 215
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
216 216
 
217 217
 // Register WSDL
218 218
 $server->register(
219 219
     'getInvoice',
220 220
     // Entry values
221
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
221
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
222 222
     // Exit values
223
-    array('result'=>'tns:result','invoice'=>'tns:invoice'),
223
+    array('result'=>'tns:result', 'invoice'=>'tns:invoice'),
224 224
     $ns,
225 225
     $ns.'#getInvoice',
226 226
     $styledoc,
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 $server->register(
231 231
     'getInvoicesForThirdParty',
232 232
     // Entry values
233
-    array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
233
+    array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'),
234 234
     // Exit values
235
-    array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'),
235
+    array('result'=>'tns:result', 'invoices'=>'tns:InvoicesArray2'),
236 236
     $ns,
237 237
     $ns.'#getInvoicesForThirdParty',
238 238
     $styledoc,
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 $server->register(
243 243
     'createInvoice',
244 244
     // Entry values
245
-    array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
245
+    array('authentication'=>'tns:authentication', 'invoice'=>'tns:invoice'),
246 246
     // Exit values
247
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
247
+    array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
248 248
     $ns,
249 249
     $ns.'#createInvoice',
250 250
     $styledoc,
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 $server->register(
255 255
 		'createInvoiceFromOrder',
256 256
 		// Entry values
257
-		array('authentication'=>'tns:authentication','id_order'=>'xsd:string','ref_order'=>'xsd:string','ref_ext_order'=>'xsd:string'),
257
+		array('authentication'=>'tns:authentication', 'id_order'=>'xsd:string', 'ref_order'=>'xsd:string', 'ref_ext_order'=>'xsd:string'),
258 258
 		// Exit values
259
-		array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
259
+		array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
260 260
 		$ns,
261 261
 		$ns.'#createInvoiceFromOrder',
262 262
 		$styledoc,
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 $server->register(
267 267
     'updateInvoice',
268 268
     // Entry values
269
-    array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'),
269
+    array('authentication'=>'tns:authentication', 'invoice'=>'tns:invoice'),
270 270
     // Exit values
271
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
271
+    array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
272 272
     $ns,
273 273
     $ns.'#updateInvoice',
274 274
     $styledoc,
@@ -286,42 +286,42 @@  discard block
 block discarded – undo
286 286
  * @param	string		$ref_ext			Ref_ext
287 287
  * @return	array							Array result
288 288
  */
289
-function getInvoice($authentication,$id='',$ref='',$ref_ext='')
289
+function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
290 290
 {
291
-	global $db,$conf,$langs;
291
+	global $db, $conf, $langs;
292 292
 
293 293
 	dol_syslog("Function: getInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
294 294
 
295
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
295
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
296 296
 
297 297
     // Init and check authentication
298
-    $objectresp=array();
299
-    $errorcode='';$errorlabel='';
300
-    $error=0;
301
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
298
+    $objectresp = array();
299
+    $errorcode = ''; $errorlabel = '';
300
+    $error = 0;
301
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
302 302
     // Check parameters
303
-	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
303
+	if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
304 304
 	{
305 305
 		$error++;
306
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
306
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
307 307
 	}
308 308
 
309
-	if (! $error)
309
+	if (!$error)
310 310
 	{
311 311
 		$fuser->getrights();
312 312
 
313 313
 		if ($fuser->rights->facture->lire)
314 314
 		{
315
-			$invoice=new Facture($db);
316
-			$result=$invoice->fetch($id,$ref,$ref_ext);
315
+			$invoice = new Facture($db);
316
+			$result = $invoice->fetch($id, $ref, $ref_ext);
317 317
 			if ($result > 0)
318 318
 			{
319
-				$linesresp=array();
320
-				$i=0;
321
-				foreach($invoice->lines as $line)
319
+				$linesresp = array();
320
+				$i = 0;
321
+				foreach ($invoice->lines as $line)
322 322
 				{
323 323
 					//var_dump($line); exit;
324
-					$linesresp[]=array(
324
+					$linesresp[] = array(
325 325
 						'id'=>$line->rowid,
326 326
 						'type'=>$line->product_type,
327 327
                                                 'desc'=>dol_htmlcleanlastbr($line->desc),
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
                                                 'vat_rate'=>$line->tva_tx,
332 332
                                                 'qty'=>$line->qty,
333 333
                                                 'unitprice'=> $line->subprice,
334
-                                                'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
335
-                                                'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
334
+                                                'date_start'=> $line->date_start ?dol_print_date($line->date_start, 'dayrfc') : '',
335
+                                                'date_end'=> $line->date_end ?dol_print_date($line->date_end, 'dayrfc') : '',
336 336
                                                 'product_id'=>$line->fk_product,
337 337
                                                 'product_ref'=>$line->product_ref,
338 338
                                                 'product_label'=>$line->product_label,
@@ -347,39 +347,39 @@  discard block
 block discarded – undo
347 347
 			        'invoice'=>array(
348 348
 				    	'id' => $invoice->id,
349 349
 			   			'ref' => $invoice->ref,
350
-			        	'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
350
+			        	'ref_ext' => $invoice->ref_ext ? $invoice->ref_ext : '', // If not defined, field is not added into soap
351 351
 			        	'thirdparty_id' => $invoice->socid,
352
-			        	'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
353
-			        	'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
354
-			        	'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
355
-			        	'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
356
-			        	'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
357
-			        	'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
358
-			        	'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
352
+			        	'fk_user_author' => $invoice->user_author ? $invoice->user_author : '',
353
+			        	'fk_user_valid' => $invoice->user_valid ? $invoice->user_valid : '',
354
+			        	'date' => $invoice->date ?dol_print_date($invoice->date, 'dayrfc') : '',
355
+			        	'date_due' => $invoice->date_lim_reglement ?dol_print_date($invoice->date_lim_reglement, 'dayrfc') : '',
356
+			        	'date_creation' => $invoice->date_creation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
357
+			        	'date_validation' => $invoice->date_validation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
358
+			        	'date_modification' => $invoice->datem ?dol_print_date($invoice->datem, 'dayhourrfc') : '',
359 359
 			        	'type' => $invoice->type,
360 360
 			        	'total_net' => $invoice->total_ht,
361 361
 			        	'total_vat' => $invoice->total_tva,
362 362
 			        	'total' => $invoice->total_ttc,
363
-			        	'note_private' => $invoice->note_private?$invoice->note_private:'',
364
-			        	'note_public' => $invoice->note_public?$invoice->note_public:'',
363
+			        	'note_private' => $invoice->note_private ? $invoice->note_private : '',
364
+			        	'note_public' => $invoice->note_public ? $invoice->note_public : '',
365 365
 			        	'status' => $invoice->statut,
366 366
 					'project_id' => $invoic->fk_project,
367
-			        	'close_code' => $invoice->close_code?$invoice->close_code:'',
368
-			        	'close_note' => $invoice->close_note?$invoice->close_note:'',
369
-			        	'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
367
+			        	'close_code' => $invoice->close_code ? $invoice->close_code : '',
368
+			        	'close_note' => $invoice->close_note ? $invoice->close_note : '',
369
+			        	'payment_mode_id' => $invoice->mode_reglement_id ? $invoice->mode_reglement_id : '',
370 370
 			        	'lines' => $linesresp
371 371
 			        ));
372 372
 			}
373 373
 			else
374 374
 			{
375 375
 				$error++;
376
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
376
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
377 377
 			}
378 378
 		}
379 379
 		else
380 380
 		{
381 381
 			$error++;
382
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
382
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
383 383
 		}
384 384
 	}
385 385
 
@@ -399,65 +399,65 @@  discard block
 block discarded – undo
399 399
  * @param	int			$idthirdparty		Id thirdparty
400 400
  * @return	array							Array result
401 401
  */
402
-function getInvoicesForThirdParty($authentication,$idthirdparty)
402
+function getInvoicesForThirdParty($authentication, $idthirdparty)
403 403
 {
404
-	global $db,$conf,$langs;
404
+	global $db, $conf, $langs;
405 405
 
406 406
 	dol_syslog("Function: getInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
407 407
 
408
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
408
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
409 409
 
410 410
     // Init and check authentication
411
-    $objectresp=array();
412
-    $errorcode='';$errorlabel='';
413
-    $error=0;
414
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
411
+    $objectresp = array();
412
+    $errorcode = ''; $errorlabel = '';
413
+    $error = 0;
414
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
415 415
 
416
-	if ($fuser->socid) $socid=$fuser->socid;
416
+	if ($fuser->socid) $socid = $fuser->socid;
417 417
 
418 418
 	// Check parameters
419
-	if (! $error && empty($idthirdparty))
419
+	if (!$error && empty($idthirdparty))
420 420
 	{
421 421
 		$error++;
422
-		$errorcode='BAD_PARAMETERS'; $errorlabel='Parameter idthirdparty is not provided';
422
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter idthirdparty is not provided';
423 423
 	}
424 424
 
425
-	if (! $error)
425
+	if (!$error)
426 426
 	{
427
-		$linesinvoice=array();
427
+		$linesinvoice = array();
428 428
 
429
-		$sql ='SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva';
430
-		$sql.=' FROM '.MAIN_DB_PREFIX.'facture as f';
431
-		$sql.=" WHERE f.entity = ".$conf->entity;
432
-		if ($idthirdparty != 'all' ) $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
429
+		$sql = 'SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva';
430
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
431
+		$sql .= " WHERE f.entity = ".$conf->entity;
432
+		if ($idthirdparty != 'all') $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty);
433 433
 
434
-		$resql=$db->query($sql);
434
+		$resql = $db->query($sql);
435 435
 		if ($resql)
436 436
 		{
437
-			$num=$db->num_rows($resql);
438
-			$i=0;
437
+			$num = $db->num_rows($resql);
438
+			$i = 0;
439 439
 			while ($i < $num)
440 440
 			{
441 441
                 // En attendant remplissage par boucle
442
-			    $obj=$db->fetch_object($resql);
442
+			    $obj = $db->fetch_object($resql);
443 443
 
444
-			    $invoice=new Facture($db);
444
+			    $invoice = new Facture($db);
445 445
 			    $invoice->fetch($obj->facid);
446 446
 
447 447
 			    // Sécurité pour utilisateur externe
448
-			    if( $socid && ( $socid != $invoice->socid) )
448
+			    if ($socid && ($socid != $invoice->socid))
449 449
 			    {
450 450
 			    	$error++;
451
-			    	$errorcode='PERMISSION_DENIED'; $errorlabel=$invoice->socid.' User does not have permission for this request';
451
+			    	$errorcode = 'PERMISSION_DENIED'; $errorlabel = $invoice->socid.' User does not have permission for this request';
452 452
 			    }
453 453
 
454
-			    if(!$error)
454
+			    if (!$error)
455 455
 			    {
456 456
 			    	// Define lines of invoice
457
-			    	$linesresp=array();
458
-			    	foreach($invoice->lines as $line)
457
+			    	$linesresp = array();
458
+			    	foreach ($invoice->lines as $line)
459 459
 			    	{
460
-			    		$linesresp[]=array(
460
+			    		$linesresp[] = array(
461 461
 	    					'id'=>$line->rowid,
462 462
 	    					'type'=>$line->product_type,
463 463
 	    					'total_net'=>$line->total_ht,
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 			    			'vat_rate'=>$line->tva_tx,
467 467
 			    			'qty'=>$line->qty,
468 468
                                                 'unitprice'=> $line->subprice,
469
-                                                'date_start'=> $line->date_start?dol_print_date($line->date_start,'dayrfc'):'',
470
-                                                'date_end'=> $line->date_end?dol_print_date($line->date_end,'dayrfc'):'',
469
+                                                'date_start'=> $line->date_start ?dol_print_date($line->date_start, 'dayrfc') : '',
470
+                                                'date_end'=> $line->date_end ?dol_print_date($line->date_end, 'dayrfc') : '',
471 471
                                                 'product_id'=>$line->fk_product,
472 472
 			    			'product_ref'=>$line->product_ref,
473 473
 			    			'product_label'=>$line->product_label,
@@ -476,28 +476,28 @@  discard block
 block discarded – undo
476 476
 			    	}
477 477
 
478 478
 			    	// Now define invoice
479
-			    	$linesinvoice[]=array(
479
+			    	$linesinvoice[] = array(
480 480
 			    		'id' => $invoice->id,
481 481
 			    		'ref' => $invoice->ref,
482
-			    		'ref_ext' => $invoice->ref_ext?$invoice->ref_ext:'',   // If not defined, field is not added into soap
483
-			    		'fk_user_author' => $invoice->user_author?$invoice->user_author:'',
484
-			    		'fk_user_valid' => $invoice->user_valid?$invoice->user_valid:'',
485
-			    		'date' => $invoice->date?dol_print_date($invoice->date,'dayrfc'):'',
486
-			    		'date_due' => $invoice->date_lim_reglement?dol_print_date($invoice->date_lim_reglement,'dayrfc'):'',
487
-                                        'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
488
-			    		'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
489
-			    		'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
482
+			    		'ref_ext' => $invoice->ref_ext ? $invoice->ref_ext : '', // If not defined, field is not added into soap
483
+			    		'fk_user_author' => $invoice->user_author ? $invoice->user_author : '',
484
+			    		'fk_user_valid' => $invoice->user_valid ? $invoice->user_valid : '',
485
+			    		'date' => $invoice->date ?dol_print_date($invoice->date, 'dayrfc') : '',
486
+			    		'date_due' => $invoice->date_lim_reglement ?dol_print_date($invoice->date_lim_reglement, 'dayrfc') : '',
487
+                                        'date_creation' => $invoice->date_creation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
488
+			    		'date_validation' => $invoice->date_validation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '',
489
+			    		'date_modification' => $invoice->datem ?dol_print_date($invoice->datem, 'dayhourrfc') : '',
490 490
 			    		'type' => $invoice->type,
491 491
 			    		'total_net' => $invoice->total_ht,
492 492
 			    		'total_vat' => $invoice->total_tva,
493 493
 			    		'total' => $invoice->total_ttc,
494
-			    		'note_private' => $invoice->note_private?$invoice->note_private:'',
495
-			    		'note_public' => $invoice->note_public?$invoice->note_public:'',
494
+			    		'note_private' => $invoice->note_private ? $invoice->note_private : '',
495
+			    		'note_public' => $invoice->note_public ? $invoice->note_public : '',
496 496
 			    		'status'=> $invoice->statut,
497 497
                                         'project_id' => $invoic->fk_project,
498
-			    		'close_code' => $invoice->close_code?$invoice->close_code:'',
499
-			    		'close_note' => $invoice->close_note?$invoice->close_note:'',
500
-			    		'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'',
498
+			    		'close_code' => $invoice->close_code ? $invoice->close_code : '',
499
+			    		'close_note' => $invoice->close_note ? $invoice->close_note : '',
500
+			    		'payment_mode_id' => $invoice->mode_reglement_id ? $invoice->mode_reglement_id : '',
501 501
 			    		'lines' => $linesresp
502 502
 			    	);
503 503
 			    }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 			    $i++;
506 506
 			}
507 507
 
508
-			$objectresp=array(
508
+			$objectresp = array(
509 509
 		    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
510 510
 		        'invoices'=>$linesinvoice
511 511
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		else
515 515
 		{
516 516
 			$error++;
517
-			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
517
+			$errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
518 518
 		}
519 519
 	}
520 520
 
@@ -534,79 +534,79 @@  discard block
 block discarded – undo
534 534
  * @param	Facture		$invoice			Invoice
535 535
  * @return	array							Array result
536 536
  */
537
-function createInvoice($authentication,$invoice)
537
+function createInvoice($authentication, $invoice)
538 538
 {
539
-    global $db,$conf,$langs;
539
+    global $db, $conf, $langs;
540 540
 
541
-    $now=dol_now();
541
+    $now = dol_now();
542 542
 
543 543
     dol_syslog("Function: createInvoice login=".$authentication['login']." id=".$invoice->id.
544 544
     		", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
545 545
 
546
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
546
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
547 547
 
548 548
     // Init and check authentication
549
-    $objectresp=array();
550
-    $errorcode='';$errorlabel='';
551
-    $error=0;
552
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
549
+    $objectresp = array();
550
+    $errorcode = ''; $errorlabel = '';
551
+    $error = 0;
552
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
553 553
 
554 554
     // Check parameters
555
-    if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext']))	{
556
-    	$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
555
+    if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext'])) {
556
+    	$error++; $errorcode = 'KO'; $errorlabel = "Invoice id or ref or ref_ext is mandatory.";
557 557
     }
558 558
     
559
-    if (! $error)
559
+    if (!$error)
560 560
     {
561
-        $new_invoice=new Facture($db);
562
-        $new_invoice->socid=$invoice['thirdparty_id'];
563
-        $new_invoice->type=$invoice['type'];
564
-        $new_invoice->ref_ext=$invoice['ref_ext'];
565
-        $new_invoice->date=dol_stringtotime($invoice['date'],'dayrfc');
566
-        $new_invoice->note_private=$invoice['note_private'];
567
-        $new_invoice->note_public=$invoice['note_public'];
568
-        $new_invoice->statut= Facture::STATUS_DRAFT;	// We start with status draft
569
-        $new_invoice->fk_project=$invoice['project_id'];
570
-        $new_invoice->date_creation=$now;
561
+        $new_invoice = new Facture($db);
562
+        $new_invoice->socid = $invoice['thirdparty_id'];
563
+        $new_invoice->type = $invoice['type'];
564
+        $new_invoice->ref_ext = $invoice['ref_ext'];
565
+        $new_invoice->date = dol_stringtotime($invoice['date'], 'dayrfc');
566
+        $new_invoice->note_private = $invoice['note_private'];
567
+        $new_invoice->note_public = $invoice['note_public'];
568
+        $new_invoice->statut = Facture::STATUS_DRAFT; // We start with status draft
569
+        $new_invoice->fk_project = $invoice['project_id'];
570
+        $new_invoice->date_creation = $now;
571 571
         
572 572
 	//take mode_reglement and cond_reglement from thirdparty
573 573
         $soc = new Societe($db);
574
-        $res=$soc->fetch($new_invoice->socid);
574
+        $res = $soc->fetch($new_invoice->socid);
575 575
         if ($res > 0) {
576
-    	    $new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
576
+    	    $new_invoice->mode_reglement_id = !empty($invoice['payment_mode_id']) ? $invoice['payment_mode_id'] : $soc->mode_reglement_id;
577 577
             $new_invoice->cond_reglement_id  = $soc->cond_reglement_id; 
578 578
         }
579 579
         else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
580 580
 
581 581
         // Trick because nusoap does not store data with same structure if there is one or several lines
582
-        $arrayoflines=array();
583
-        if (isset($invoice['lines']['line'][0])) $arrayoflines=$invoice['lines']['line'];
584
-        else $arrayoflines=$invoice['lines'];
582
+        $arrayoflines = array();
583
+        if (isset($invoice['lines']['line'][0])) $arrayoflines = $invoice['lines']['line'];
584
+        else $arrayoflines = $invoice['lines'];
585 585
 
586
-        foreach($arrayoflines as $key => $line)
586
+        foreach ($arrayoflines as $key => $line)
587 587
         {
588 588
             // $key can be 'line' or '0','1',...
589
-            $newline=new FactureLigne($db);
590
-            $newline->product_type=$line['type'];
591
-            $newline->desc=$line['desc'];
592
-            $newline->fk_product=$line['fk_product'];
593
-            $newline->tva_tx=$line['vat_rate'];
594
-            $newline->qty=$line['qty'];
595
-            $newline->subprice=$line['unitprice'];
596
-            $newline->total_ht=$line['total_net'];
597
-            $newline->total_tva=$line['total_vat'];
598
-            $newline->total_ttc=$line['total'];
599
-            $newline->date_start=dol_stringtotime($line['date_start']);
600
-            $newline->date_end=dol_stringtotime($line['date_end']);
601
-            $newline->fk_product=$line['product_id'];
602
-            $new_invoice->lines[]=$newline;
589
+            $newline = new FactureLigne($db);
590
+            $newline->product_type = $line['type'];
591
+            $newline->desc = $line['desc'];
592
+            $newline->fk_product = $line['fk_product'];
593
+            $newline->tva_tx = $line['vat_rate'];
594
+            $newline->qty = $line['qty'];
595
+            $newline->subprice = $line['unitprice'];
596
+            $newline->total_ht = $line['total_net'];
597
+            $newline->total_tva = $line['total_vat'];
598
+            $newline->total_ttc = $line['total'];
599
+            $newline->date_start = dol_stringtotime($line['date_start']);
600
+            $newline->date_end = dol_stringtotime($line['date_end']);
601
+            $newline->fk_product = $line['product_id'];
602
+            $new_invoice->lines[] = $newline;
603 603
         }
604 604
         //var_dump($newobject->date_lim_reglement); exit;
605 605
         //var_dump($invoice['lines'][0]['type']);
606 606
 
607 607
         $db->begin();
608 608
 
609
-        $result=$new_invoice->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
609
+        $result = $new_invoice->create($fuser, 0, dol_stringtotime($invoice['date_due'], 'dayrfc'));
610 610
         if ($result < 0)
611 611
         {
612 612
             $error++;
@@ -614,25 +614,25 @@  discard block
 block discarded – undo
614 614
 
615 615
         if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED)   // We want invoice to have status validated
616 616
         {
617
-            $result=$new_invoice->validate($fuser);
617
+            $result = $new_invoice->validate($fuser);
618 618
             if ($result < 0)
619 619
             {
620 620
                 $error++;
621 621
             }
622 622
         }
623 623
 
624
-        if (! $error)
624
+        if (!$error)
625 625
         {
626 626
             $db->commit();
627
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
628
-            		'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
627
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$new_invoice->id,
628
+            		'ref'=>$new_invoice->ref, 'ref_ext'=>$new_invoice->ref_ext);
629 629
         }
630 630
         else
631 631
         {
632 632
             $db->rollback();
633 633
             $error++;
634
-            $errorcode='KO';
635
-            $errorlabel=$new_invoice->error;
634
+            $errorcode = 'KO';
635
+            $errorlabel = $new_invoice->error;
636 636
             dol_syslog("Function: createInvoice error while creating".$errorlabel);
637 637
         }
638 638
 
@@ -655,51 +655,51 @@  discard block
 block discarded – undo
655 655
  * @param	string      $ref_ext_order		ref_ext of order to copy invoice from
656 656
  * @return	array							Array result
657 657
  */
658
-function createInvoiceFromOrder($authentication,$id_order='', $ref_order='', $ref_ext_order='')
658
+function createInvoiceFromOrder($authentication, $id_order = '', $ref_order = '', $ref_ext_order = '')
659 659
 {
660
-	global $db,$conf;
660
+	global $db, $conf;
661 661
 
662
-	$now=dol_now();
662
+	$now = dol_now();
663 663
 
664 664
 	dol_syslog("Function: createInvoiceFromOrder login=".$authentication['login']." id=".$id_order.
665 665
 			", ref=".$ref_order.", ref_ext=".$ref_ext_order);
666 666
 
667
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
667
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
668 668
 
669 669
 	// Init and check authentication
670
-	$objectresp=array();
671
-	$errorcode='';$errorlabel='';
672
-	$error=0;
673
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
674
-    if ($fuser->socid) $socid=$fuser->socid;
670
+	$objectresp = array();
671
+	$errorcode = ''; $errorlabel = '';
672
+	$error = 0;
673
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
674
+    if ($fuser->socid) $socid = $fuser->socid;
675 675
 
676 676
 	// Check parameters
677
-	if (empty($id_order) && empty($ref_order) && empty($ref_ext_order))	{
678
-		$error++; $errorcode='KO'; $errorlabel="order id or ref or ref_ext is mandatory.";
677
+	if (empty($id_order) && empty($ref_order) && empty($ref_ext_order)) {
678
+		$error++; $errorcode = 'KO'; $errorlabel = "order id or ref or ref_ext is mandatory.";
679 679
 	}
680 680
 	
681 681
 	//////////////////////
682
-	if (! $error)
682
+	if (!$error)
683 683
 	{
684 684
 		$fuser->getrights();
685 685
 	
686 686
 		if ($fuser->rights->commande->lire)
687 687
 		{
688
-			$order=new Commande($db);
689
-			$result=$order->fetch($id_order,$ref_order,$ref_ext_order);
688
+			$order = new Commande($db);
689
+			$result = $order->fetch($id_order, $ref_order, $ref_ext_order);
690 690
 			if ($result > 0)
691 691
 			{
692 692
 				// Security for external user
693
-				if( $socid && ( $socid != $order->socid) )
693
+				if ($socid && ($socid != $order->socid))
694 694
 				{
695 695
 					$error++;
696
-					$errorcode='PERMISSION_DENIED'; $errorlabel=$order->socid.'User does not have permission for this request';
696
+					$errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.'User does not have permission for this request';
697 697
 				}
698 698
 	
699
-				if(!$error)
699
+				if (!$error)
700 700
 				{
701 701
 					
702
-					$newobject=new Facture($db);
702
+					$newobject = new Facture($db);
703 703
 					$result = $newobject->createFromOrder($order);
704 704
 					
705 705
 					if ($result < 0)
@@ -713,13 +713,13 @@  discard block
 block discarded – undo
713 713
 			else
714 714
 			{
715 715
 				$error++;
716
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id_order.' nor ref='.$ref_order.' nor ref_ext='.$ref_ext_order;
716
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id_order.' nor ref='.$ref_order.' nor ref_ext='.$ref_ext_order;
717 717
 			}
718 718
 		}
719 719
 		else
720 720
 		{
721 721
 			$error++;
722
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
722
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
723 723
 		}
724 724
 	}
725 725
 	
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	}
730 730
 	else
731 731
 	{
732
-		$objectresp= array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref,'ref_ext'=>$newobject->ref_ext);
732
+		$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref, 'ref_ext'=>$newobject->ref_ext);
733 733
 	}
734 734
 	
735 735
 	return $objectresp;
@@ -742,36 +742,36 @@  discard block
 block discarded – undo
742 742
  * @param	Facture		$invoice			Invoice
743 743
  * @return	array							Array result
744 744
  */
745
-function updateInvoice($authentication,$invoice)
745
+function updateInvoice($authentication, $invoice)
746 746
 {
747
-	global $db,$conf,$langs;
747
+	global $db, $conf, $langs;
748 748
 
749 749
 	dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id'].
750 750
     		", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
751 751
 
752
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
752
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
753 753
 
754 754
 	// Init and check authentication
755
-	$objectresp=array();
756
-	$errorcode='';$errorlabel='';
757
-	$error=0;
758
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
755
+	$objectresp = array();
756
+	$errorcode = ''; $errorlabel = '';
757
+	$error = 0;
758
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
759 759
 
760 760
 	// Check parameters
761
-	if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext']))	{
762
-		$error++; $errorcode='KO'; $errorlabel="Invoice id or ref or ref_ext is mandatory.";
761
+	if (empty($invoice['id']) && empty($invoice['ref']) && empty($invoice['ref_ext'])) {
762
+		$error++; $errorcode = 'KO'; $errorlabel = "Invoice id or ref or ref_ext is mandatory.";
763 763
 	}
764 764
 	
765
-	if (! $error)
765
+	if (!$error)
766 766
 	{
767
-		$objectfound=false;
767
+		$objectfound = false;
768 768
 	
769
-		$object=new Facture($db);
770
-		$result=$object->fetch($invoice['id'],$invoice['ref'],$invoice['ref_ext'], '');
769
+		$object = new Facture($db);
770
+		$result = $object->fetch($invoice['id'], $invoice['ref'], $invoice['ref_ext'], '');
771 771
 	
772 772
 		if (!empty($object->id)) {
773 773
 	
774
-			$objectfound=true;
774
+			$objectfound = true;
775 775
 	
776 776
 			$db->begin();
777 777
 	
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 				{
786 786
 					$result = $object->validate($fuser);
787 787
 						
788
-					if ($result	>= 0)
788
+					if ($result >= 0)
789 789
 					{
790 790
 						// Define output language
791 791
 						$outputlangs = $langs;
@@ -794,17 +794,17 @@  discard block
 block discarded – undo
794 794
 				}
795 795
 				if ($invoice['status'] == Facture::STATUS_CLOSED)
796 796
 				{
797
-					$result = $object->set_paid($fuser,$invoice->close_code,$invoice->close_note);			
797
+					$result = $object->set_paid($fuser, $invoice->close_code, $invoice->close_note);			
798 798
 				}
799 799
 				if ($invoice['status'] == Facture::STATUS_ABANDONED)
800
-					$result = $object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
800
+					$result = $object->set_canceled($fuser, $invoice->close_code, $invoice->close_note);
801 801
 			}
802 802
 		}
803 803
 	
804
-		if ((! $error) && ($objectfound))
804
+		if ((!$error) && ($objectfound))
805 805
 		{
806 806
 			$db->commit();
807
-			$objectresp=array(
807
+			$objectresp = array(
808 808
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
809 809
 					'id'=>$object->id,
810 810
 					'ref'=>$object->ref,
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
 		{
816 816
 			$db->rollback();
817 817
 			$error++;
818
-			$errorcode='KO';
819
-			$errorlabel=$object->error;
818
+			$errorcode = 'KO';
819
+			$errorlabel = $object->error;
820 820
 		} else {
821 821
 			$error++;
822
-			$errorcode='NOT_FOUND';
823
-			$errorlabel='Invoice id='.$invoice['id'].' ref='.$invoice['ref'].' ref_ext='.$invoice['ref_ext'].' cannot be found';
822
+			$errorcode = 'NOT_FOUND';
823
+			$errorlabel = 'Invoice id='.$invoice['id'].' ref='.$invoice['ref'].' ref_ext='.$invoice['ref_ext'].' cannot be found';
824 824
 		}
825 825
 	}
826 826
 	
Please login to merge, or discard this patch.
htdocs/webservices/server_actioncomm.php 3 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 // Enable and test if module web services is enabled
40 40
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
41 41
 {
42
-    $langs->load("admin");
43
-    dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
-    print $langs->trans("ToActivateModule");
46
-    exit;
42
+	$langs->load("admin");
43
+	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
+	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
+	print $langs->trans("ToActivateModule");
46
+	exit;
47 47
 }
48 48
 
49 49
 // Create the soap Object
@@ -57,36 +57,36 @@  discard block
 block discarded – undo
57 57
 
58 58
 // Define WSDL Authentication object
59 59
 $server->wsdl->addComplexType(
60
-    'authentication',
61
-    'complexType',
62
-    'struct',
63
-    'all',
64
-    '',
65
-    array(
66
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
67
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
68
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
69
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
70
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
71
-    )
60
+	'authentication',
61
+	'complexType',
62
+	'struct',
63
+	'all',
64
+	'',
65
+	array(
66
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
67
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
68
+		'login' => array('name'=>'login','type'=>'xsd:string'),
69
+		'password' => array('name'=>'password','type'=>'xsd:string'),
70
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
71
+	)
72 72
 );
73 73
 
74 74
 // Define WSDL Return object
75 75
 $server->wsdl->addComplexType(
76
-    'result',
77
-    'complexType',
78
-    'struct',
79
-    'all',
80
-    '',
81
-    array(
82
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
84
-    )
76
+	'result',
77
+	'complexType',
78
+	'struct',
79
+	'all',
80
+	'',
81
+	array(
82
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
84
+	)
85 85
 );
86 86
 
87 87
 
88 88
 $actioncomm_fields= array(
89
-    'id' => array('name'=>'id','type'=>'xsd:string'),
89
+	'id' => array('name'=>'id','type'=>'xsd:string'),
90 90
 	'ref' => array('name'=>'ref','type'=>'xsd:string'),
91 91
 	'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
92 92
 	'type_id' => array('name'=>'type_id','type'=>'xsd:string'),
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 
132 132
 // Define other specific objects
133 133
 $server->wsdl->addComplexType(
134
-    'actioncomm',
135
-    'complexType',
136
-    'struct',
137
-    'all',
138
-    '',
134
+	'actioncomm',
135
+	'complexType',
136
+	'struct',
137
+	'all',
138
+	'',
139 139
 	$actioncomm_fields
140 140
 );
141 141
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	'sequence',
160 160
 	'',
161 161
 	 array(
162
-        'actioncommtype' => array(
163
-            'name' => 'actioncommtype',
164
-            'type' => 'tns:actioncommtype',
165
-            'minOccurs' => '0',
166
-            'maxOccurs' => 'unbounded'
167
-        )
162
+		'actioncommtype' => array(
163
+			'name' => 'actioncommtype',
164
+			'type' => 'tns:actioncommtype',
165
+			'minOccurs' => '0',
166
+			'maxOccurs' => 'unbounded'
167
+		)
168 168
 	)
169 169
 );
170 170
 
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
 
194 194
 // Register WSDL
195 195
 $server->register(
196
-    'getActionComm',
197
-    // Entry values
198
-    array('authentication'=>'tns:authentication','id'=>'xsd:string'),
199
-    // Exit values
200
-    array('result'=>'tns:result','actioncomm'=>'tns:actioncomm'),
201
-    $ns,
202
-    $ns.'#getActionComm',
203
-    $styledoc,
204
-    $styleuse,
205
-    'WS to get actioncomm'
196
+	'getActionComm',
197
+	// Entry values
198
+	array('authentication'=>'tns:authentication','id'=>'xsd:string'),
199
+	// Exit values
200
+	array('result'=>'tns:result','actioncomm'=>'tns:actioncomm'),
201
+	$ns,
202
+	$ns.'#getActionComm',
203
+	$styledoc,
204
+	$styleuse,
205
+	'WS to get actioncomm'
206 206
 );
207 207
 
208 208
 // Register WSDL
@@ -245,97 +245,97 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function getActionComm($authentication,$id)
247 247
 {
248
-    global $db,$conf,$langs;
249
-
250
-    dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id);
251
-
252
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
253
-
254
-    // Init and check authentication
255
-    $objectresp=array();
256
-    $errorcode='';$errorlabel='';
257
-    $error=0;
258
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
259
-    // Check parameters
260
-    if ($error || (! $id))
261
-    {
262
-        $error++;
263
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
264
-    }
265
-
266
-    if (! $error)
267
-    {
268
-        $fuser->getrights();
269
-
270
-        if ($fuser->rights->agenda->allactions->read)
271
-        {
272
-            $actioncomm=new ActionComm($db);
273
-            $result=$actioncomm->fetch($id);
274
-            if ($result > 0)
275
-            {
276
-
277
-            	$actioncomm_result_fields=array(
248
+	global $db,$conf,$langs;
249
+
250
+	dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id);
251
+
252
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
253
+
254
+	// Init and check authentication
255
+	$objectresp=array();
256
+	$errorcode='';$errorlabel='';
257
+	$error=0;
258
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
259
+	// Check parameters
260
+	if ($error || (! $id))
261
+	{
262
+		$error++;
263
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
264
+	}
265
+
266
+	if (! $error)
267
+	{
268
+		$fuser->getrights();
269
+
270
+		if ($fuser->rights->agenda->allactions->read)
271
+		{
272
+			$actioncomm=new ActionComm($db);
273
+			$result=$actioncomm->fetch($id);
274
+			if ($result > 0)
275
+			{
276
+
277
+				$actioncomm_result_fields=array(
278 278
 						'id' => $actioncomm->id,
279 279
 						'ref'=> $actioncomm->ref,
280
-			        	'ref_ext'=> $actioncomm->ref_ext,
281
-			        	'type_id'=> $actioncomm->type_id,
282
-			        	'type_code'=> $actioncomm->type_code,
283
-			        	'type'=> $actioncomm->type,
284
-			        	'label'=> $actioncomm->label,
285
-			        	'datep'=> dol_print_date($actioncomm->datep,'dayhourrfc'),
286
-			        	'datef'=> dol_print_date($actioncomm->datef,'dayhourrfc'),
287
-			        	'datec'=> dol_print_date($actioncomm->datec,'dayhourrfc'),
288
-			        	'datem'=> dol_print_date($actioncomm->datem,'dayhourrfc'),
289
-			        	'note'=> $actioncomm->note,
290
-			        	'percentage'=> $actioncomm->percentage,
291
-			        	'author'=> $actioncomm->authorid,
292
-			        	'usermod'=> $actioncomm->usermodid,
293
-			        	'userownerid'=> $actioncomm->userownerid,
294
-			        	'priority'=> $actioncomm->priority,
295
-			        	'fulldayevent'=> $actioncomm->fulldayevent,
296
-			        	'location'=> $actioncomm->location,
297
-			        	'socid'=> $actioncomm->socid,
298
-			        	'contactid'=> $actioncomm->contactid,
299
-			        	'projectid'=> $actioncomm->fk_project,
300
-			        	'fk_element'=> $actioncomm->fk_element,
301
-			        	'elementtype'=> $actioncomm->elementtype);
302
-
303
-			        	//Retreive all extrafield for actioncomm
304
-			        	// fetch optionals attributes and labels
305
-			        	$extrafields=new ExtraFields($db);
306
-			        	$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
307
-			        	//Get extrafield values
308
-			        	$actioncomm->fetch_optionals($actioncomm->id,$extralabels);
309
-
310
-			        	foreach($extrafields->attribute_label as $key=>$label)
311
-			        	{
312
-			        		$actioncomm_result_fields=array_merge($actioncomm_result_fields,array('options_'.$key => $actioncomm->array_options['options_'.$key]));
313
-			        	}
314
-
315
-                // Create
316
-                $objectresp = array(
317
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
318
-			        'actioncomm'=>$actioncomm_result_fields);
319
-            }
320
-            else
321
-            {
322
-                $error++;
323
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
324
-            }
325
-        }
326
-        else
327
-        {
328
-            $error++;
329
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
330
-        }
331
-    }
332
-
333
-    if ($error)
334
-    {
335
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
336
-    }
337
-
338
-    return $objectresp;
280
+						'ref_ext'=> $actioncomm->ref_ext,
281
+						'type_id'=> $actioncomm->type_id,
282
+						'type_code'=> $actioncomm->type_code,
283
+						'type'=> $actioncomm->type,
284
+						'label'=> $actioncomm->label,
285
+						'datep'=> dol_print_date($actioncomm->datep,'dayhourrfc'),
286
+						'datef'=> dol_print_date($actioncomm->datef,'dayhourrfc'),
287
+						'datec'=> dol_print_date($actioncomm->datec,'dayhourrfc'),
288
+						'datem'=> dol_print_date($actioncomm->datem,'dayhourrfc'),
289
+						'note'=> $actioncomm->note,
290
+						'percentage'=> $actioncomm->percentage,
291
+						'author'=> $actioncomm->authorid,
292
+						'usermod'=> $actioncomm->usermodid,
293
+						'userownerid'=> $actioncomm->userownerid,
294
+						'priority'=> $actioncomm->priority,
295
+						'fulldayevent'=> $actioncomm->fulldayevent,
296
+						'location'=> $actioncomm->location,
297
+						'socid'=> $actioncomm->socid,
298
+						'contactid'=> $actioncomm->contactid,
299
+						'projectid'=> $actioncomm->fk_project,
300
+						'fk_element'=> $actioncomm->fk_element,
301
+						'elementtype'=> $actioncomm->elementtype);
302
+
303
+						//Retreive all extrafield for actioncomm
304
+						// fetch optionals attributes and labels
305
+						$extrafields=new ExtraFields($db);
306
+						$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
307
+						//Get extrafield values
308
+						$actioncomm->fetch_optionals($actioncomm->id,$extralabels);
309
+
310
+						foreach($extrafields->attribute_label as $key=>$label)
311
+						{
312
+							$actioncomm_result_fields=array_merge($actioncomm_result_fields,array('options_'.$key => $actioncomm->array_options['options_'.$key]));
313
+						}
314
+
315
+				// Create
316
+				$objectresp = array(
317
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
318
+					'actioncomm'=>$actioncomm_result_fields);
319
+			}
320
+			else
321
+			{
322
+				$error++;
323
+				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
324
+			}
325
+		}
326
+		else
327
+		{
328
+			$error++;
329
+			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
330
+		}
331
+	}
332
+
333
+	if ($error)
334
+	{
335
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
336
+	}
337
+
338
+	return $objectresp;
339 339
 }
340 340
 
341 341
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 				}
376 376
 
377 377
 				 $objectresp = array(
378
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
379
-			        'actioncommtypes'=>$resultarray);
378
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
379
+					'actioncommtypes'=>$resultarray);
380 380
 
381 381
 			}
382 382
 			else
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
  *       \brief      File that is entry point to call Dolibarr WebServices
24 24
  */
25 25
 
26
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
26
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
27 27
 
28 28
 require_once("../master.inc.php");
29
-require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
29
+require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
30 30
 require_once(DOL_DOCUMENT_ROOT."/core/lib/ws.lib.php");
31 31
 
32 32
 require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php");
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 {
42 42
     $langs->load("admin");
43 43
     dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
44
+    print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
45 45
     print $langs->trans("ToActivateModule");
46 46
     exit;
47 47
 }
48 48
 
49 49
 // Create the soap Object
50 50
 $server = new nusoap_server();
51
-$server->soap_defencoding='UTF-8';
52
-$server->decode_utf8=false;
53
-$ns='http://www.dolibarr.org/ns/';
54
-$server->configureWSDL('WebServicesDolibarrActionComm',$ns);
55
-$server->wsdl->schemaTargetNamespace=$ns;
51
+$server->soap_defencoding = 'UTF-8';
52
+$server->decode_utf8 = false;
53
+$ns = 'http://www.dolibarr.org/ns/';
54
+$server->configureWSDL('WebServicesDolibarrActionComm', $ns);
55
+$server->wsdl->schemaTargetNamespace = $ns;
56 56
 
57 57
 
58 58
 // Define WSDL Authentication object
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
     'all',
64 64
     '',
65 65
     array(
66
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
67
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
68
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
69
-    	'password' => array('name'=>'password','type'=>'xsd:string'),
70
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
66
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
67
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
68
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
69
+    	'password' => array('name'=>'password', 'type'=>'xsd:string'),
70
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
71 71
     )
72 72
 );
73 73
 
@@ -79,55 +79,55 @@  discard block
 block discarded – undo
79 79
     'all',
80 80
     '',
81 81
     array(
82
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
83
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
82
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
83
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
84 84
     )
85 85
 );
86 86
 
87 87
 
88
-$actioncomm_fields= array(
89
-    'id' => array('name'=>'id','type'=>'xsd:string'),
90
-	'ref' => array('name'=>'ref','type'=>'xsd:string'),
91
-	'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
92
-	'type_id' => array('name'=>'type_id','type'=>'xsd:string'),
93
-	'type_code' => array('name'=>'type_code','type'=>'xsd:string'),
94
-	'type' => array('name'=>'type','type'=>'xsd:string'),
95
-	'label' => array('name'=>'label','type'=>'xsd:string'),
96
-	'datep' => array('name'=>'datep','type'=>'xsd:dateTime'),
97
-	'datef' => array('name'=>'datef','type'=>'xsd:dateTime'),
98
-	'datec' => array('name'=>'datec','type'=>'xsd:dateTime'),
99
-	'datem' => array('name'=>'datem','type'=>'xsd:dateTime'),
100
-	'note' => array('name'=>'note','type'=>'xsd:string'),
101
-	'percentage' => array('name'=>'percentage','type'=>'xsd:string'),
102
-	'author' => array('name'=>'author','type'=>'xsd:string'),
103
-	'usermod' => array('name'=>'usermod','type'=>'xsd:string'),
104
-	'userownerid' => array('name'=>'userownerid','type'=>'xsd:string'),
105
-	'priority' => array('name'=>'priority','type'=>'xsd:string'),
106
-	'fulldayevent' => array('name'=>'fulldayevent','type'=>'xsd:string'),
107
-	'location' => array('name'=>'location','type'=>'xsd:string'),
108
-	'socid' => array('name'=>'socid','type'=>'xsd:string'),
109
-	'contactid' => array('name'=>'contactid','type'=>'xsd:string'),
110
-	'projectid' => array('name'=>'projectid','type'=>'xsd:string'),
111
-	'fk_element' => array('name'=>'fk_element','type'=>'xsd:string'),
112
-	'elementtype' => array('name'=>'elementtype','type'=>'xsd:string'));
88
+$actioncomm_fields = array(
89
+    'id' => array('name'=>'id', 'type'=>'xsd:string'),
90
+	'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
91
+	'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
92
+	'type_id' => array('name'=>'type_id', 'type'=>'xsd:string'),
93
+	'type_code' => array('name'=>'type_code', 'type'=>'xsd:string'),
94
+	'type' => array('name'=>'type', 'type'=>'xsd:string'),
95
+	'label' => array('name'=>'label', 'type'=>'xsd:string'),
96
+	'datep' => array('name'=>'datep', 'type'=>'xsd:dateTime'),
97
+	'datef' => array('name'=>'datef', 'type'=>'xsd:dateTime'),
98
+	'datec' => array('name'=>'datec', 'type'=>'xsd:dateTime'),
99
+	'datem' => array('name'=>'datem', 'type'=>'xsd:dateTime'),
100
+	'note' => array('name'=>'note', 'type'=>'xsd:string'),
101
+	'percentage' => array('name'=>'percentage', 'type'=>'xsd:string'),
102
+	'author' => array('name'=>'author', 'type'=>'xsd:string'),
103
+	'usermod' => array('name'=>'usermod', 'type'=>'xsd:string'),
104
+	'userownerid' => array('name'=>'userownerid', 'type'=>'xsd:string'),
105
+	'priority' => array('name'=>'priority', 'type'=>'xsd:string'),
106
+	'fulldayevent' => array('name'=>'fulldayevent', 'type'=>'xsd:string'),
107
+	'location' => array('name'=>'location', 'type'=>'xsd:string'),
108
+	'socid' => array('name'=>'socid', 'type'=>'xsd:string'),
109
+	'contactid' => array('name'=>'contactid', 'type'=>'xsd:string'),
110
+	'projectid' => array('name'=>'projectid', 'type'=>'xsd:string'),
111
+	'fk_element' => array('name'=>'fk_element', 'type'=>'xsd:string'),
112
+	'elementtype' => array('name'=>'elementtype', 'type'=>'xsd:string'));
113 113
 
114 114
 //Retreive all extrafield for actioncomm
115 115
 // fetch optionals attributes and labels
116
-$extrafields=new ExtraFields($db);
117
-$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
118
-if (count($extrafields)>0) {
116
+$extrafields = new ExtraFields($db);
117
+$extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
118
+if (count($extrafields) > 0) {
119 119
 	$extrafield_array = array();
120 120
 }
121
-foreach($extrafields->attribute_label as $key=>$label)
121
+foreach ($extrafields->attribute_label as $key=>$label)
122 122
 {
123
-	$type =$extrafields->attribute_type[$key];
124
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
125
-	else {$type='xsd:string';}
123
+	$type = $extrafields->attribute_type[$key];
124
+	if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
125
+	else {$type = 'xsd:string'; }
126 126
 
127
-	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
127
+	$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
128 128
 }
129 129
 
130
-$actioncomm_fields=array_merge($actioncomm_fields,$extrafield_array);
130
+$actioncomm_fields = array_merge($actioncomm_fields, $extrafield_array);
131 131
 
132 132
 // Define other specific objects
133 133
 $server->wsdl->addComplexType(
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	'sequence',
148 148
 	'',
149 149
 	array(
150
-	'code' => array('name'=>'code','type'=>'xsd:string'),
151
-	'libelle' => array('name'=>'libelle','type'=>'xsd:string')
150
+	'code' => array('name'=>'code', 'type'=>'xsd:string'),
151
+	'libelle' => array('name'=>'libelle', 'type'=>'xsd:string')
152 152
 	)
153 153
 );
154 154
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
173 173
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
174 174
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
175
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
176
-$styleuse='encoded';   // encoded/literal/literal wrapped
175
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
176
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
177 177
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
178 178
 
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	// Entry values
184 184
 	array('authentication'=>'tns:authentication'),
185 185
 	// Exit values
186
-	array('result'=>'tns:result','actioncommtypes'=>'tns:actioncommtypes'),
186
+	array('result'=>'tns:result', 'actioncommtypes'=>'tns:actioncommtypes'),
187 187
 	$ns,
188 188
 	$ns.'#getListActionCommType',
189 189
 	$styledoc,
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 $server->register(
196 196
     'getActionComm',
197 197
     // Entry values
198
-    array('authentication'=>'tns:authentication','id'=>'xsd:string'),
198
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string'),
199 199
     // Exit values
200
-    array('result'=>'tns:result','actioncomm'=>'tns:actioncomm'),
200
+    array('result'=>'tns:result', 'actioncomm'=>'tns:actioncomm'),
201 201
     $ns,
202 202
     $ns.'#getActionComm',
203 203
     $styledoc,
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 $server->register(
210 210
 	'createActionComm',
211 211
 	// Entry values
212
-	array('authentication'=>'tns:authentication','actioncomm'=>'tns:actioncomm'),
212
+	array('authentication'=>'tns:authentication', 'actioncomm'=>'tns:actioncomm'),
213 213
 	// Exit values
214
-	array('result'=>'tns:result','id'=>'xsd:string'),
214
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
215 215
 	$ns,
216 216
 	$ns.'#createActionComm',
217 217
 	$styledoc,
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 $server->register(
224 224
 	'updateActionComm',
225 225
 	// Entry values
226
-	array('authentication'=>'tns:authentication','actioncomm'=>'tns:actioncomm'),
226
+	array('authentication'=>'tns:authentication', 'actioncomm'=>'tns:actioncomm'),
227 227
 	// Exit values
228
-	array('result'=>'tns:result','id'=>'xsd:string'),
228
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
229 229
 	$ns,
230 230
 	$ns.'#updateActionComm',
231 231
 	$styledoc,
@@ -243,38 +243,38 @@  discard block
 block discarded – undo
243 243
  * @param	int			$id					Id of object
244 244
  * @return	mixed
245 245
  */
246
-function getActionComm($authentication,$id)
246
+function getActionComm($authentication, $id)
247 247
 {
248
-    global $db,$conf,$langs;
248
+    global $db, $conf, $langs;
249 249
 
250 250
     dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id);
251 251
 
252
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
252
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
253 253
 
254 254
     // Init and check authentication
255
-    $objectresp=array();
256
-    $errorcode='';$errorlabel='';
257
-    $error=0;
258
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
255
+    $objectresp = array();
256
+    $errorcode = ''; $errorlabel = '';
257
+    $error = 0;
258
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
259 259
     // Check parameters
260
-    if ($error || (! $id))
260
+    if ($error || (!$id))
261 261
     {
262 262
         $error++;
263
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
263
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
264 264
     }
265 265
 
266
-    if (! $error)
266
+    if (!$error)
267 267
     {
268 268
         $fuser->getrights();
269 269
 
270 270
         if ($fuser->rights->agenda->allactions->read)
271 271
         {
272
-            $actioncomm=new ActionComm($db);
273
-            $result=$actioncomm->fetch($id);
272
+            $actioncomm = new ActionComm($db);
273
+            $result = $actioncomm->fetch($id);
274 274
             if ($result > 0)
275 275
             {
276 276
 
277
-            	$actioncomm_result_fields=array(
277
+            	$actioncomm_result_fields = array(
278 278
 						'id' => $actioncomm->id,
279 279
 						'ref'=> $actioncomm->ref,
280 280
 			        	'ref_ext'=> $actioncomm->ref_ext,
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 			        	'type_code'=> $actioncomm->type_code,
283 283
 			        	'type'=> $actioncomm->type,
284 284
 			        	'label'=> $actioncomm->label,
285
-			        	'datep'=> dol_print_date($actioncomm->datep,'dayhourrfc'),
286
-			        	'datef'=> dol_print_date($actioncomm->datef,'dayhourrfc'),
287
-			        	'datec'=> dol_print_date($actioncomm->datec,'dayhourrfc'),
288
-			        	'datem'=> dol_print_date($actioncomm->datem,'dayhourrfc'),
285
+			        	'datep'=> dol_print_date($actioncomm->datep, 'dayhourrfc'),
286
+			        	'datef'=> dol_print_date($actioncomm->datef, 'dayhourrfc'),
287
+			        	'datec'=> dol_print_date($actioncomm->datec, 'dayhourrfc'),
288
+			        	'datem'=> dol_print_date($actioncomm->datem, 'dayhourrfc'),
289 289
 			        	'note'=> $actioncomm->note,
290 290
 			        	'percentage'=> $actioncomm->percentage,
291 291
 			        	'author'=> $actioncomm->authorid,
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 
303 303
 			        	//Retreive all extrafield for actioncomm
304 304
 			        	// fetch optionals attributes and labels
305
-			        	$extrafields=new ExtraFields($db);
306
-			        	$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
305
+			        	$extrafields = new ExtraFields($db);
306
+			        	$extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
307 307
 			        	//Get extrafield values
308
-			        	$actioncomm->fetch_optionals($actioncomm->id,$extralabels);
308
+			        	$actioncomm->fetch_optionals($actioncomm->id, $extralabels);
309 309
 
310
-			        	foreach($extrafields->attribute_label as $key=>$label)
310
+			        	foreach ($extrafields->attribute_label as $key=>$label)
311 311
 			        	{
312
-			        		$actioncomm_result_fields=array_merge($actioncomm_result_fields,array('options_'.$key => $actioncomm->array_options['options_'.$key]));
312
+			        		$actioncomm_result_fields = array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key]));
313 313
 			        	}
314 314
 
315 315
                 // Create
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
             else
321 321
             {
322 322
                 $error++;
323
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
323
+                $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
324 324
             }
325 325
         }
326 326
         else
327 327
         {
328 328
             $error++;
329
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
329
+            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
330 330
         }
331 331
     }
332 332
 
@@ -347,31 +347,31 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function getListActionCommType($authentication)
349 349
 {
350
-	global $db,$conf,$langs;
350
+	global $db, $conf, $langs;
351 351
 
352 352
 	dol_syslog("Function: getListActionCommType login=".$authentication['login']);
353 353
 
354
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
354
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
355 355
 
356 356
 	// Init and check authentication
357
-	$objectresp=array();
358
-	$errorcode='';$errorlabel='';
359
-	$error=0;
360
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
357
+	$objectresp = array();
358
+	$errorcode = ''; $errorlabel = '';
359
+	$error = 0;
360
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
361 361
 
362
-	if (! $error)
362
+	if (!$error)
363 363
 	{
364 364
 		$fuser->getrights();
365 365
 
366 366
 		if ($fuser->rights->agenda->myactions->read)
367 367
 		{
368
-			$cactioncomm=new CActionComm($db);
369
-			$result=$cactioncomm->liste_array('','code');
368
+			$cactioncomm = new CActionComm($db);
369
+			$result = $cactioncomm->liste_array('', 'code');
370 370
 			if ($result > 0)
371 371
 			{
372
-				$resultarray=array();
373
-				foreach($cactioncomm->liste_array as $code=>$libeller) {
374
-					$resultarray[]=array('code'=>$code,'libelle'=>$libeller);
372
+				$resultarray = array();
373
+				foreach ($cactioncomm->liste_array as $code=>$libeller) {
374
+					$resultarray[] = array('code'=>$code, 'libelle'=>$libeller);
375 375
 				}
376 376
 
377 377
 				 $objectresp = array(
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 			else
383 383
 			{
384 384
 				$error++;
385
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
385
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
386 386
 			}
387 387
 		}
388 388
 		else
389 389
 		{
390 390
 			$error++;
391
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
391
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
392 392
 		}
393 393
 	}
394 394
 
@@ -408,71 +408,71 @@  discard block
 block discarded – undo
408 408
  * @param	ActionComm	$actioncomm		    $actioncomm
409 409
  * @return	array							Array result
410 410
  */
411
-function createActionComm($authentication,$actioncomm)
411
+function createActionComm($authentication, $actioncomm)
412 412
 {
413
-	global $db,$conf,$langs;
413
+	global $db, $conf, $langs;
414 414
 
415
-	$now=dol_now();
415
+	$now = dol_now();
416 416
 
417 417
 	dol_syslog("Function: createActionComm login=".$authentication['login']);
418 418
 
419
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
419
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
420 420
 
421 421
 	// Init and check authentication
422
-	$objectresp=array();
423
-	$errorcode='';$errorlabel='';
424
-	$error=0;
425
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
422
+	$objectresp = array();
423
+	$errorcode = ''; $errorlabel = '';
424
+	$error = 0;
425
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
426 426
 
427
-	if (! $error)
427
+	if (!$error)
428 428
 	{
429
-		$newobject=new ActionComm($db);
430
-
431
-		$newobject->datep=$actioncomm['datep'];
432
-		$newobject->datef=$actioncomm['datef'];
433
-		$newobject->type_code=$actioncomm['type_code'];
434
-		$newobject->socid=$actioncomm['socid'];
435
-		$newobject->fk_project=$actioncomm['projectid'];
436
-		$newobject->note=$actioncomm['note'];
437
-		$newobject->contactid=$actioncomm['contactid'];
438
-		$newobject->userownerid=$actioncomm['userownerid'];
439
-		$newobject->label=$actioncomm['label'];
440
-		$newobject->percentage=$actioncomm['percentage'];
441
-		$newobject->priority=$actioncomm['priority'];
442
-		$newobject->fulldayevent=$actioncomm['fulldayevent'];
443
-		$newobject->location=$actioncomm['location'];
444
-		$newobject->fk_element=$actioncomm['fk_element'];
445
-		$newobject->elementtype=$actioncomm['elementtype'];
429
+		$newobject = new ActionComm($db);
430
+
431
+		$newobject->datep = $actioncomm['datep'];
432
+		$newobject->datef = $actioncomm['datef'];
433
+		$newobject->type_code = $actioncomm['type_code'];
434
+		$newobject->socid = $actioncomm['socid'];
435
+		$newobject->fk_project = $actioncomm['projectid'];
436
+		$newobject->note = $actioncomm['note'];
437
+		$newobject->contactid = $actioncomm['contactid'];
438
+		$newobject->userownerid = $actioncomm['userownerid'];
439
+		$newobject->label = $actioncomm['label'];
440
+		$newobject->percentage = $actioncomm['percentage'];
441
+		$newobject->priority = $actioncomm['priority'];
442
+		$newobject->fulldayevent = $actioncomm['fulldayevent'];
443
+		$newobject->location = $actioncomm['location'];
444
+		$newobject->fk_element = $actioncomm['fk_element'];
445
+		$newobject->elementtype = $actioncomm['elementtype'];
446 446
 
447 447
 		//Retreive all extrafield for actioncomm
448 448
 		// fetch optionals attributes and labels
449
-		$extrafields=new ExtraFields($db);
450
-		$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
451
-		foreach($extrafields->attribute_label as $key=>$label)
449
+		$extrafields = new ExtraFields($db);
450
+		$extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
451
+		foreach ($extrafields->attribute_label as $key=>$label)
452 452
 		{
453
-			$key='options_'.$key;
454
-			$newobject->array_options[$key]=$actioncomm[$key];
453
+			$key = 'options_'.$key;
454
+			$newobject->array_options[$key] = $actioncomm[$key];
455 455
 		}
456 456
 
457 457
 		$db->begin();
458 458
 
459
-		$result=$newobject->create($fuser);
459
+		$result = $newobject->create($fuser);
460 460
 		if ($result <= 0)
461 461
 		{
462 462
 			$error++;
463 463
 		}
464 464
 
465
-		if (! $error)
465
+		if (!$error)
466 466
 		{
467 467
 			$db->commit();
468
-			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id);
468
+			$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id);
469 469
 		}
470 470
 		else
471 471
 		{
472 472
 			$db->rollback();
473 473
 			$error++;
474
-			$errorcode='KO';
475
-			$errorlabel=$newobject->error;
474
+			$errorcode = 'KO';
475
+			$errorlabel = $newobject->error;
476 476
 		}
477 477
 	}
478 478
 
@@ -491,75 +491,75 @@  discard block
 block discarded – undo
491 491
  * @param	ActionComm	$actioncomm		    $actioncomm
492 492
  * @return	array							Array result
493 493
  */
494
-function updateActionComm($authentication,$actioncomm)
494
+function updateActionComm($authentication, $actioncomm)
495 495
 {
496
-	global $db,$conf,$langs;
496
+	global $db, $conf, $langs;
497 497
 
498
-	$now=dol_now();
498
+	$now = dol_now();
499 499
 
500 500
 	dol_syslog("Function: updateActionComm login=".$authentication['login']);
501 501
 
502
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
502
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
503 503
 
504 504
 	// Init and check authentication
505
-	$objectresp=array();
506
-	$errorcode='';$errorlabel='';
507
-	$error=0;
508
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
505
+	$objectresp = array();
506
+	$errorcode = ''; $errorlabel = '';
507
+	$error = 0;
508
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
509 509
 	// Check parameters
510
-	if (empty($actioncomm['id']))	{
511
-		$error++; $errorcode='KO'; $errorlabel="Actioncomm id is mandatory.";
510
+	if (empty($actioncomm['id'])) {
511
+		$error++; $errorcode = 'KO'; $errorlabel = "Actioncomm id is mandatory.";
512 512
 	}
513 513
 
514
-	if (! $error)
514
+	if (!$error)
515 515
 	{
516
-		$objectfound=false;
516
+		$objectfound = false;
517 517
 
518
-		$object=new ActionComm($db);
519
-		$result=$object->fetch($actioncomm['id']);
518
+		$object = new ActionComm($db);
519
+		$result = $object->fetch($actioncomm['id']);
520 520
 
521 521
 		if (!empty($object->id)) {
522 522
 
523
-			$objectfound=true;
524
-
525
-			$object->datep=$actioncomm['datep'];
526
-			$object->datef=$actioncomm['datef'];
527
-			$object->type_code=$actioncomm['type_code'];
528
-			$object->socid=$actioncomm['socid'];
529
-			$object->contactid=$actioncomm['contactid'];
530
-			$object->fk_project=$actioncomm['projectid'];
531
-			$object->note=$actioncomm['note'];
532
-			$object->userownerid=$actioncomm['userownerid'];
533
-			$object->label=$actioncomm['label'];
534
-			$object->percentage=$actioncomm['percentage'];
535
-			$object->priority=$actioncomm['priority'];
536
-			$object->fulldayevent=$actioncomm['fulldayevent'];
537
-			$object->location=$actioncomm['location'];
538
-			$object->fk_element=$actioncomm['fk_element'];
539
-			$object->elementtype=$actioncomm['elementtype'];
523
+			$objectfound = true;
524
+
525
+			$object->datep = $actioncomm['datep'];
526
+			$object->datef = $actioncomm['datef'];
527
+			$object->type_code = $actioncomm['type_code'];
528
+			$object->socid = $actioncomm['socid'];
529
+			$object->contactid = $actioncomm['contactid'];
530
+			$object->fk_project = $actioncomm['projectid'];
531
+			$object->note = $actioncomm['note'];
532
+			$object->userownerid = $actioncomm['userownerid'];
533
+			$object->label = $actioncomm['label'];
534
+			$object->percentage = $actioncomm['percentage'];
535
+			$object->priority = $actioncomm['priority'];
536
+			$object->fulldayevent = $actioncomm['fulldayevent'];
537
+			$object->location = $actioncomm['location'];
538
+			$object->fk_element = $actioncomm['fk_element'];
539
+			$object->elementtype = $actioncomm['elementtype'];
540 540
 
541 541
 			//Retreive all extrafield for actioncomm
542 542
 			// fetch optionals attributes and labels
543
-			$extrafields=new ExtraFields($db);
544
-			$extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true);
545
-			foreach($extrafields->attribute_label as $key=>$label)
543
+			$extrafields = new ExtraFields($db);
544
+			$extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
545
+			foreach ($extrafields->attribute_label as $key=>$label)
546 546
 			{
547
-				$key='options_'.$key;
548
-				$object->array_options[$key]=$actioncomm[$key];
547
+				$key = 'options_'.$key;
548
+				$object->array_options[$key] = $actioncomm[$key];
549 549
 			}
550 550
 
551 551
 			$db->begin();
552 552
 
553
-			$result=$object->update($fuser);
553
+			$result = $object->update($fuser);
554 554
 			if ($result <= 0) {
555 555
 				$error++;
556 556
 			}
557 557
 		}
558 558
 
559
-		if ((! $error) && ($objectfound))
559
+		if ((!$error) && ($objectfound))
560 560
 		{
561 561
 			$db->commit();
562
-			$objectresp=array(
562
+			$objectresp = array(
563 563
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
564 564
 					'id'=>$object->id
565 565
 			);
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 		{
569 569
 			$db->rollback();
570 570
 			$error++;
571
-			$errorcode='KO';
572
-			$errorlabel=$object->error;
571
+			$errorcode = 'KO';
572
+			$errorlabel = $object->error;
573 573
 		} else {
574 574
 			$error++;
575
-			$errorcode='NOT_FOUND';
576
-			$errorlabel='Actioncomm id='.$actioncomm['id'].' cannot be found';
575
+			$errorcode = 'NOT_FOUND';
576
+			$errorlabel = 'Actioncomm id='.$actioncomm['id'].' cannot be found';
577 577
 		}
578 578
 	}
579 579
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -19 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
  *       \brief      File that is entry point to call Dolibarr WebServices
24 24
  */
25 25
 
26
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
26
+if (! defined("NOCSRFCHECK")) {
27
+	define("NOCSRFCHECK",'1');
28
+}
27 29
 
28 30
 require_once("../master.inc.php");
29 31
 require_once(NUSOAP_PATH.'/nusoap.php');		// Include SOAP
@@ -121,8 +123,7 @@  discard block
 block discarded – undo
121 123
 foreach($extrafields->attribute_label as $key=>$label)
122 124
 {
123 125
 	$type =$extrafields->attribute_type[$key];
124
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
125
-	else {$type='xsd:string';}
126
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
126 127
 
127 128
 	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
128 129
 }
@@ -249,7 +250,9 @@  discard block
 block discarded – undo
249 250
 
250 251
     dol_syslog("Function: getActionComm login=".$authentication['login']." id=".$id);
251 252
 
252
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
253
+    if ($authentication['entity']) {
254
+    	$conf->entity=$authentication['entity'];
255
+    }
253 256
 
254 257
     // Init and check authentication
255 258
     $objectresp=array();
@@ -316,14 +319,12 @@  discard block
 block discarded – undo
316 319
                 $objectresp = array(
317 320
 			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
318 321
 			        'actioncomm'=>$actioncomm_result_fields);
319
-            }
320
-            else
322
+            } else
321 323
             {
322 324
                 $error++;
323 325
                 $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
324 326
             }
325
-        }
326
-        else
327
+        } else
327 328
         {
328 329
             $error++;
329 330
             $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -351,7 +352,9 @@  discard block
 block discarded – undo
351 352
 
352 353
 	dol_syslog("Function: getListActionCommType login=".$authentication['login']);
353 354
 
354
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
355
+	if ($authentication['entity']) {
356
+		$conf->entity=$authentication['entity'];
357
+	}
355 358
 
356 359
 	// Init and check authentication
357 360
 	$objectresp=array();
@@ -378,14 +381,12 @@  discard block
 block discarded – undo
378 381
 			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
379 382
 			        'actioncommtypes'=>$resultarray);
380 383
 
381
-			}
382
-			else
384
+			} else
383 385
 			{
384 386
 				$error++;
385 387
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
386 388
 			}
387
-		}
388
-		else
389
+		} else
389 390
 		{
390 391
 			$error++;
391 392
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -416,7 +417,9 @@  discard block
 block discarded – undo
416 417
 
417 418
 	dol_syslog("Function: createActionComm login=".$authentication['login']);
418 419
 
419
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
420
+	if ($authentication['entity']) {
421
+		$conf->entity=$authentication['entity'];
422
+	}
420 423
 
421 424
 	// Init and check authentication
422 425
 	$objectresp=array();
@@ -466,8 +469,7 @@  discard block
 block discarded – undo
466 469
 		{
467 470
 			$db->commit();
468 471
 			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id);
469
-		}
470
-		else
472
+		} else
471 473
 		{
472 474
 			$db->rollback();
473 475
 			$error++;
@@ -499,7 +501,9 @@  discard block
 block discarded – undo
499 501
 
500 502
 	dol_syslog("Function: updateActionComm login=".$authentication['login']);
501 503
 
502
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
504
+	if ($authentication['entity']) {
505
+		$conf->entity=$authentication['entity'];
506
+	}
503 507
 
504 508
 	// Init and check authentication
505 509
 	$objectresp=array();
@@ -563,8 +567,7 @@  discard block
 block discarded – undo
563 567
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
564 568
 					'id'=>$object->id
565 569
 			);
566
-		}
567
-		elseif ($objectfound)
570
+		} elseif ($objectfound)
568 571
 		{
569 572
 			$db->rollback();
570 573
 			$error++;
Please login to merge, or discard this patch.
htdocs/webservices/server_productorservice.php 3 patches
Indentation   +587 added lines, -587 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 // Enable and test if module web services is enabled
45 45
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
46 46
 {
47
-    $langs->load("admin");
48
-    dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
50
-    print $langs->trans("ToActivateModule");
51
-    exit;
47
+	$langs->load("admin");
48
+	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
+	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
50
+	print $langs->trans("ToActivateModule");
51
+	exit;
52 52
 }
53 53
 
54 54
 // Create the soap Object
@@ -62,72 +62,72 @@  discard block
 block discarded – undo
62 62
 
63 63
 // Define WSDL Authentication object
64 64
 $server->wsdl->addComplexType(
65
-    'authentication',
66
-    'complexType',
67
-    'struct',
68
-    'all',
69
-    '',
70
-    array(
71
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
74
-        'password' => array('name'=>'password','type'=>'xsd:string'),
75
-        'entity' => array('name'=>'entity','type'=>'xsd:string')
76
-    )
65
+	'authentication',
66
+	'complexType',
67
+	'struct',
68
+	'all',
69
+	'',
70
+	array(
71
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
+		'login' => array('name'=>'login','type'=>'xsd:string'),
74
+		'password' => array('name'=>'password','type'=>'xsd:string'),
75
+		'entity' => array('name'=>'entity','type'=>'xsd:string')
76
+	)
77 77
 );
78 78
 // Define WSDL Return object
79 79
 $server->wsdl->addComplexType(
80
-    'result',
81
-    'complexType',
82
-    'struct',
83
-    'all',
84
-    '',
85
-    array(
86
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
87
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string')
88
-    )
80
+	'result',
81
+	'complexType',
82
+	'struct',
83
+	'all',
84
+	'',
85
+	array(
86
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
87
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string')
88
+	)
89 89
 );
90 90
 
91 91
 $productorservice_fields = array(
92
-    'id' => array('name'=>'id','type'=>'xsd:string'),
93
-    'ref' => array('name'=>'ref','type'=>'xsd:string'),
94
-    'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
95
-    'type' => array('name'=>'type','type'=>'xsd:string'),
96
-    'label' => array('name'=>'label','type'=>'xsd:string'),
97
-    'description' => array('name'=>'description','type'=>'xsd:string'),
98
-    'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
-    'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
-    'note' => array('name'=>'note','type'=>'xsd:string'),
101
-    'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
102
-    'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
103
-    'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
104
-    'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
105
-    'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
106
-    'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
107
-    'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
108
-
109
-    'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
110
-    'price' => array('name'=>'price','type'=>'xsd:string'),
111
-    'price_min_net' => array('name'=>'price_min_net','type'=>'xsd:string'),
112
-    'price_min' => array('name'=>'price_min','type'=>'xsd:string'),
113
-
114
-    'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
115
-
116
-    'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:string'),
117
-    'vat_npr' => array('name'=>'vat_npr','type'=>'xsd:string'),
118
-    'localtax1_tx' => array('name'=>'localtax1_tx','type'=>'xsd:string'),
119
-    'localtax2_tx' => array('name'=>'localtax2_tx','type'=>'xsd:string'),
120
-
121
-    'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
122
-    'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
123
-    'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
124
-    'warehouse_ref' => array('name'=>'warehouse_ref','type'=>'xsd:string'),		// Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database
125
-
126
-    'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
127
-    'import_key' => array('name'=>'import_key','type'=>'xsd:string'),
128
-
129
-    'dir' => array('name'=>'dir','type'=>'xsd:string'),
130
-    'images' => array('name'=>'images','type'=>'tns:ImagesArray')
92
+	'id' => array('name'=>'id','type'=>'xsd:string'),
93
+	'ref' => array('name'=>'ref','type'=>'xsd:string'),
94
+	'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
95
+	'type' => array('name'=>'type','type'=>'xsd:string'),
96
+	'label' => array('name'=>'label','type'=>'xsd:string'),
97
+	'description' => array('name'=>'description','type'=>'xsd:string'),
98
+	'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
+	'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
+	'note' => array('name'=>'note','type'=>'xsd:string'),
101
+	'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
102
+	'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
103
+	'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
104
+	'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
105
+	'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
106
+	'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
107
+	'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
108
+
109
+	'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
110
+	'price' => array('name'=>'price','type'=>'xsd:string'),
111
+	'price_min_net' => array('name'=>'price_min_net','type'=>'xsd:string'),
112
+	'price_min' => array('name'=>'price_min','type'=>'xsd:string'),
113
+
114
+	'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
115
+
116
+	'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:string'),
117
+	'vat_npr' => array('name'=>'vat_npr','type'=>'xsd:string'),
118
+	'localtax1_tx' => array('name'=>'localtax1_tx','type'=>'xsd:string'),
119
+	'localtax2_tx' => array('name'=>'localtax2_tx','type'=>'xsd:string'),
120
+
121
+	'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
122
+	'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
123
+	'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
124
+	'warehouse_ref' => array('name'=>'warehouse_ref','type'=>'xsd:string'),		// Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database
125
+
126
+	'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
127
+	'import_key' => array('name'=>'import_key','type'=>'xsd:string'),
128
+
129
+	'dir' => array('name'=>'dir','type'=>'xsd:string'),
130
+	'images' => array('name'=>'images','type'=>'tns:ImagesArray')
131 131
 );
132 132
 
133 133
 //Retreive all extrafield for product
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 
151 151
 // Define other specific objects
152 152
 $server->wsdl->addComplexType(
153
-    'product',
154
-    'complexType',
155
-    'struct',
156
-    'all',
157
-    '',
158
-    $productorservice_fields
153
+	'product',
154
+	'complexType',
155
+	'struct',
156
+	'all',
157
+	'',
158
+	$productorservice_fields
159 159
 );
160 160
 
161 161
 
@@ -198,33 +198,33 @@  discard block
 block discarded – undo
198 198
 
199 199
 // Define other specific objects
200 200
 $server->wsdl->addComplexType(
201
-    'filterproduct',
202
-    'complexType',
203
-    'struct',
204
-    'all',
205
-    '',
206
-    array(
207
-        //'limit' => array('name'=>'limit','type'=>'xsd:string'),
201
+	'filterproduct',
202
+	'complexType',
203
+	'struct',
204
+	'all',
205
+	'',
206
+	array(
207
+		//'limit' => array('name'=>'limit','type'=>'xsd:string'),
208 208
 		'type' => array('name'=>'type','type'=>'xsd:string'),
209
-	    'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
210
-	    'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
211
-    )
209
+		'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
210
+		'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
211
+	)
212 212
 );
213 213
 
214 214
 $server->wsdl->addComplexType(
215
-    'ProductsArray2',
216
-    'complexType',
217
-    'array',
218
-    'sequence',
219
-    '',
220
-    array(
221
-        'product' => array(
222
-            'name' => 'product',
223
-            'type' => 'tns:product',
224
-            'minOccurs' => '0',
225
-            'maxOccurs' => 'unbounded'
226
-        )
227
-    )
215
+	'ProductsArray2',
216
+	'complexType',
217
+	'array',
218
+	'sequence',
219
+	'',
220
+	array(
221
+		'product' => array(
222
+			'name' => 'product',
223
+			'type' => 'tns:product',
224
+			'minOccurs' => '0',
225
+			'maxOccurs' => 'unbounded'
226
+		)
227
+	)
228 228
 );
229 229
 
230 230
 
@@ -239,72 +239,72 @@  discard block
 block discarded – undo
239 239
 
240 240
 // Register WSDL
241 241
 $server->register(
242
-    'getProductOrService',
243
-    // Entry values
244
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string','lang'=>'xsd:string'),
245
-    // Exit values
246
-    array('result'=>'tns:result','product'=>'tns:product'),
247
-    $ns,
248
-    $ns.'#getProductOrService',
249
-    $styledoc,
250
-    $styleuse,
251
-    'WS to get product or service'
242
+	'getProductOrService',
243
+	// Entry values
244
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string','lang'=>'xsd:string'),
245
+	// Exit values
246
+	array('result'=>'tns:result','product'=>'tns:product'),
247
+	$ns,
248
+	$ns.'#getProductOrService',
249
+	$styledoc,
250
+	$styleuse,
251
+	'WS to get product or service'
252 252
 );
253 253
 
254 254
 // Register WSDL
255 255
 $server->register(
256
-    'createProductOrService',
257
-    // Entry values
258
-    array('authentication'=>'tns:authentication','product'=>'tns:product'),
259
-    // Exit values
260
-    array('result'=>'tns:result','id'=>'xsd:string'),
261
-    $ns,
262
-    $ns.'#createProductOrService',
263
-    $styledoc,
264
-    $styleuse,
265
-    'WS to create a product or service'
256
+	'createProductOrService',
257
+	// Entry values
258
+	array('authentication'=>'tns:authentication','product'=>'tns:product'),
259
+	// Exit values
260
+	array('result'=>'tns:result','id'=>'xsd:string'),
261
+	$ns,
262
+	$ns.'#createProductOrService',
263
+	$styledoc,
264
+	$styleuse,
265
+	'WS to create a product or service'
266 266
 );
267 267
 
268 268
 // Register WSDL
269 269
 $server->register(
270
-    'updateProductOrService',
271
-    // Entry values
272
-    array('authentication'=>'tns:authentication','product'=>'tns:product'),
273
-    // Exit values
274
-    array('result'=>'tns:result','id'=>'xsd:string'),
275
-    $ns,
276
-    $ns.'#updateProductOrService',
277
-    $styledoc,
278
-    $styleuse,
279
-    'WS to update a product or service'
270
+	'updateProductOrService',
271
+	// Entry values
272
+	array('authentication'=>'tns:authentication','product'=>'tns:product'),
273
+	// Exit values
274
+	array('result'=>'tns:result','id'=>'xsd:string'),
275
+	$ns,
276
+	$ns.'#updateProductOrService',
277
+	$styledoc,
278
+	$styleuse,
279
+	'WS to update a product or service'
280 280
 );
281 281
 
282 282
 // Register WSDL
283 283
 $server->register(
284
-    'deleteProductOrService',
285
-    // Entry values
286
-    array('authentication'=>'tns:authentication','listofid'=>'xsd:string'),
287
-    // Exit values
288
-    array('result'=>'tns:result','nbdeleted'=>'xsd:int'),
289
-    $ns,
290
-    $ns.'#deleteProductOrService',
291
-    $styledoc,
292
-    $styleuse,
293
-    'WS to delete a product or service'
284
+	'deleteProductOrService',
285
+	// Entry values
286
+	array('authentication'=>'tns:authentication','listofid'=>'xsd:string'),
287
+	// Exit values
288
+	array('result'=>'tns:result','nbdeleted'=>'xsd:int'),
289
+	$ns,
290
+	$ns.'#deleteProductOrService',
291
+	$styledoc,
292
+	$styleuse,
293
+	'WS to delete a product or service'
294 294
 );
295 295
 
296 296
 // Register WSDL
297 297
 $server->register(
298
-    'getListOfProductsOrServices',
299
-    // Entry values
300
-    array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'),
301
-    // Exit values
302
-    array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
303
-    $ns,
304
-    $ns.'#getListOfProductsOrServices',
305
-    $styledoc,
306
-    $styleuse,
307
-    'WS to get list of all products or services id and ref'
298
+	'getListOfProductsOrServices',
299
+	// Entry values
300
+	array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'),
301
+	// Exit values
302
+	array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
303
+	$ns,
304
+	$ns.'#getListOfProductsOrServices',
305
+	$styledoc,
306
+	$styleuse,
307
+	'WS to get list of all products or services id and ref'
308 308
 );
309 309
 
310 310
 // Register WSDL
@@ -334,128 +334,128 @@  discard block
 block discarded – undo
334 334
  */
335 335
 function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='')
336 336
 {
337
-    global $db,$conf,$langs;
337
+	global $db,$conf,$langs;
338 338
 
339
-    dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
339
+	dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
340 340
 
341
-    $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
342
-    $langs->setDefaultLang($langcode);
341
+	$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
342
+	$langs->setDefaultLang($langcode);
343 343
 
344
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
344
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
345 345
 
346
-    // Init and check authentication
347
-    $objectresp=array();
348
-    $errorcode='';$errorlabel='';
349
-    $error=0;
350
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
351
-    // Check parameters
352
-    if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
353
-    {
354
-        $error++;
355
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
356
-    }
346
+	// Init and check authentication
347
+	$objectresp=array();
348
+	$errorcode='';$errorlabel='';
349
+	$error=0;
350
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
351
+	// Check parameters
352
+	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
353
+	{
354
+		$error++;
355
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
356
+	}
357
+
358
+	if (! $error)
359
+	{
357 360
 
358
-    if (! $error)
359
-    {
361
+		$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
362
+		$langs->setDefaultLang($langcode);
360 363
 
361
-    	$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
362
-    	$langs->setDefaultLang($langcode);
364
+		$fuser->getrights();
363 365
 
364
-        $fuser->getrights();
366
+		if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
367
+		{
368
+			$product=new Product($db);
369
+			$result=$product->fetch($id,$ref,$ref_ext);
365 370
 
366
-        if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
367
-        {
368
-            $product=new Product($db);
369
-            $result=$product->fetch($id,$ref,$ref_ext);
370
-
371
-            if ($result > 0)
372
-            {
373
-            	$product->load_stock();
374
-
375
-            	$dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output);
376
-            	$pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/";
377
-            	$dir = $dir . '/'. $pdir;
378
-
379
-            	if (! empty($product->multilangs[$langs->defaultlang]["label"]))     		$product->label =  $product->multilangs[$langs->defaultlang]["label"];
380
-            	if (! empty($product->multilangs[$langs->defaultlang]["description"]))     	$product->description =  $product->multilangs[$langs->defaultlang]["description"];
381
-            	if (! empty($product->multilangs[$langs->defaultlang]["note"]))     		$product->note =  $product->multilangs[$langs->defaultlang]["note"];
382
-
383
-            	$productorservice_result_fields = array(
384
-	            	'id' => $product->id,
385
-	            	'ref' => $product->ref,
386
-	            	'ref_ext' => $product->ref_ext,
387
-	            	'label' => $product->label,
388
-	            	'description' => $product->description,
389
-	            	'date_creation' => dol_print_date($product->date_creation,'dayhourrfc'),
390
-	            	'date_modification' => dol_print_date($product->date_modification,'dayhourrfc'),
391
-	            	'note' => $product->note,
392
-	            	'status_tosell' => $product->status,
393
-	            	'status_tobuy' => $product->status_buy,
394
-	            	'type' => $product->type,
395
-	            	'barcode' => $product->barcode,
396
-	            	'barcode_type' => $product->barcode_type,
397
-	            	'country_id' => $product->country_id>0?$product->country_id:'',
398
-	            	'country_code' => $product->country_code,
399
-	            	'custom_code' => $product->customcode,
400
-
401
-	            	'price_net' => $product->price,
402
-	            	'price' => $product->price_ttc,
403
-	            	'price_min_net' => $product->price_min,
404
-	            	'price_min' => $product->price_min_ttc,
405
-	            	'price_base_type' => $product->price_base_type,
406
-	            	'vat_rate' => $product->tva_tx,
407
-	            	//! French VAT NPR
408
-	            	'vat_npr' => $product->tva_npr,
409
-	            	//! Spanish local taxes
410
-	            	'localtax1_tx' => $product->localtax1_tx,
411
-	            	'localtax2_tx' => $product->localtax2_tx,
412
-
413
-            	    'stock_real' => $product->stock_reel,
414
-            	    'stock_virtual' => $product->stock_theorique,
415
-	            	'stock_alert' => $product->seuil_stock_alerte,
416
-	            	'pmp' => $product->pmp,
417
-	            	'import_key' => $product->import_key,
418
-	            	'dir' => $pdir,
419
-	            	'images' => $product->liste_photos($dir,$nbmax=10)
420
-            	);
421
-
422
-                //Retreive all extrafield for thirdsparty
423
-            	// fetch optionals attributes and labels
424
-            	$extrafields=new ExtraFields($db);
425
-            	$extralabels=$extrafields->fetch_name_optionals_label('product',true);
426
-            	//Get extrafield values
427
-            	$product->fetch_optionals($product->id,$extralabels);
428
-
429
-            	foreach($extrafields->attribute_label as $key=>$label)
430
-            	{
431
-            		$productorservice_result_fields=array_merge($productorservice_result_fields,array('options_'.$key => $product->array_options['options_'.$key]));
432
-            	}
433
-
434
-                // Create
435
-                $objectresp = array(
436
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
437
-			        'product'=>$productorservice_result_fields
438
-                );
439
-            }
440
-            else
441
-            {
442
-                $error++;
443
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
444
-            }
445
-        }
446
-        else
447
-        {
448
-            $error++;
449
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
450
-        }
451
-    }
452
-
453
-    if ($error)
454
-    {
455
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
456
-    }
371
+			if ($result > 0)
372
+			{
373
+				$product->load_stock();
374
+
375
+				$dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output);
376
+				$pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/";
377
+				$dir = $dir . '/'. $pdir;
378
+
379
+				if (! empty($product->multilangs[$langs->defaultlang]["label"]))     		$product->label =  $product->multilangs[$langs->defaultlang]["label"];
380
+				if (! empty($product->multilangs[$langs->defaultlang]["description"]))     	$product->description =  $product->multilangs[$langs->defaultlang]["description"];
381
+				if (! empty($product->multilangs[$langs->defaultlang]["note"]))     		$product->note =  $product->multilangs[$langs->defaultlang]["note"];
382
+
383
+				$productorservice_result_fields = array(
384
+					'id' => $product->id,
385
+					'ref' => $product->ref,
386
+					'ref_ext' => $product->ref_ext,
387
+					'label' => $product->label,
388
+					'description' => $product->description,
389
+					'date_creation' => dol_print_date($product->date_creation,'dayhourrfc'),
390
+					'date_modification' => dol_print_date($product->date_modification,'dayhourrfc'),
391
+					'note' => $product->note,
392
+					'status_tosell' => $product->status,
393
+					'status_tobuy' => $product->status_buy,
394
+					'type' => $product->type,
395
+					'barcode' => $product->barcode,
396
+					'barcode_type' => $product->barcode_type,
397
+					'country_id' => $product->country_id>0?$product->country_id:'',
398
+					'country_code' => $product->country_code,
399
+					'custom_code' => $product->customcode,
400
+
401
+					'price_net' => $product->price,
402
+					'price' => $product->price_ttc,
403
+					'price_min_net' => $product->price_min,
404
+					'price_min' => $product->price_min_ttc,
405
+					'price_base_type' => $product->price_base_type,
406
+					'vat_rate' => $product->tva_tx,
407
+					//! French VAT NPR
408
+					'vat_npr' => $product->tva_npr,
409
+					//! Spanish local taxes
410
+					'localtax1_tx' => $product->localtax1_tx,
411
+					'localtax2_tx' => $product->localtax2_tx,
412
+
413
+					'stock_real' => $product->stock_reel,
414
+					'stock_virtual' => $product->stock_theorique,
415
+					'stock_alert' => $product->seuil_stock_alerte,
416
+					'pmp' => $product->pmp,
417
+					'import_key' => $product->import_key,
418
+					'dir' => $pdir,
419
+					'images' => $product->liste_photos($dir,$nbmax=10)
420
+				);
421
+
422
+				//Retreive all extrafield for thirdsparty
423
+				// fetch optionals attributes and labels
424
+				$extrafields=new ExtraFields($db);
425
+				$extralabels=$extrafields->fetch_name_optionals_label('product',true);
426
+				//Get extrafield values
427
+				$product->fetch_optionals($product->id,$extralabels);
428
+
429
+				foreach($extrafields->attribute_label as $key=>$label)
430
+				{
431
+					$productorservice_result_fields=array_merge($productorservice_result_fields,array('options_'.$key => $product->array_options['options_'.$key]));
432
+				}
433
+
434
+				// Create
435
+				$objectresp = array(
436
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
437
+					'product'=>$productorservice_result_fields
438
+				);
439
+			}
440
+			else
441
+			{
442
+				$error++;
443
+				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
444
+			}
445
+		}
446
+		else
447
+		{
448
+			$error++;
449
+			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
450
+		}
451
+	}
452
+
453
+	if ($error)
454
+	{
455
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
456
+	}
457 457
 	//var_dump($objectresp);exit;
458
-    return $objectresp;
458
+	return $objectresp;
459 459
 }
460 460
 
461 461
 
@@ -468,54 +468,54 @@  discard block
 block discarded – undo
468 468
  */
469 469
 function createProductOrService($authentication,$product)
470 470
 {
471
-    global $db,$conf,$langs;
471
+	global $db,$conf,$langs;
472 472
 
473
-    $now=dol_now();
473
+	$now=dol_now();
474 474
 
475
-    dol_syslog("Function: createProductOrService login=".$authentication['login']);
475
+	dol_syslog("Function: createProductOrService login=".$authentication['login']);
476 476
 
477
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
477
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
478 478
 
479
-    // Init and check authentication
480
-    $objectresp=array();
481
-    $errorcode='';$errorlabel='';
482
-    $error=0;
483
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
484
-    // Check parameters
485
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
486
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
479
+	// Init and check authentication
480
+	$objectresp=array();
481
+	$errorcode='';$errorlabel='';
482
+	$error=0;
483
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
484
+	// Check parameters
485
+	if ($product['price_net'] > 0) $product['price_base_type']='HT';
486
+	if ($product['price'] > 0)     $product['price_base_type']='TTC';
487 487
 
488
-    if ($product['price_net'] > 0 && $product['price'] > 0)
489
-    {
490
-        $error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
491
-    }
488
+	if ($product['price_net'] > 0 && $product['price'] > 0)
489
+	{
490
+		$error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
491
+	}
492 492
 
493
-    if ($product['barcode'] && !$product['barcode_type'])
494
-    {
493
+	if ($product['barcode'] && !$product['barcode_type'])
494
+	{
495 495
 	$errror++; $errorcode='KO' ; $errorlabel="You must set a barcode type when setting a barcode.";
496
-    }
497
-
498
-
499
-
500
-    if (! $error)
501
-    {
502
-        include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
503
-
504
-        $newobject=new Product($db);
505
-        $newobject->ref=$product['ref'];
506
-        $newobject->ref_ext=$product['ref_ext'];
507
-        $newobject->type=$product['type'];
508
-        $newobject->libelle=$product['label'];    // @deprecated
509
-        $newobject->label=$product['label'];
510
-        $newobject->description=$product['description'];
511
-        $newobject->note=$product['note'];
512
-        $newobject->status=$product['status_tosell'];
513
-        $newobject->status_buy=$product['status_tobuy'];
514
-        $newobject->price=$product['price_net'];
515
-        $newobject->price_ttc=$product['price'];
516
-        $newobject->tva_tx=$product['vat_rate'];
517
-        $newobject->price_base_type=$product['price_base_type'];
518
-        $newobject->date_creation=$now;
496
+	}
497
+
498
+
499
+
500
+	if (! $error)
501
+	{
502
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
503
+
504
+		$newobject=new Product($db);
505
+		$newobject->ref=$product['ref'];
506
+		$newobject->ref_ext=$product['ref_ext'];
507
+		$newobject->type=$product['type'];
508
+		$newobject->libelle=$product['label'];    // @deprecated
509
+		$newobject->label=$product['label'];
510
+		$newobject->description=$product['description'];
511
+		$newobject->note=$product['note'];
512
+		$newobject->status=$product['status_tosell'];
513
+		$newobject->status_buy=$product['status_tobuy'];
514
+		$newobject->price=$product['price_net'];
515
+		$newobject->price_ttc=$product['price'];
516
+		$newobject->tva_tx=$product['vat_rate'];
517
+		$newobject->price_base_type=$product['price_base_type'];
518
+		$newobject->date_creation=$now;
519 519
 
520 520
 		if ($product['barcode'])
521 521
 		{
@@ -523,16 +523,16 @@  discard block
 block discarded – undo
523 523
 			$newobject->barcode_type = $product['barcode_type'];
524 524
 		}
525 525
 
526
-        $newobject->stock_reel=$product['stock_real'];
527
-        $newobject->pmp=$product['pmp'];
528
-        $newobject->seuil_stock_alert=$product['stock_alert'];
526
+		$newobject->stock_reel=$product['stock_real'];
527
+		$newobject->pmp=$product['pmp'];
528
+		$newobject->seuil_stock_alert=$product['stock_alert'];
529 529
 
530
-        $newobject->country_id=$product['country_id'];
531
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
532
-        $newobject->customcode=$product['customcode'];
530
+		$newobject->country_id=$product['country_id'];
531
+		if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
532
+		$newobject->customcode=$product['customcode'];
533 533
 
534
-        $newobject->canvas=$product['canvas'];
535
-        /*foreach($product['lines'] as $line)
534
+		$newobject->canvas=$product['canvas'];
535
+		/*foreach($product['lines'] as $line)
536 536
         {
537 537
             $newline=new FactureLigne($db);
538 538
             $newline->type=$line['type'];
@@ -545,10 +545,10 @@  discard block
 block discarded – undo
545 545
             $newline->qty=$line['qty'];
546 546
             $newline->fk_product=$line['product_id'];
547 547
         }*/
548
-        //var_dump($product['ref_ext']);
549
-        //var_dump($product['lines'][0]['type']);
548
+		//var_dump($product['ref_ext']);
549
+		//var_dump($product['lines'][0]['type']);
550 550
 
551
-        $extrafields=new ExtraFields($db);
551
+		$extrafields=new ExtraFields($db);
552 552
 		$extralabels=$extrafields->fetch_name_optionals_label('product',true);
553 553
 		foreach($extrafields->attribute_label as $key=>$label)
554 554
 		{
@@ -556,17 +556,17 @@  discard block
 block discarded – undo
556 556
 			$newobject->array_options[$key]=$product[$key];
557 557
 		}
558 558
 
559
-        $db->begin();
559
+		$db->begin();
560 560
 
561
-        $result=$newobject->create($fuser,0);
562
-        if ($result <= 0)
563
-        {
564
-            $error++;
565
-        }
561
+		$result=$newobject->create($fuser,0);
562
+		if ($result <= 0)
563
+		{
564
+			$error++;
565
+		}
566 566
 
567
-        if (! $error)
568
-        {
569
-        	// Update stock if stock count is provided and differs from database after creation or update
567
+		if (! $error)
568
+		{
569
+			// Update stock if stock count is provided and differs from database after creation or update
570 570
 			if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled))
571 571
 			{
572 572
 				require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
@@ -604,27 +604,27 @@  discard block
 block discarded – undo
604 604
 			}
605 605
 		}
606 606
 
607
-        if (! $error)
608
-        {
609
-            $db->commit();
610
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
611
-        }
612
-        else
613
-        {
614
-            $db->rollback();
615
-            $error++;
616
-            $errorcode='KO';
617
-            $errorlabel=$newobject->error;
618
-        }
607
+		if (! $error)
608
+		{
609
+			$db->commit();
610
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
611
+		}
612
+		else
613
+		{
614
+			$db->rollback();
615
+			$error++;
616
+			$errorcode='KO';
617
+			$errorlabel=$newobject->error;
618
+		}
619 619
 
620
-    }
620
+	}
621 621
 
622
-    if ($error)
623
-    {
624
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
625
-    }
622
+	if ($error)
623
+	{
624
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
625
+	}
626 626
 
627
-    return $objectresp;
627
+	return $objectresp;
628 628
 }
629 629
 
630 630
 
@@ -637,72 +637,72 @@  discard block
 block discarded – undo
637 637
  */
638 638
 function updateProductOrService($authentication,$product)
639 639
 {
640
-    global $db,$conf,$langs;
641
-
642
-    $now=dol_now();
643
-
644
-    dol_syslog("Function: updateProductOrService login=".$authentication['login']);
645
-
646
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
647
-
648
-    // Init and check authentication
649
-    $objectresp=array();
650
-    $errorcode='';$errorlabel='';
651
-    $error=0;
652
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
653
-    // Check parameters
654
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
655
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
656
-
657
-    if ($product['price_net'] > 0 && $product['price'] > 0)
658
-    {
659
-        $error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
660
-    }
661
-
662
-
663
-    if ($product['barcode'] && !$product['barcode_type'])
664
-    {
665
-        $errror++; $errorcode='KO' ; $errorlabel="You must set a barcode type when setting a barcode.";
666
-    }
667
-
668
-    if (! $error)
669
-    {
670
-        include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
671
-
672
-        $newobject=new Product($db);
673
-        $newobject->fetch($product['id']);
674
-
675
-        if (isset($product['ref']))     $newobject->ref=$product['ref'];
676
-        if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext'];
677
-        $newobject->type=$product['type'];
678
-        $newobject->libelle=$product['label'];    // @deprecated
679
-        $newobject->label=$product['label'];
680
-        $newobject->description=$product['description'];
681
-        $newobject->note=$product['note'];
682
-        $newobject->status=$product['status_tosell'];
683
-        $newobject->status_buy=$product['status_tobuy'];
684
-        $newobject->price=$product['price_net'];
685
-        $newobject->price_ttc=$product['price'];
686
-        $newobject->tva_tx=$product['vat_rate'];
687
-        $newobject->price_base_type=$product['price_base_type'];
688
-        $newobject->date_creation=$now;
689
-
690
-        if ($product['barcode'])
691
-        {
692
-                $newobject->barcode = $product['barcode'];
693
-                $newobject->barcode_type = $product['barcode_type'];
694
-        }
640
+	global $db,$conf,$langs;
641
+
642
+	$now=dol_now();
643
+
644
+	dol_syslog("Function: updateProductOrService login=".$authentication['login']);
645
+
646
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
647
+
648
+	// Init and check authentication
649
+	$objectresp=array();
650
+	$errorcode='';$errorlabel='';
651
+	$error=0;
652
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
653
+	// Check parameters
654
+	if ($product['price_net'] > 0) $product['price_base_type']='HT';
655
+	if ($product['price'] > 0)     $product['price_base_type']='TTC';
656
+
657
+	if ($product['price_net'] > 0 && $product['price'] > 0)
658
+	{
659
+		$error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
660
+	}
661
+
695 662
 
696
-        $newobject->stock_reel=$product['stock_real'];
697
-        $newobject->pmp=$product['pmp'];
698
-        $newobject->seuil_stock_alert=$product['stock_alert'];
663
+	if ($product['barcode'] && !$product['barcode_type'])
664
+	{
665
+		$errror++; $errorcode='KO' ; $errorlabel="You must set a barcode type when setting a barcode.";
666
+	}
699 667
 
700
-        $newobject->country_id=$product['country_id'];
701
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
702
-        $newobject->customcode=$product['customcode'];
668
+	if (! $error)
669
+	{
670
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
671
+
672
+		$newobject=new Product($db);
673
+		$newobject->fetch($product['id']);
674
+
675
+		if (isset($product['ref']))     $newobject->ref=$product['ref'];
676
+		if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext'];
677
+		$newobject->type=$product['type'];
678
+		$newobject->libelle=$product['label'];    // @deprecated
679
+		$newobject->label=$product['label'];
680
+		$newobject->description=$product['description'];
681
+		$newobject->note=$product['note'];
682
+		$newobject->status=$product['status_tosell'];
683
+		$newobject->status_buy=$product['status_tobuy'];
684
+		$newobject->price=$product['price_net'];
685
+		$newobject->price_ttc=$product['price'];
686
+		$newobject->tva_tx=$product['vat_rate'];
687
+		$newobject->price_base_type=$product['price_base_type'];
688
+		$newobject->date_creation=$now;
703 689
 
704
-        $newobject->canvas=$product['canvas'];
705
-        /*foreach($product['lines'] as $line)
690
+		if ($product['barcode'])
691
+		{
692
+				$newobject->barcode = $product['barcode'];
693
+				$newobject->barcode_type = $product['barcode_type'];
694
+		}
695
+
696
+		$newobject->stock_reel=$product['stock_real'];
697
+		$newobject->pmp=$product['pmp'];
698
+		$newobject->seuil_stock_alert=$product['stock_alert'];
699
+
700
+		$newobject->country_id=$product['country_id'];
701
+		if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
702
+		$newobject->customcode=$product['customcode'];
703
+
704
+		$newobject->canvas=$product['canvas'];
705
+		/*foreach($product['lines'] as $line)
706 706
         {
707 707
             $newline=new FactureLigne($db);
708 708
             $newline->type=$line['type'];
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
             $newline->qty=$line['qty'];
716 716
             $newline->fk_product=$line['product_id'];
717 717
         }*/
718
-        //var_dump($product['ref_ext']);
719
-        //var_dump($product['lines'][0]['type']);
718
+		//var_dump($product['ref_ext']);
719
+		//var_dump($product['lines'][0]['type']);
720 720
 
721 721
 		$extrafields=new ExtraFields($db);
722 722
 		$extralabels=$extrafields->fetch_name_optionals_label('product',true);
@@ -726,16 +726,16 @@  discard block
 block discarded – undo
726 726
 			$newobject->array_options[$key]=$product[$key];
727 727
 		}
728 728
 
729
-        $db->begin();
729
+		$db->begin();
730 730
 
731
-        $result=$newobject->update($newobject->id,$fuser);
732
-        if ($result <= 0)
733
-        {
734
-            $error++;
735
-        }
736
-        else
731
+		$result=$newobject->update($newobject->id,$fuser);
732
+		if ($result <= 0)
733
+		{
734
+			$error++;
735
+		}
736
+		else
737 737
 		{
738
-        	// Update stock if stock count is provided and differs from database after creation or update
738
+			// Update stock if stock count is provided and differs from database after creation or update
739 739
 			if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled))
740 740
 			{
741 741
 				require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
@@ -771,49 +771,49 @@  discard block
 block discarded – undo
771 771
 					}
772 772
 				}
773 773
 			}
774
-        }
774
+		}
775 775
 
776
-        if (! $error)
777
-        {
778
-            if ($newobject->price_base_type == 'HT')
779
-            {
780
-                $result=$newobject->updatePrice($newobject->price, $newobject->price_base_type,$fuser);
781
-                if ($result <= 0)
782
-                {
783
-                    $error++;
784
-                }
785
-            }
786
-            elseif ($newobject->price_base_type == 'TTC')
787
-            {
788
-                $result=$newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
789
-                if ($result <= 0)
790
-                {
791
-                    $error++;
792
-                }
793
-            }
794
-        }
795
-
796
-        if (! $error)
797
-        {
798
-            $db->commit();
799
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
800
-        }
801
-        else
776
+		if (! $error)
802 777
 		{
803
-            $db->rollback();
804
-            $error++;
805
-            $errorcode='KO';
806
-            $errorlabel=$newobject->error;
807
-        }
778
+			if ($newobject->price_base_type == 'HT')
779
+			{
780
+				$result=$newobject->updatePrice($newobject->price, $newobject->price_base_type,$fuser);
781
+				if ($result <= 0)
782
+				{
783
+					$error++;
784
+				}
785
+			}
786
+			elseif ($newobject->price_base_type == 'TTC')
787
+			{
788
+				$result=$newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
789
+				if ($result <= 0)
790
+				{
791
+					$error++;
792
+				}
793
+			}
794
+		}
808 795
 
809
-    }
796
+		if (! $error)
797
+		{
798
+			$db->commit();
799
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
800
+		}
801
+		else
802
+		{
803
+			$db->rollback();
804
+			$error++;
805
+			$errorcode='KO';
806
+			$errorlabel=$newobject->error;
807
+		}
810 808
 
811
-    if ($error)
812
-    {
813
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
814
-    }
809
+	}
815 810
 
816
-    return $objectresp;
811
+	if ($error)
812
+	{
813
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
814
+	}
815
+
816
+	return $objectresp;
817 817
 }
818 818
 
819 819
 
@@ -826,91 +826,91 @@  discard block
 block discarded – undo
826 826
  */
827 827
 function deleteProductOrService($authentication,$listofidstring)
828 828
 {
829
-    global $db,$conf,$langs;
829
+	global $db,$conf,$langs;
830 830
 
831
-    $now=dol_now();
831
+	$now=dol_now();
832 832
 
833
-    dol_syslog("Function: deleteProductOrService login=".$authentication['login']);
833
+	dol_syslog("Function: deleteProductOrService login=".$authentication['login']);
834 834
 
835
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
835
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
836 836
 
837
-    // Init and check authentication
838
-    $objectresp=array();
839
-    $errorcode='';$errorlabel='';
840
-    $error=0;
841
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
837
+	// Init and check authentication
838
+	$objectresp=array();
839
+	$errorcode='';$errorlabel='';
840
+	$error=0;
841
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
842 842
 
843 843
 	// User must be defined to user authenticated
844
-    global $user;
845
-    $user=$fuser;
844
+	global $user;
845
+	$user=$fuser;
846 846
 
847
-    $listofid=explode(',',trim($listofidstring));
848
-    $listofiddeleted=array();
847
+	$listofid=explode(',',trim($listofidstring));
848
+	$listofiddeleted=array();
849 849
 
850
-    // Check parameters
851
-    if (count($listofid) == 0 || empty($listofid[0]))
852
-    {
853
-        $error++; $errorcode='KO'; $errorlabel="List of Id of products or services to delete are required.";
854
-    }
850
+	// Check parameters
851
+	if (count($listofid) == 0 || empty($listofid[0]))
852
+	{
853
+		$error++; $errorcode='KO'; $errorlabel="List of Id of products or services to delete are required.";
854
+	}
855 855
 
856
-    if (! $error)
857
-    {
858
-    	$firsterror='';
856
+	if (! $error)
857
+	{
858
+		$firsterror='';
859 859
 
860 860
 		$db->begin();
861 861
 
862
-    	foreach($listofid as $key => $id)
862
+		foreach($listofid as $key => $id)
863 863
 		{
864
-	        $newobject=new Product($db);
865
-	        $result=$newobject->fetch($id);
866
-
867
-	        if ($result == 0)
868
-	        {
869
-	        	$error++;
870
-		        $firsterror='Product or service with id '.$id.' not found';
871
-		        break;
872
-	        }
873
-	        else
864
+			$newobject=new Product($db);
865
+			$result=$newobject->fetch($id);
866
+
867
+			if ($result == 0)
874 868
 			{
875
-		        $result=$newobject->delete($user);
876
-		        if ($result <= 0)
877
-		        {
878
-		            $error++;
879
-		            $firsterror=$newobject->error;
880
-		            break;
881
-		        }
882
-
883
-		        $listofiddeleted[]=$id;
869
+				$error++;
870
+				$firsterror='Product or service with id '.$id.' not found';
871
+				break;
872
+			}
873
+			else
874
+			{
875
+				$result=$newobject->delete($user);
876
+				if ($result <= 0)
877
+				{
878
+					$error++;
879
+					$firsterror=$newobject->error;
880
+					break;
881
+				}
882
+
883
+				$listofiddeleted[]=$id;
884 884
 			}
885 885
 		}
886 886
 
887
-	    if (! $error)
888
-	    {
889
-	        $db->commit();
890
-            //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted);
891
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
892
-	    }
893
-	    else
894
-	    {
895
-	    	$db->rollback();
896
-	        $error++;
897
-	        $errorcode='KO';
898
-	        $errorlabel=$firsterror;
887
+		if (! $error)
888
+		{
889
+			$db->commit();
890
+			//$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted);
891
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
899 892
 		}
900
-    }
901
-
902
-    if ($error)
903
-    {
904
-        //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted);
905
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0);
906
-    }
907
-    else if (count($listofiddeleted) == 0)
908
-    {
893
+		else
894
+		{
895
+			$db->rollback();
896
+			$error++;
897
+			$errorcode='KO';
898
+			$errorlabel=$firsterror;
899
+		}
900
+	}
901
+
902
+	if ($error)
903
+	{
904
+		//$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted);
905
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0);
906
+	}
907
+	else if (count($listofiddeleted) == 0)
908
+	{
909 909
    		//$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted);
910 910
    		$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'nbdeleted'=>0);
911
-    }
911
+	}
912 912
 
913
-    return $objectresp;
913
+	return $objectresp;
914 914
 }
915 915
 
916 916
 
@@ -923,70 +923,70 @@  discard block
 block discarded – undo
923 923
  */
924 924
 function getListOfProductsOrServices($authentication,$filterproduct)
925 925
 {
926
-    global $db,$conf,$langs;
926
+	global $db,$conf,$langs;
927 927
 
928
-    $now=dol_now();
928
+	$now=dol_now();
929 929
 
930
-    dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']);
930
+	dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']);
931 931
 
932
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
932
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
933 933
 
934
-    // Init and check authentication
935
-    $objectresp=array();
936
-    $arrayproducts=array();
937
-    $errorcode='';$errorlabel='';
938
-    $error=0;
939
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
940
-    // Check parameters
934
+	// Init and check authentication
935
+	$objectresp=array();
936
+	$arrayproducts=array();
937
+	$errorcode='';$errorlabel='';
938
+	$error=0;
939
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
940
+	// Check parameters
941 941
 
942
-    if (! $error)
943
-    {
944
-        $sql ="SELECT rowid, ref, ref_ext";
945
-        $sql.=" FROM ".MAIN_DB_PREFIX."product";
946
-        $sql.=" WHERE entity=".$conf->entity;
947
-        foreach($filterproduct as $key => $val)
948
-        {
942
+	if (! $error)
943
+	{
944
+		$sql ="SELECT rowid, ref, ref_ext";
945
+		$sql.=" FROM ".MAIN_DB_PREFIX."product";
946
+		$sql.=" WHERE entity=".$conf->entity;
947
+		foreach($filterproduct as $key => $val)
948
+		{
949 949
 		if ($key == 'type' && $val >= 0)   	$sql.=" AND fk_product_type = ".$db->escape($val);
950 950
 		if ($key == 'status_tosell') 				$sql.=" AND tosell = ".$db->escape($val);
951 951
 		if ($key == 'status_tobuy')  				$sql.=" AND tobuy = ".$db->escape($val);
952
-        }
952
+		}
953 953
 		$resql=$db->query($sql);
954
-        if ($resql)
955
-        {
956
-         	$num=$db->num_rows($resql);
957
-
958
-         	$i=0;
959
-         	while ($i < $num)
960
-         	{
961
-         		$obj=$db->fetch_object($resql);
962
-         		$arrayproducts[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
963
-         		$i++;
964
-         	}
965
-        }
966
-        else
967
-        {
968
-            $error++;
969
-            $errorcode=$db->lasterrno();
970
-            $errorlabel=$db->lasterror();
971
-        }
972
-    }
973
-
974
-    if ($error)
975
-    {
976
-        $objectresp = array(
954
+		if ($resql)
955
+		{
956
+		 	$num=$db->num_rows($resql);
957
+
958
+		 	$i=0;
959
+		 	while ($i < $num)
960
+		 	{
961
+		 		$obj=$db->fetch_object($resql);
962
+		 		$arrayproducts[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
963
+		 		$i++;
964
+		 	}
965
+		}
966
+		else
967
+		{
968
+			$error++;
969
+			$errorcode=$db->lasterrno();
970
+			$errorlabel=$db->lasterror();
971
+		}
972
+	}
973
+
974
+	if ($error)
975
+	{
976
+		$objectresp = array(
977 977
 			'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
978
-        	'products'=>$arrayproducts
979
-        );
980
-    }
981
-    else
982
-    {
983
-        $objectresp = array(
978
+			'products'=>$arrayproducts
979
+		);
980
+	}
981
+	else
982
+	{
983
+		$objectresp = array(
984 984
 			'result'=>array('result_code' => 'OK', 'result_label' => ''),
985
-        	'products'=>$arrayproducts
986
-        );
987
-    }
985
+			'products'=>$arrayproducts
986
+		);
987
+	}
988 988
 
989
-    return $objectresp;
989
+	return $objectresp;
990 990
 }
991 991
 
992 992
 
@@ -1059,35 +1059,35 @@  discard block
 block discarded – undo
1059 1059
 							$dir = $dir . '/'. $pdir;
1060 1060
 
1061 1061
 							$products[] = array(
1062
-						    	'id' => $obj->id,
1062
+								'id' => $obj->id,
1063 1063
 					   			'ref' => $obj->ref,
1064 1064
 					   			'ref_ext' => $obj->ref_ext,
1065
-					    		'label' => ! empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label,
1066
-					    		'description' => ! empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description,
1067
-					    		'date_creation' => dol_print_date($obj->date_creation,'dayhourrfc'),
1068
-					    		'date_modification' => dol_print_date($obj->date_modification,'dayhourrfc'),
1069
-					            'note' => ! empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note,
1070
-					            'status_tosell' => $obj->status,
1071
-					            'status_tobuy' => $obj->status_buy,
1072
-		                		'type' => $obj->type,
1073
-						        'barcode' => $obj->barcode,
1074
-						        'barcode_type' => $obj->barcode_type,
1075
-		                		'country_id' => $obj->country_id>0?$obj->country_id:'',
1076
-						        'country_code' => $obj->country_code,
1077
-						        'custom_code' => $obj->customcode,
1078
-
1079
-						        'price_net' => $obj->price,
1080
-						        'price' => $obj->price_ttc,
1081
-						        'vat_rate' => $obj->tva_tx,
1065
+								'label' => ! empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label,
1066
+								'description' => ! empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description,
1067
+								'date_creation' => dol_print_date($obj->date_creation,'dayhourrfc'),
1068
+								'date_modification' => dol_print_date($obj->date_modification,'dayhourrfc'),
1069
+								'note' => ! empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note,
1070
+								'status_tosell' => $obj->status,
1071
+								'status_tobuy' => $obj->status_buy,
1072
+								'type' => $obj->type,
1073
+								'barcode' => $obj->barcode,
1074
+								'barcode_type' => $obj->barcode_type,
1075
+								'country_id' => $obj->country_id>0?$obj->country_id:'',
1076
+								'country_code' => $obj->country_code,
1077
+								'custom_code' => $obj->customcode,
1078
+
1079
+								'price_net' => $obj->price,
1080
+								'price' => $obj->price_ttc,
1081
+								'vat_rate' => $obj->tva_tx,
1082 1082
 
1083 1083
 								'price_base_type' => $obj->price_base_type,
1084 1084
 
1085
-						        'stock_real' => $obj->stock_reel,
1086
-		                		'stock_alert' => $obj->seuil_stock_alerte,
1087
-						        'pmp' => $obj->pmp,
1088
-		                		'import_key' => $obj->import_key,
1089
-		                		'dir' => $pdir,
1090
-		                		'images' => $obj->liste_photos($dir,$nbmax=10)
1085
+								'stock_real' => $obj->stock_reel,
1086
+								'stock_alert' => $obj->seuil_stock_alerte,
1087
+								'pmp' => $obj->pmp,
1088
+								'import_key' => $obj->import_key,
1089
+								'dir' => $pdir,
1090
+								'images' => $obj->liste_photos($dir,$nbmax=10)
1091 1091
 							);
1092 1092
 
1093 1093
 							//Retreive all extrafield for thirdsparty
Please login to merge, or discard this patch.
Spacing   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
  *       \brief      File that is entry point to call Dolibarr WebServices
24 24
  */
25 25
 
26
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
26
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
27 27
 
28 28
 require_once '../master.inc.php';
29
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
29
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 {
47 47
     $langs->load("admin");
48 48
     dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
49
+    print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
50 50
     print $langs->trans("ToActivateModule");
51 51
     exit;
52 52
 }
53 53
 
54 54
 // Create the soap Object
55 55
 $server = new nusoap_server();
56
-$server->soap_defencoding='UTF-8';
57
-$server->decode_utf8=false;
58
-$ns='http://www.dolibarr.org/ns/';
59
-$server->configureWSDL('WebServicesDolibarrProductOrService',$ns);
60
-$server->wsdl->schemaTargetNamespace=$ns;
56
+$server->soap_defencoding = 'UTF-8';
57
+$server->decode_utf8 = false;
58
+$ns = 'http://www.dolibarr.org/ns/';
59
+$server->configureWSDL('WebServicesDolibarrProductOrService', $ns);
60
+$server->wsdl->schemaTargetNamespace = $ns;
61 61
 
62 62
 
63 63
 // Define WSDL Authentication object
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
     'all',
69 69
     '',
70 70
     array(
71
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
74
-        'password' => array('name'=>'password','type'=>'xsd:string'),
75
-        'entity' => array('name'=>'entity','type'=>'xsd:string')
71
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
72
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
73
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
74
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
75
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string')
76 76
     )
77 77
 );
78 78
 // Define WSDL Return object
@@ -83,70 +83,70 @@  discard block
 block discarded – undo
83 83
     'all',
84 84
     '',
85 85
     array(
86
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
87
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string')
86
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
87
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string')
88 88
     )
89 89
 );
90 90
 
91 91
 $productorservice_fields = array(
92
-    'id' => array('name'=>'id','type'=>'xsd:string'),
93
-    'ref' => array('name'=>'ref','type'=>'xsd:string'),
94
-    'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
95
-    'type' => array('name'=>'type','type'=>'xsd:string'),
96
-    'label' => array('name'=>'label','type'=>'xsd:string'),
97
-    'description' => array('name'=>'description','type'=>'xsd:string'),
98
-    'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
-    'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
-    'note' => array('name'=>'note','type'=>'xsd:string'),
101
-    'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
102
-    'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
103
-    'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
104
-    'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
105
-    'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
106
-    'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
107
-    'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
108
-
109
-    'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
110
-    'price' => array('name'=>'price','type'=>'xsd:string'),
111
-    'price_min_net' => array('name'=>'price_min_net','type'=>'xsd:string'),
112
-    'price_min' => array('name'=>'price_min','type'=>'xsd:string'),
113
-
114
-    'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
115
-
116
-    'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:string'),
117
-    'vat_npr' => array('name'=>'vat_npr','type'=>'xsd:string'),
118
-    'localtax1_tx' => array('name'=>'localtax1_tx','type'=>'xsd:string'),
119
-    'localtax2_tx' => array('name'=>'localtax2_tx','type'=>'xsd:string'),
120
-
121
-    'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
122
-    'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
123
-    'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
124
-    'warehouse_ref' => array('name'=>'warehouse_ref','type'=>'xsd:string'),		// Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database
125
-
126
-    'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
127
-    'import_key' => array('name'=>'import_key','type'=>'xsd:string'),
128
-
129
-    'dir' => array('name'=>'dir','type'=>'xsd:string'),
130
-    'images' => array('name'=>'images','type'=>'tns:ImagesArray')
92
+    'id' => array('name'=>'id', 'type'=>'xsd:string'),
93
+    'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
94
+    'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
95
+    'type' => array('name'=>'type', 'type'=>'xsd:string'),
96
+    'label' => array('name'=>'label', 'type'=>'xsd:string'),
97
+    'description' => array('name'=>'description', 'type'=>'xsd:string'),
98
+    'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'),
99
+    'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'),
100
+    'note' => array('name'=>'note', 'type'=>'xsd:string'),
101
+    'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'),
102
+    'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'),
103
+    'barcode' => array('name'=>'barcode', 'type'=>'xsd:string'),
104
+    'barcode_type' => array('name'=>'barcode_type', 'type'=>'xsd:string'),
105
+    'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'),
106
+    'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'),
107
+    'customcode' => array('name'=>'customcode', 'type'=>'xsd:string'),
108
+
109
+    'price_net' => array('name'=>'price_net', 'type'=>'xsd:string'),
110
+    'price' => array('name'=>'price', 'type'=>'xsd:string'),
111
+    'price_min_net' => array('name'=>'price_min_net', 'type'=>'xsd:string'),
112
+    'price_min' => array('name'=>'price_min', 'type'=>'xsd:string'),
113
+
114
+    'price_base_type' => array('name'=>'price_base_type', 'type'=>'xsd:string'),
115
+
116
+    'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:string'),
117
+    'vat_npr' => array('name'=>'vat_npr', 'type'=>'xsd:string'),
118
+    'localtax1_tx' => array('name'=>'localtax1_tx', 'type'=>'xsd:string'),
119
+    'localtax2_tx' => array('name'=>'localtax2_tx', 'type'=>'xsd:string'),
120
+
121
+    'stock_alert' => array('name'=>'stock_alert', 'type'=>'xsd:string'),
122
+    'stock_real' => array('name'=>'stock_real', 'type'=>'xsd:string'),
123
+    'stock_pmp' => array('name'=>'stock_pmp', 'type'=>'xsd:string'),
124
+    'warehouse_ref' => array('name'=>'warehouse_ref', 'type'=>'xsd:string'), // Used only for create or update to set which warehouse to use for stock correction if stock_real differs from database
125
+
126
+    'canvas' => array('name'=>'canvas', 'type'=>'xsd:string'),
127
+    'import_key' => array('name'=>'import_key', 'type'=>'xsd:string'),
128
+
129
+    'dir' => array('name'=>'dir', 'type'=>'xsd:string'),
130
+    'images' => array('name'=>'images', 'type'=>'tns:ImagesArray')
131 131
 );
132 132
 
133 133
 //Retreive all extrafield for product
134 134
 // fetch optionals attributes and labels
135
-$extrafields=new ExtraFields($db);
136
-$extralabels=$extrafields->fetch_name_optionals_label('product',true);
137
-if (count($extrafields)>0) {
135
+$extrafields = new ExtraFields($db);
136
+$extralabels = $extrafields->fetch_name_optionals_label('product', true);
137
+if (count($extrafields) > 0) {
138 138
 	$extrafield_array = array();
139 139
 }
140
-foreach($extrafields->attribute_label as $key=>$label)
140
+foreach ($extrafields->attribute_label as $key=>$label)
141 141
 {
142
-	$type =$extrafields->attribute_type[$key];
143
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
144
-	else {$type='xsd:string';}
142
+	$type = $extrafields->attribute_type[$key];
143
+	if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
144
+	else {$type = 'xsd:string'; }
145 145
 
146
-	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
146
+	$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
147 147
 }
148 148
 
149
-$productorservice_fields=array_merge($productorservice_fields,$extrafield_array);
149
+$productorservice_fields = array_merge($productorservice_fields, $extrafield_array);
150 150
 
151 151
 // Define other specific objects
152 152
 $server->wsdl->addComplexType(
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 	'all',
189 189
 	'',
190 190
 	array(
191
-		'photo' => array('name'=>'photo','type'=>'xsd:string'),
192
-		'photo_vignette' => array('name'=>'photo_vignette','type'=>'xsd:string'),
193
-		'imgWidth' => array('name'=>'imgWidth','type'=>'xsd:string'),
194
-		'imgHeight' => array('name'=>'imgHeight','type'=>'xsd:string')
191
+		'photo' => array('name'=>'photo', 'type'=>'xsd:string'),
192
+		'photo_vignette' => array('name'=>'photo_vignette', 'type'=>'xsd:string'),
193
+		'imgWidth' => array('name'=>'imgWidth', 'type'=>'xsd:string'),
194
+		'imgHeight' => array('name'=>'imgHeight', 'type'=>'xsd:string')
195 195
 	)
196 196
 );
197 197
 
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
     '',
206 206
     array(
207 207
         //'limit' => array('name'=>'limit','type'=>'xsd:string'),
208
-		'type' => array('name'=>'type','type'=>'xsd:string'),
209
-	    'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
210
-	    'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
208
+		'type' => array('name'=>'type', 'type'=>'xsd:string'),
209
+	    'status_tobuy' => array('name'=>'status_tobuy', 'type'=>'xsd:string'),
210
+	    'status_tosell' => array('name'=>'status_tosell', 'type'=>'xsd:string'),
211 211
     )
212 212
 );
213 213
 
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
233 233
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
234 234
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
235
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
236
-$styleuse='encoded';   // encoded/literal/literal wrapped
235
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
236
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
237 237
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
238 238
 
239 239
 
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 $server->register(
242 242
     'getProductOrService',
243 243
     // Entry values
244
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string','lang'=>'xsd:string'),
244
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string', 'lang'=>'xsd:string'),
245 245
     // Exit values
246
-    array('result'=>'tns:result','product'=>'tns:product'),
246
+    array('result'=>'tns:result', 'product'=>'tns:product'),
247 247
     $ns,
248 248
     $ns.'#getProductOrService',
249 249
     $styledoc,
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 $server->register(
256 256
     'createProductOrService',
257 257
     // Entry values
258
-    array('authentication'=>'tns:authentication','product'=>'tns:product'),
258
+    array('authentication'=>'tns:authentication', 'product'=>'tns:product'),
259 259
     // Exit values
260
-    array('result'=>'tns:result','id'=>'xsd:string'),
260
+    array('result'=>'tns:result', 'id'=>'xsd:string'),
261 261
     $ns,
262 262
     $ns.'#createProductOrService',
263 263
     $styledoc,
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 $server->register(
270 270
     'updateProductOrService',
271 271
     // Entry values
272
-    array('authentication'=>'tns:authentication','product'=>'tns:product'),
272
+    array('authentication'=>'tns:authentication', 'product'=>'tns:product'),
273 273
     // Exit values
274
-    array('result'=>'tns:result','id'=>'xsd:string'),
274
+    array('result'=>'tns:result', 'id'=>'xsd:string'),
275 275
     $ns,
276 276
     $ns.'#updateProductOrService',
277 277
     $styledoc,
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 $server->register(
284 284
     'deleteProductOrService',
285 285
     // Entry values
286
-    array('authentication'=>'tns:authentication','listofid'=>'xsd:string'),
286
+    array('authentication'=>'tns:authentication', 'listofid'=>'xsd:string'),
287 287
     // Exit values
288
-    array('result'=>'tns:result','nbdeleted'=>'xsd:int'),
288
+    array('result'=>'tns:result', 'nbdeleted'=>'xsd:int'),
289 289
     $ns,
290 290
     $ns.'#deleteProductOrService',
291 291
     $styledoc,
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 $server->register(
298 298
     'getListOfProductsOrServices',
299 299
     // Entry values
300
-    array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'),
300
+    array('authentication'=>'tns:authentication', 'filterproduct'=>'tns:filterproduct'),
301 301
     // Exit values
302
-    array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
302
+    array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'),
303 303
     $ns,
304 304
     $ns.'#getListOfProductsOrServices',
305 305
     $styledoc,
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 $server->register(
312 312
 	'getProductsForCategory',
313 313
 	// Entry values
314
-	array('authentication'=>'tns:authentication','id'=>'xsd:string','lang'=>'xsd:string'),
314
+	array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'lang'=>'xsd:string'),
315 315
 	// Exit values
316
-	array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
316
+	array('result'=>'tns:result', 'products'=>'tns:ProductsArray2'),
317 317
 	$ns,
318 318
 	$ns.'#getProductsForCategory',
319 319
 	$styledoc,
@@ -332,53 +332,53 @@  discard block
 block discarded – undo
332 332
  * @param   string      $lang               Lang to force
333 333
  * @return	mixed
334 334
  */
335
-function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='')
335
+function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '', $lang = '')
336 336
 {
337
-    global $db,$conf,$langs;
337
+    global $db, $conf, $langs;
338 338
 
339 339
     dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
340 340
 
341
-    $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
341
+    $langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
342 342
     $langs->setDefaultLang($langcode);
343 343
 
344
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
344
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
345 345
 
346 346
     // Init and check authentication
347
-    $objectresp=array();
348
-    $errorcode='';$errorlabel='';
349
-    $error=0;
350
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
347
+    $objectresp = array();
348
+    $errorcode = ''; $errorlabel = '';
349
+    $error = 0;
350
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
351 351
     // Check parameters
352
-    if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
352
+    if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
353 353
     {
354 354
         $error++;
355
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
355
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
356 356
     }
357 357
 
358
-    if (! $error)
358
+    if (!$error)
359 359
     {
360 360
 
361
-    	$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
361
+    	$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
362 362
     	$langs->setDefaultLang($langcode);
363 363
 
364 364
         $fuser->getrights();
365 365
 
366 366
         if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
367 367
         {
368
-            $product=new Product($db);
369
-            $result=$product->fetch($id,$ref,$ref_ext);
368
+            $product = new Product($db);
369
+            $result = $product->fetch($id, $ref, $ref_ext);
370 370
 
371 371
             if ($result > 0)
372 372
             {
373 373
             	$product->load_stock();
374 374
 
375
-            	$dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output);
376
-            	$pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/";
377
-            	$dir = $dir . '/'. $pdir;
375
+            	$dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output);
376
+            	$pdir = get_exdir($product->id, 2, 0, 0, $product, 'product').$product->ref."/";
377
+            	$dir = $dir.'/'.$pdir;
378 378
 
379
-            	if (! empty($product->multilangs[$langs->defaultlang]["label"]))     		$product->label =  $product->multilangs[$langs->defaultlang]["label"];
380
-            	if (! empty($product->multilangs[$langs->defaultlang]["description"]))     	$product->description =  $product->multilangs[$langs->defaultlang]["description"];
381
-            	if (! empty($product->multilangs[$langs->defaultlang]["note"]))     		$product->note =  $product->multilangs[$langs->defaultlang]["note"];
379
+            	if (!empty($product->multilangs[$langs->defaultlang]["label"]))     		$product->label = $product->multilangs[$langs->defaultlang]["label"];
380
+            	if (!empty($product->multilangs[$langs->defaultlang]["description"]))     	$product->description = $product->multilangs[$langs->defaultlang]["description"];
381
+            	if (!empty($product->multilangs[$langs->defaultlang]["note"]))     		$product->note = $product->multilangs[$langs->defaultlang]["note"];
382 382
 
383 383
             	$productorservice_result_fields = array(
384 384
 	            	'id' => $product->id,
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
 	            	'ref_ext' => $product->ref_ext,
387 387
 	            	'label' => $product->label,
388 388
 	            	'description' => $product->description,
389
-	            	'date_creation' => dol_print_date($product->date_creation,'dayhourrfc'),
390
-	            	'date_modification' => dol_print_date($product->date_modification,'dayhourrfc'),
389
+	            	'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'),
390
+	            	'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'),
391 391
 	            	'note' => $product->note,
392 392
 	            	'status_tosell' => $product->status,
393 393
 	            	'status_tobuy' => $product->status_buy,
394 394
 	            	'type' => $product->type,
395 395
 	            	'barcode' => $product->barcode,
396 396
 	            	'barcode_type' => $product->barcode_type,
397
-	            	'country_id' => $product->country_id>0?$product->country_id:'',
397
+	            	'country_id' => $product->country_id > 0 ? $product->country_id : '',
398 398
 	            	'country_code' => $product->country_code,
399 399
 	            	'custom_code' => $product->customcode,
400 400
 
@@ -416,19 +416,19 @@  discard block
 block discarded – undo
416 416
 	            	'pmp' => $product->pmp,
417 417
 	            	'import_key' => $product->import_key,
418 418
 	            	'dir' => $pdir,
419
-	            	'images' => $product->liste_photos($dir,$nbmax=10)
419
+	            	'images' => $product->liste_photos($dir, $nbmax = 10)
420 420
             	);
421 421
 
422 422
                 //Retreive all extrafield for thirdsparty
423 423
             	// fetch optionals attributes and labels
424
-            	$extrafields=new ExtraFields($db);
425
-            	$extralabels=$extrafields->fetch_name_optionals_label('product',true);
424
+            	$extrafields = new ExtraFields($db);
425
+            	$extralabels = $extrafields->fetch_name_optionals_label('product', true);
426 426
             	//Get extrafield values
427
-            	$product->fetch_optionals($product->id,$extralabels);
427
+            	$product->fetch_optionals($product->id, $extralabels);
428 428
 
429
-            	foreach($extrafields->attribute_label as $key=>$label)
429
+            	foreach ($extrafields->attribute_label as $key=>$label)
430 430
             	{
431
-            		$productorservice_result_fields=array_merge($productorservice_result_fields,array('options_'.$key => $product->array_options['options_'.$key]));
431
+            		$productorservice_result_fields = array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key]));
432 432
             	}
433 433
 
434 434
                 // Create
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
             else
441 441
             {
442 442
                 $error++;
443
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
443
+                $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
444 444
             }
445 445
         }
446 446
         else
447 447
         {
448 448
             $error++;
449
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
449
+            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
450 450
         }
451 451
     }
452 452
 
@@ -466,56 +466,56 @@  discard block
 block discarded – undo
466 466
  * @param	Product		$product			Product
467 467
  * @return	array							Array result
468 468
  */
469
-function createProductOrService($authentication,$product)
469
+function createProductOrService($authentication, $product)
470 470
 {
471
-    global $db,$conf,$langs;
471
+    global $db, $conf, $langs;
472 472
 
473
-    $now=dol_now();
473
+    $now = dol_now();
474 474
 
475 475
     dol_syslog("Function: createProductOrService login=".$authentication['login']);
476 476
 
477
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
477
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
478 478
 
479 479
     // Init and check authentication
480
-    $objectresp=array();
481
-    $errorcode='';$errorlabel='';
482
-    $error=0;
483
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
480
+    $objectresp = array();
481
+    $errorcode = ''; $errorlabel = '';
482
+    $error = 0;
483
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
484 484
     // Check parameters
485
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
486
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
485
+    if ($product['price_net'] > 0) $product['price_base_type'] = 'HT';
486
+    if ($product['price'] > 0)     $product['price_base_type'] = 'TTC';
487 487
 
488 488
     if ($product['price_net'] > 0 && $product['price'] > 0)
489 489
     {
490
-        $error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
490
+        $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price.";
491 491
     }
492 492
 
493 493
     if ($product['barcode'] && !$product['barcode_type'])
494 494
     {
495
-	$errror++; $errorcode='KO' ; $errorlabel="You must set a barcode type when setting a barcode.";
495
+	$errror++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode.";
496 496
     }
497 497
 
498 498
 
499 499
 
500
-    if (! $error)
500
+    if (!$error)
501 501
     {
502 502
         include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
503 503
 
504
-        $newobject=new Product($db);
505
-        $newobject->ref=$product['ref'];
506
-        $newobject->ref_ext=$product['ref_ext'];
507
-        $newobject->type=$product['type'];
508
-        $newobject->libelle=$product['label'];    // @deprecated
509
-        $newobject->label=$product['label'];
510
-        $newobject->description=$product['description'];
511
-        $newobject->note=$product['note'];
512
-        $newobject->status=$product['status_tosell'];
513
-        $newobject->status_buy=$product['status_tobuy'];
514
-        $newobject->price=$product['price_net'];
515
-        $newobject->price_ttc=$product['price'];
516
-        $newobject->tva_tx=$product['vat_rate'];
517
-        $newobject->price_base_type=$product['price_base_type'];
518
-        $newobject->date_creation=$now;
504
+        $newobject = new Product($db);
505
+        $newobject->ref = $product['ref'];
506
+        $newobject->ref_ext = $product['ref_ext'];
507
+        $newobject->type = $product['type'];
508
+        $newobject->libelle = $product['label']; // @deprecated
509
+        $newobject->label = $product['label'];
510
+        $newobject->description = $product['description'];
511
+        $newobject->note = $product['note'];
512
+        $newobject->status = $product['status_tosell'];
513
+        $newobject->status_buy = $product['status_tobuy'];
514
+        $newobject->price = $product['price_net'];
515
+        $newobject->price_ttc = $product['price'];
516
+        $newobject->tva_tx = $product['vat_rate'];
517
+        $newobject->price_base_type = $product['price_base_type'];
518
+        $newobject->date_creation = $now;
519 519
 
520 520
 		if ($product['barcode'])
521 521
 		{
@@ -523,15 +523,15 @@  discard block
 block discarded – undo
523 523
 			$newobject->barcode_type = $product['barcode_type'];
524 524
 		}
525 525
 
526
-        $newobject->stock_reel=$product['stock_real'];
527
-        $newobject->pmp=$product['pmp'];
528
-        $newobject->seuil_stock_alert=$product['stock_alert'];
526
+        $newobject->stock_reel = $product['stock_real'];
527
+        $newobject->pmp = $product['pmp'];
528
+        $newobject->seuil_stock_alert = $product['stock_alert'];
529 529
 
530
-        $newobject->country_id=$product['country_id'];
531
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
532
-        $newobject->customcode=$product['customcode'];
530
+        $newobject->country_id = $product['country_id'];
531
+        if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3);
532
+        $newobject->customcode = $product['customcode'];
533 533
 
534
-        $newobject->canvas=$product['canvas'];
534
+        $newobject->canvas = $product['canvas'];
535 535
         /*foreach($product['lines'] as $line)
536 536
         {
537 537
             $newline=new FactureLigne($db);
@@ -548,31 +548,31 @@  discard block
 block discarded – undo
548 548
         //var_dump($product['ref_ext']);
549 549
         //var_dump($product['lines'][0]['type']);
550 550
 
551
-        $extrafields=new ExtraFields($db);
552
-		$extralabels=$extrafields->fetch_name_optionals_label('product',true);
553
-		foreach($extrafields->attribute_label as $key=>$label)
551
+        $extrafields = new ExtraFields($db);
552
+		$extralabels = $extrafields->fetch_name_optionals_label('product', true);
553
+		foreach ($extrafields->attribute_label as $key=>$label)
554 554
 		{
555
-			$key='options_'.$key;
556
-			$newobject->array_options[$key]=$product[$key];
555
+			$key = 'options_'.$key;
556
+			$newobject->array_options[$key] = $product[$key];
557 557
 		}
558 558
 
559 559
         $db->begin();
560 560
 
561
-        $result=$newobject->create($fuser,0);
561
+        $result = $newobject->create($fuser, 0);
562 562
         if ($result <= 0)
563 563
         {
564 564
             $error++;
565 565
         }
566 566
 
567
-        if (! $error)
567
+        if (!$error)
568 568
         {
569 569
         	// Update stock if stock count is provided and differs from database after creation or update
570
-			if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled))
570
+			if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled))
571 571
 			{
572 572
 				require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
573 573
 
574
-				$savstockreal=$newobject->stock_reel;
575
-				$newobject->load_stock('novirtual,nobatch');		// This overwrite ->stock_reel, surely 0 because we have just created product
574
+				$savstockreal = $newobject->stock_reel;
575
+				$newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel, surely 0 because we have just created product
576 576
 				$getstockreal = $newobject->stock_reel;
577 577
 
578 578
 				if ($savstockreal != $getstockreal)
@@ -583,38 +583,38 @@  discard block
 block discarded – undo
583 583
 					{
584 584
 						if (($savstockreal - $getstockreal) > 0)
585 585
 						{
586
-							$result=$newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now,'dayhourlog'));
586
+							$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
587 587
 						}
588 588
 						if (($savstockreal - $getstockreal) > 0)
589 589
 						{
590
-							$result=$newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now,'dayhourlog'));
590
+							$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
591 591
 						}
592 592
 						if ($result <= 0)
593 593
 						{
594 594
 							$error++;
595
-							$newobject->error='You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
595
+							$newobject->error = 'You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
596 596
 						}
597 597
 					}
598 598
 					else
599 599
 					{
600 600
 						$error++;
601
-						$newobject->error='You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
601
+						$newobject->error = 'You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
602 602
 					}
603 603
 				}
604 604
 			}
605 605
 		}
606 606
 
607
-        if (! $error)
607
+        if (!$error)
608 608
         {
609 609
             $db->commit();
610
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
610
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
611 611
         }
612 612
         else
613 613
         {
614 614
             $db->rollback();
615 615
             $error++;
616
-            $errorcode='KO';
617
-            $errorlabel=$newobject->error;
616
+            $errorcode = 'KO';
617
+            $errorlabel = $newobject->error;
618 618
         }
619 619
 
620 620
     }
@@ -635,57 +635,57 @@  discard block
 block discarded – undo
635 635
  * @param	Product		$product			Product
636 636
  * @return	array							Array result
637 637
  */
638
-function updateProductOrService($authentication,$product)
638
+function updateProductOrService($authentication, $product)
639 639
 {
640
-    global $db,$conf,$langs;
640
+    global $db, $conf, $langs;
641 641
 
642
-    $now=dol_now();
642
+    $now = dol_now();
643 643
 
644 644
     dol_syslog("Function: updateProductOrService login=".$authentication['login']);
645 645
 
646
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
646
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
647 647
 
648 648
     // Init and check authentication
649
-    $objectresp=array();
650
-    $errorcode='';$errorlabel='';
651
-    $error=0;
652
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
649
+    $objectresp = array();
650
+    $errorcode = ''; $errorlabel = '';
651
+    $error = 0;
652
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
653 653
     // Check parameters
654
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
655
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
654
+    if ($product['price_net'] > 0) $product['price_base_type'] = 'HT';
655
+    if ($product['price'] > 0)     $product['price_base_type'] = 'TTC';
656 656
 
657 657
     if ($product['price_net'] > 0 && $product['price'] > 0)
658 658
     {
659
-        $error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price.";
659
+        $error++; $errorcode = 'KO'; $errorlabel = "You must choose between price or price_net to provide price.";
660 660
     }
661 661
 
662 662
 
663 663
     if ($product['barcode'] && !$product['barcode_type'])
664 664
     {
665
-        $errror++; $errorcode='KO' ; $errorlabel="You must set a barcode type when setting a barcode.";
665
+        $errror++; $errorcode = 'KO'; $errorlabel = "You must set a barcode type when setting a barcode.";
666 666
     }
667 667
 
668
-    if (! $error)
668
+    if (!$error)
669 669
     {
670 670
         include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
671 671
 
672
-        $newobject=new Product($db);
672
+        $newobject = new Product($db);
673 673
         $newobject->fetch($product['id']);
674 674
 
675
-        if (isset($product['ref']))     $newobject->ref=$product['ref'];
676
-        if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext'];
677
-        $newobject->type=$product['type'];
678
-        $newobject->libelle=$product['label'];    // @deprecated
679
-        $newobject->label=$product['label'];
680
-        $newobject->description=$product['description'];
681
-        $newobject->note=$product['note'];
682
-        $newobject->status=$product['status_tosell'];
683
-        $newobject->status_buy=$product['status_tobuy'];
684
-        $newobject->price=$product['price_net'];
685
-        $newobject->price_ttc=$product['price'];
686
-        $newobject->tva_tx=$product['vat_rate'];
687
-        $newobject->price_base_type=$product['price_base_type'];
688
-        $newobject->date_creation=$now;
675
+        if (isset($product['ref']))     $newobject->ref = $product['ref'];
676
+        if (isset($product['ref_ext'])) $newobject->ref_ext = $product['ref_ext'];
677
+        $newobject->type = $product['type'];
678
+        $newobject->libelle = $product['label']; // @deprecated
679
+        $newobject->label = $product['label'];
680
+        $newobject->description = $product['description'];
681
+        $newobject->note = $product['note'];
682
+        $newobject->status = $product['status_tosell'];
683
+        $newobject->status_buy = $product['status_tobuy'];
684
+        $newobject->price = $product['price_net'];
685
+        $newobject->price_ttc = $product['price'];
686
+        $newobject->tva_tx = $product['vat_rate'];
687
+        $newobject->price_base_type = $product['price_base_type'];
688
+        $newobject->date_creation = $now;
689 689
 
690 690
         if ($product['barcode'])
691 691
         {
@@ -693,15 +693,15 @@  discard block
 block discarded – undo
693 693
                 $newobject->barcode_type = $product['barcode_type'];
694 694
         }
695 695
 
696
-        $newobject->stock_reel=$product['stock_real'];
697
-        $newobject->pmp=$product['pmp'];
698
-        $newobject->seuil_stock_alert=$product['stock_alert'];
696
+        $newobject->stock_reel = $product['stock_real'];
697
+        $newobject->pmp = $product['pmp'];
698
+        $newobject->seuil_stock_alert = $product['stock_alert'];
699 699
 
700
-        $newobject->country_id=$product['country_id'];
701
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
702
-        $newobject->customcode=$product['customcode'];
700
+        $newobject->country_id = $product['country_id'];
701
+        if ($product['country_code']) $newobject->country_id = getCountry($product['country_code'], 3);
702
+        $newobject->customcode = $product['customcode'];
703 703
 
704
-        $newobject->canvas=$product['canvas'];
704
+        $newobject->canvas = $product['canvas'];
705 705
         /*foreach($product['lines'] as $line)
706 706
         {
707 707
             $newline=new FactureLigne($db);
@@ -718,17 +718,17 @@  discard block
 block discarded – undo
718 718
         //var_dump($product['ref_ext']);
719 719
         //var_dump($product['lines'][0]['type']);
720 720
 
721
-		$extrafields=new ExtraFields($db);
722
-		$extralabels=$extrafields->fetch_name_optionals_label('product',true);
723
-		foreach($extrafields->attribute_label as $key=>$label)
721
+		$extrafields = new ExtraFields($db);
722
+		$extralabels = $extrafields->fetch_name_optionals_label('product', true);
723
+		foreach ($extrafields->attribute_label as $key=>$label)
724 724
 		{
725
-			$key='options_'.$key;
726
-			$newobject->array_options[$key]=$product[$key];
725
+			$key = 'options_'.$key;
726
+			$newobject->array_options[$key] = $product[$key];
727 727
 		}
728 728
 
729 729
         $db->begin();
730 730
 
731
-        $result=$newobject->update($newobject->id,$fuser);
731
+        $result = $newobject->update($newobject->id, $fuser);
732 732
         if ($result <= 0)
733 733
         {
734 734
             $error++;
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
         else
737 737
 		{
738 738
         	// Update stock if stock count is provided and differs from database after creation or update
739
-			if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled))
739
+			if (isset($product['stock_real']) && $product['stock_real'] != '' && !empty($conf->global->stock->enabled))
740 740
 			{
741 741
 				require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
742 742
 
743
-				$savstockreal=$newobject->stock_reel;
744
-				$newobject->load_stock('novirtual,nobatch');		// This overwrite ->stock_reel
743
+				$savstockreal = $newobject->stock_reel;
744
+				$newobject->load_stock('novirtual,nobatch'); // This overwrite ->stock_reel
745 745
 				$getstockreal = $newobject->stock_reel;
746 746
 
747 747
 				if ($savstockreal != $getstockreal)
@@ -752,32 +752,32 @@  discard block
 block discarded – undo
752 752
 					{
753 753
 						if (($savstockreal - $getstockreal) > 0)
754 754
 						{
755
-							$result=$newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now,'dayhourlog'));
755
+							$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 0, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
756 756
 						}
757 757
 						if (($savstockreal - $getstockreal) > 0)
758 758
 						{
759
-							$result=$newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now,'dayhourlog'));
759
+							$result = $newobject->correct_stock($fuser, $warehouse->id, ($savstockreal - $getstockreal), 1, 'Correction from external call (Web Service)', 0, 'WS'.dol_print_date($now, 'dayhourlog'));
760 760
 						}
761 761
 						if ($result <= 0)
762 762
 						{
763 763
 							$error++;
764
-							$newobject->error='You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
764
+							$newobject->error = 'You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
765 765
 						}
766 766
 					}
767 767
 					else
768 768
 					{
769 769
 						$error++;
770
-						$newobject->error='You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
770
+						$newobject->error = 'You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
771 771
 					}
772 772
 				}
773 773
 			}
774 774
         }
775 775
 
776
-        if (! $error)
776
+        if (!$error)
777 777
         {
778 778
             if ($newobject->price_base_type == 'HT')
779 779
             {
780
-                $result=$newobject->updatePrice($newobject->price, $newobject->price_base_type,$fuser);
780
+                $result = $newobject->updatePrice($newobject->price, $newobject->price_base_type, $fuser);
781 781
                 if ($result <= 0)
782 782
                 {
783 783
                     $error++;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
             }
786 786
             elseif ($newobject->price_base_type == 'TTC')
787 787
             {
788
-                $result=$newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
788
+                $result = $newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
789 789
                 if ($result <= 0)
790 790
                 {
791 791
                     $error++;
@@ -793,17 +793,17 @@  discard block
 block discarded – undo
793 793
             }
794 794
         }
795 795
 
796
-        if (! $error)
796
+        if (!$error)
797 797
         {
798 798
             $db->commit();
799
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
799
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
800 800
         }
801 801
         else
802 802
 		{
803 803
             $db->rollback();
804 804
             $error++;
805
-            $errorcode='KO';
806
-            $errorlabel=$newobject->error;
805
+            $errorcode = 'KO';
806
+            $errorlabel = $newobject->error;
807 807
         }
808 808
 
809 809
     }
@@ -824,78 +824,78 @@  discard block
 block discarded – undo
824 824
  * @param	string		$listofidstring		List of id with comma
825 825
  * @return	array							Array result
826 826
  */
827
-function deleteProductOrService($authentication,$listofidstring)
827
+function deleteProductOrService($authentication, $listofidstring)
828 828
 {
829
-    global $db,$conf,$langs;
829
+    global $db, $conf, $langs;
830 830
 
831
-    $now=dol_now();
831
+    $now = dol_now();
832 832
 
833 833
     dol_syslog("Function: deleteProductOrService login=".$authentication['login']);
834 834
 
835
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
835
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
836 836
 
837 837
     // Init and check authentication
838
-    $objectresp=array();
839
-    $errorcode='';$errorlabel='';
840
-    $error=0;
841
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
838
+    $objectresp = array();
839
+    $errorcode = ''; $errorlabel = '';
840
+    $error = 0;
841
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
842 842
 
843 843
 	// User must be defined to user authenticated
844 844
     global $user;
845
-    $user=$fuser;
845
+    $user = $fuser;
846 846
 
847
-    $listofid=explode(',',trim($listofidstring));
848
-    $listofiddeleted=array();
847
+    $listofid = explode(',', trim($listofidstring));
848
+    $listofiddeleted = array();
849 849
 
850 850
     // Check parameters
851 851
     if (count($listofid) == 0 || empty($listofid[0]))
852 852
     {
853
-        $error++; $errorcode='KO'; $errorlabel="List of Id of products or services to delete are required.";
853
+        $error++; $errorcode = 'KO'; $errorlabel = "List of Id of products or services to delete are required.";
854 854
     }
855 855
 
856
-    if (! $error)
856
+    if (!$error)
857 857
     {
858
-    	$firsterror='';
858
+    	$firsterror = '';
859 859
 
860 860
 		$db->begin();
861 861
 
862
-    	foreach($listofid as $key => $id)
862
+    	foreach ($listofid as $key => $id)
863 863
 		{
864
-	        $newobject=new Product($db);
865
-	        $result=$newobject->fetch($id);
864
+	        $newobject = new Product($db);
865
+	        $result = $newobject->fetch($id);
866 866
 
867 867
 	        if ($result == 0)
868 868
 	        {
869 869
 	        	$error++;
870
-		        $firsterror='Product or service with id '.$id.' not found';
870
+		        $firsterror = 'Product or service with id '.$id.' not found';
871 871
 		        break;
872 872
 	        }
873 873
 	        else
874 874
 			{
875
-		        $result=$newobject->delete($user);
875
+		        $result = $newobject->delete($user);
876 876
 		        if ($result <= 0)
877 877
 		        {
878 878
 		            $error++;
879
-		            $firsterror=$newobject->error;
879
+		            $firsterror = $newobject->error;
880 880
 		            break;
881 881
 		        }
882 882
 
883
-		        $listofiddeleted[]=$id;
883
+		        $listofiddeleted[] = $id;
884 884
 			}
885 885
 		}
886 886
 
887
-	    if (! $error)
887
+	    if (!$error)
888 888
 	    {
889 889
 	        $db->commit();
890 890
             //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted);
891
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
891
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
892 892
 	    }
893 893
 	    else
894 894
 	    {
895 895
 	    	$db->rollback();
896 896
 	        $error++;
897
-	        $errorcode='KO';
898
-	        $errorlabel=$firsterror;
897
+	        $errorcode = 'KO';
898
+	        $errorlabel = $firsterror;
899 899
 		}
900 900
     }
901 901
 
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
     else if (count($listofiddeleted) == 0)
908 908
     {
909 909
    		//$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted);
910
-   		$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'nbdeleted'=>0);
910
+   		$objectresp = array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',', $listofid).' found'), 'nbdeleted'=>0);
911 911
     }
912 912
 
913 913
     return $objectresp;
@@ -921,53 +921,53 @@  discard block
 block discarded – undo
921 921
  * @param	array		$filterproduct		Filter fields
922 922
  * @return	array							Array result
923 923
  */
924
-function getListOfProductsOrServices($authentication,$filterproduct)
924
+function getListOfProductsOrServices($authentication, $filterproduct)
925 925
 {
926
-    global $db,$conf,$langs;
926
+    global $db, $conf, $langs;
927 927
 
928
-    $now=dol_now();
928
+    $now = dol_now();
929 929
 
930 930
     dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']);
931 931
 
932
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
932
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
933 933
 
934 934
     // Init and check authentication
935
-    $objectresp=array();
936
-    $arrayproducts=array();
937
-    $errorcode='';$errorlabel='';
938
-    $error=0;
939
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
935
+    $objectresp = array();
936
+    $arrayproducts = array();
937
+    $errorcode = ''; $errorlabel = '';
938
+    $error = 0;
939
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
940 940
     // Check parameters
941 941
 
942
-    if (! $error)
942
+    if (!$error)
943 943
     {
944
-        $sql ="SELECT rowid, ref, ref_ext";
945
-        $sql.=" FROM ".MAIN_DB_PREFIX."product";
946
-        $sql.=" WHERE entity=".$conf->entity;
947
-        foreach($filterproduct as $key => $val)
944
+        $sql = "SELECT rowid, ref, ref_ext";
945
+        $sql .= " FROM ".MAIN_DB_PREFIX."product";
946
+        $sql .= " WHERE entity=".$conf->entity;
947
+        foreach ($filterproduct as $key => $val)
948 948
         {
949
-		if ($key == 'type' && $val >= 0)   	$sql.=" AND fk_product_type = ".$db->escape($val);
950
-		if ($key == 'status_tosell') 				$sql.=" AND tosell = ".$db->escape($val);
951
-		if ($key == 'status_tobuy')  				$sql.=" AND tobuy = ".$db->escape($val);
949
+		if ($key == 'type' && $val >= 0)   	$sql .= " AND fk_product_type = ".$db->escape($val);
950
+		if ($key == 'status_tosell') 				$sql .= " AND tosell = ".$db->escape($val);
951
+		if ($key == 'status_tobuy')  				$sql .= " AND tobuy = ".$db->escape($val);
952 952
         }
953
-		$resql=$db->query($sql);
953
+		$resql = $db->query($sql);
954 954
         if ($resql)
955 955
         {
956
-         	$num=$db->num_rows($resql);
956
+         	$num = $db->num_rows($resql);
957 957
 
958
-         	$i=0;
958
+         	$i = 0;
959 959
          	while ($i < $num)
960 960
          	{
961
-         		$obj=$db->fetch_object($resql);
962
-         		$arrayproducts[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
961
+         		$obj = $db->fetch_object($resql);
962
+         		$arrayproducts[] = array('id'=>$obj->rowid, 'ref'=>$obj->ref, 'ref_ext'=>$obj->ref_ext);
963 963
          		$i++;
964 964
          	}
965 965
         }
966 966
         else
967 967
         {
968 968
             $error++;
969
-            $errorcode=$db->lasterrno();
970
-            $errorlabel=$db->lasterror();
969
+            $errorcode = $db->lasterrno();
970
+            $errorlabel = $db->lasterror();
971 971
         }
972 972
     }
973 973
 
@@ -998,53 +998,53 @@  discard block
 block discarded – undo
998 998
  * @param	$lang		$lang				Force lang
999 999
  * @return	array							Array result
1000 1000
  */
1001
-function getProductsForCategory($authentication,$id,$lang='')
1001
+function getProductsForCategory($authentication, $id, $lang = '')
1002 1002
 {
1003
-	global $db,$conf,$langs;
1003
+	global $db, $conf, $langs;
1004 1004
 
1005
-	$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
1005
+	$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
1006 1006
 	$langs->setDefaultLang($langcode);
1007 1007
 
1008 1008
 	dol_syslog("Function: getProductsForCategory login=".$authentication['login']." id=".$id);
1009 1009
 
1010
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
1010
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
1011 1011
 
1012
-	$objectresp=array();
1013
-	$errorcode='';$errorlabel='';
1014
-	$error=0;
1012
+	$objectresp = array();
1013
+	$errorcode = ''; $errorlabel = '';
1014
+	$error = 0;
1015 1015
 
1016
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
1016
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
1017 1017
 
1018 1018
 
1019
-	if (! $error && !$id)
1019
+	if (!$error && !$id)
1020 1020
 	{
1021 1021
 		$error++;
1022
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id must be provided.";
1022
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided.";
1023 1023
 	}
1024 1024
 
1025 1025
 
1026
-	if (! $error)
1026
+	if (!$error)
1027 1027
 	{
1028
-		$langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
1028
+		$langcode = ($lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
1029 1029
 		$langs->setDefaultLang($langcode);
1030 1030
 
1031 1031
 		$fuser->getrights();
1032 1032
 
1033 1033
 		if ($fuser->rights->produit->lire)
1034 1034
 		{
1035
-			$categorie=new Categorie($db);
1036
-			$result=$categorie->fetch($id);
1035
+			$categorie = new Categorie($db);
1036
+			$result = $categorie->fetch($id);
1037 1037
 			if ($result > 0)
1038 1038
 			{
1039 1039
 				$table = "product";
1040 1040
 				$field = "product";
1041 1041
 				$sql  = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table;
1042 1042
 				$sql .= " WHERE fk_categorie = ".$id;
1043
-				$sql .= " ORDER BY fk_".$field." ASC" ;
1043
+				$sql .= " ORDER BY fk_".$field." ASC";
1044 1044
 
1045 1045
 
1046 1046
 				dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG);
1047
-				$res  = $db->query($sql);
1047
+				$res = $db->query($sql);
1048 1048
 				if ($res)
1049 1049
 				{
1050 1050
 					while ($rec = $db->fetch_array($res))
@@ -1052,27 +1052,27 @@  discard block
 block discarded – undo
1052 1052
 						$obj = new Product($db);
1053 1053
 						$obj->fetch($rec['fk_'.$field]);
1054 1054
 						$iProduct = 0;
1055
-						if($obj->status > 0 )
1055
+						if ($obj->status > 0)
1056 1056
 						{
1057
-							$dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output);
1058
-							$pdir = get_exdir($obj->id,2,0,0,$product,'product') . $obj->id ."/photos/";
1059
-							$dir = $dir . '/'. $pdir;
1057
+							$dir = (!empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output);
1058
+							$pdir = get_exdir($obj->id, 2, 0, 0, $product, 'product').$obj->id."/photos/";
1059
+							$dir = $dir.'/'.$pdir;
1060 1060
 
1061 1061
 							$products[] = array(
1062 1062
 						    	'id' => $obj->id,
1063 1063
 					   			'ref' => $obj->ref,
1064 1064
 					   			'ref_ext' => $obj->ref_ext,
1065
-					    		'label' => ! empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label,
1066
-					    		'description' => ! empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description,
1067
-					    		'date_creation' => dol_print_date($obj->date_creation,'dayhourrfc'),
1068
-					    		'date_modification' => dol_print_date($obj->date_modification,'dayhourrfc'),
1069
-					            'note' => ! empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note,
1065
+					    		'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label,
1066
+					    		'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description,
1067
+					    		'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'),
1068
+					    		'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'),
1069
+					            'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note,
1070 1070
 					            'status_tosell' => $obj->status,
1071 1071
 					            'status_tobuy' => $obj->status_buy,
1072 1072
 		                		'type' => $obj->type,
1073 1073
 						        'barcode' => $obj->barcode,
1074 1074
 						        'barcode_type' => $obj->barcode_type,
1075
-		                		'country_id' => $obj->country_id>0?$obj->country_id:'',
1075
+		                		'country_id' => $obj->country_id > 0 ? $obj->country_id : '',
1076 1076
 						        'country_code' => $obj->country_code,
1077 1077
 						        'custom_code' => $obj->customcode,
1078 1078
 
@@ -1087,19 +1087,19 @@  discard block
 block discarded – undo
1087 1087
 						        'pmp' => $obj->pmp,
1088 1088
 		                		'import_key' => $obj->import_key,
1089 1089
 		                		'dir' => $pdir,
1090
-		                		'images' => $obj->liste_photos($dir,$nbmax=10)
1090
+		                		'images' => $obj->liste_photos($dir, $nbmax = 10)
1091 1091
 							);
1092 1092
 
1093 1093
 							//Retreive all extrafield for thirdsparty
1094 1094
 							// fetch optionals attributes and labels
1095
-							$extrafields=new ExtraFields($db);
1096
-							$extralabels=$extrafields->fetch_name_optionals_label('product',true);
1095
+							$extrafields = new ExtraFields($db);
1096
+							$extralabels = $extrafields->fetch_name_optionals_label('product', true);
1097 1097
 							//Get extrafield values
1098
-							$obj->fetch_optionals($obj->id,$extralabels);
1098
+							$obj->fetch_optionals($obj->id, $extralabels);
1099 1099
 
1100
-							foreach($extrafields->attribute_label as $key=>$label)
1100
+							foreach ($extrafields->attribute_label as $key=>$label)
1101 1101
 							{
1102
-								$products[$iProduct]=array_merge($products[$iProduct],array('options_'.$key => $obj->array_options['options_'.$key]));
1102
+								$products[$iProduct] = array_merge($products[$iProduct], array('options_'.$key => $obj->array_options['options_'.$key]));
1103 1103
 							}
1104 1104
 
1105 1105
 							$iProduct++;
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 				}
1117 1117
 				else
1118 1118
 				{
1119
-					$errorcode='NORECORDS_FOR_ASSOCIATION'; $errorlabel='No products associated'.$sql;
1119
+					$errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated'.$sql;
1120 1120
 					$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
1121 1121
 					dol_syslog("getProductsForCategory:: ".$c->error, LOG_DEBUG);
1122 1122
 
@@ -1125,13 +1125,13 @@  discard block
 block discarded – undo
1125 1125
 			else
1126 1126
 			{
1127 1127
 				$error++;
1128
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id;
1128
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id;
1129 1129
 			}
1130 1130
 		}
1131 1131
 		else
1132 1132
 		{
1133 1133
 			$error++;
1134
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
1134
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
1135 1135
 		}
1136 1136
 	}
1137 1137
 
Please login to merge, or discard this patch.
Braces   +80 added lines, -55 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
  *       \brief      File that is entry point to call Dolibarr WebServices
24 24
  */
25 25
 
26
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
26
+if (! defined("NOCSRFCHECK")) {
27
+	define("NOCSRFCHECK",'1');
28
+}
27 29
 
28 30
 require_once '../master.inc.php';
29 31
 require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
@@ -140,8 +142,7 @@  discard block
 block discarded – undo
140 142
 foreach($extrafields->attribute_label as $key=>$label)
141 143
 {
142 144
 	$type =$extrafields->attribute_type[$key];
143
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
144
-	else {$type='xsd:string';}
145
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
145 146
 
146 147
 	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
147 148
 }
@@ -341,7 +342,9 @@  discard block
 block discarded – undo
341 342
     $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT));
342 343
     $langs->setDefaultLang($langcode);
343 344
 
344
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
345
+    if ($authentication['entity']) {
346
+    	$conf->entity=$authentication['entity'];
347
+    }
345 348
 
346 349
     // Init and check authentication
347 350
     $objectresp=array();
@@ -376,9 +379,15 @@  discard block
 block discarded – undo
376 379
             	$pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/";
377 380
             	$dir = $dir . '/'. $pdir;
378 381
 
379
-            	if (! empty($product->multilangs[$langs->defaultlang]["label"]))     		$product->label =  $product->multilangs[$langs->defaultlang]["label"];
380
-            	if (! empty($product->multilangs[$langs->defaultlang]["description"]))     	$product->description =  $product->multilangs[$langs->defaultlang]["description"];
381
-            	if (! empty($product->multilangs[$langs->defaultlang]["note"]))     		$product->note =  $product->multilangs[$langs->defaultlang]["note"];
382
+            	if (! empty($product->multilangs[$langs->defaultlang]["label"])) {
383
+            		$product->label =  $product->multilangs[$langs->defaultlang]["label"];
384
+            	}
385
+            	if (! empty($product->multilangs[$langs->defaultlang]["description"])) {
386
+            		$product->description =  $product->multilangs[$langs->defaultlang]["description"];
387
+            	}
388
+            	if (! empty($product->multilangs[$langs->defaultlang]["note"])) {
389
+            		$product->note =  $product->multilangs[$langs->defaultlang]["note"];
390
+            	}
382 391
 
383 392
             	$productorservice_result_fields = array(
384 393
 	            	'id' => $product->id,
@@ -436,14 +445,12 @@  discard block
 block discarded – undo
436 445
 			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
437 446
 			        'product'=>$productorservice_result_fields
438 447
                 );
439
-            }
440
-            else
448
+            } else
441 449
             {
442 450
                 $error++;
443 451
                 $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
444 452
             }
445
-        }
446
-        else
453
+        } else
447 454
         {
448 455
             $error++;
449 456
             $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -474,7 +481,9 @@  discard block
 block discarded – undo
474 481
 
475 482
     dol_syslog("Function: createProductOrService login=".$authentication['login']);
476 483
 
477
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
484
+    if ($authentication['entity']) {
485
+    	$conf->entity=$authentication['entity'];
486
+    }
478 487
 
479 488
     // Init and check authentication
480 489
     $objectresp=array();
@@ -482,8 +491,12 @@  discard block
 block discarded – undo
482 491
     $error=0;
483 492
     $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
484 493
     // Check parameters
485
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
486
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
494
+    if ($product['price_net'] > 0) {
495
+    	$product['price_base_type']='HT';
496
+    }
497
+    if ($product['price'] > 0) {
498
+    	$product['price_base_type']='TTC';
499
+    }
487 500
 
488 501
     if ($product['price_net'] > 0 && $product['price'] > 0)
489 502
     {
@@ -528,7 +541,9 @@  discard block
 block discarded – undo
528 541
         $newobject->seuil_stock_alert=$product['stock_alert'];
529 542
 
530 543
         $newobject->country_id=$product['country_id'];
531
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
544
+        if ($product['country_code']) {
545
+        	$newobject->country_id=getCountry($product['country_code'],3);
546
+        }
532 547
         $newobject->customcode=$product['customcode'];
533 548
 
534 549
         $newobject->canvas=$product['canvas'];
@@ -594,8 +609,7 @@  discard block
 block discarded – undo
594 609
 							$error++;
595 610
 							$newobject->error='You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
596 611
 						}
597
-					}
598
-					else
612
+					} else
599 613
 					{
600 614
 						$error++;
601 615
 						$newobject->error='You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
@@ -608,8 +622,7 @@  discard block
 block discarded – undo
608 622
         {
609 623
             $db->commit();
610 624
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
611
-        }
612
-        else
625
+        } else
613 626
         {
614 627
             $db->rollback();
615 628
             $error++;
@@ -643,7 +656,9 @@  discard block
 block discarded – undo
643 656
 
644 657
     dol_syslog("Function: updateProductOrService login=".$authentication['login']);
645 658
 
646
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
659
+    if ($authentication['entity']) {
660
+    	$conf->entity=$authentication['entity'];
661
+    }
647 662
 
648 663
     // Init and check authentication
649 664
     $objectresp=array();
@@ -651,8 +666,12 @@  discard block
 block discarded – undo
651 666
     $error=0;
652 667
     $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
653 668
     // Check parameters
654
-    if ($product['price_net'] > 0) $product['price_base_type']='HT';
655
-    if ($product['price'] > 0)     $product['price_base_type']='TTC';
669
+    if ($product['price_net'] > 0) {
670
+    	$product['price_base_type']='HT';
671
+    }
672
+    if ($product['price'] > 0) {
673
+    	$product['price_base_type']='TTC';
674
+    }
656 675
 
657 676
     if ($product['price_net'] > 0 && $product['price'] > 0)
658 677
     {
@@ -672,8 +691,12 @@  discard block
 block discarded – undo
672 691
         $newobject=new Product($db);
673 692
         $newobject->fetch($product['id']);
674 693
 
675
-        if (isset($product['ref']))     $newobject->ref=$product['ref'];
676
-        if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext'];
694
+        if (isset($product['ref'])) {
695
+        	$newobject->ref=$product['ref'];
696
+        }
697
+        if (isset($product['ref_ext'])) {
698
+        	$newobject->ref_ext=$product['ref_ext'];
699
+        }
677 700
         $newobject->type=$product['type'];
678 701
         $newobject->libelle=$product['label'];    // @deprecated
679 702
         $newobject->label=$product['label'];
@@ -698,7 +721,9 @@  discard block
 block discarded – undo
698 721
         $newobject->seuil_stock_alert=$product['stock_alert'];
699 722
 
700 723
         $newobject->country_id=$product['country_id'];
701
-        if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3);
724
+        if ($product['country_code']) {
725
+        	$newobject->country_id=getCountry($product['country_code'],3);
726
+        }
702 727
         $newobject->customcode=$product['customcode'];
703 728
 
704 729
         $newobject->canvas=$product['canvas'];
@@ -732,8 +757,7 @@  discard block
 block discarded – undo
732 757
         if ($result <= 0)
733 758
         {
734 759
             $error++;
735
-        }
736
-        else
760
+        } else
737 761
 		{
738 762
         	// Update stock if stock count is provided and differs from database after creation or update
739 763
 			if (isset($product['stock_real']) && $product['stock_real'] != '' && ! empty($conf->global->stock->enabled))
@@ -763,8 +787,7 @@  discard block
 block discarded – undo
763 787
 							$error++;
764 788
 							$newobject->error='You set a different value for stock, but correction of stock count (before='.$getstockreal.', after='.$savstockreal.') fails with error '.$newobject->error;
765 789
 						}
766
-					}
767
-					else
790
+					} else
768 791
 					{
769 792
 						$error++;
770 793
 						$newobject->error='You set a different value for stock but we failed to find warehouse '.$product['warehouse_ref'].' to make correction.';
@@ -782,8 +805,7 @@  discard block
 block discarded – undo
782 805
                 {
783 806
                     $error++;
784 807
                 }
785
-            }
786
-            elseif ($newobject->price_base_type == 'TTC')
808
+            } elseif ($newobject->price_base_type == 'TTC')
787 809
             {
788 810
                 $result=$newobject->updatePrice($newobject->price_ttc, $newobject->price_base_type);
789 811
                 if ($result <= 0)
@@ -797,8 +819,7 @@  discard block
 block discarded – undo
797 819
         {
798 820
             $db->commit();
799 821
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
800
-        }
801
-        else
822
+        } else
802 823
 		{
803 824
             $db->rollback();
804 825
             $error++;
@@ -832,7 +853,9 @@  discard block
 block discarded – undo
832 853
 
833 854
     dol_syslog("Function: deleteProductOrService login=".$authentication['login']);
834 855
 
835
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
856
+    if ($authentication['entity']) {
857
+    	$conf->entity=$authentication['entity'];
858
+    }
836 859
 
837 860
     // Init and check authentication
838 861
     $objectresp=array();
@@ -869,8 +892,7 @@  discard block
 block discarded – undo
869 892
 	        	$error++;
870 893
 		        $firsterror='Product or service with id '.$id.' not found';
871 894
 		        break;
872
-	        }
873
-	        else
895
+	        } else
874 896
 			{
875 897
 		        $result=$newobject->delete($user);
876 898
 		        if ($result <= 0)
@@ -889,8 +911,7 @@  discard block
 block discarded – undo
889 911
 	        $db->commit();
890 912
             //$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'listofid'=>$listofiddeleted);
891 913
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'nbdeleted'=>count($listofiddeleted));
892
-	    }
893
-	    else
914
+	    } else
894 915
 	    {
895 916
 	    	$db->rollback();
896 917
 	        $error++;
@@ -903,8 +924,7 @@  discard block
 block discarded – undo
903 924
     {
904 925
         //$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'listofid'=>$listofiddeleted);
905 926
         $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'nbdeleted'=>0);
906
-    }
907
-    else if (count($listofiddeleted) == 0)
927
+    } else if (count($listofiddeleted) == 0)
908 928
     {
909 929
    		//$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'listofid'=>$listofiddeleted);
910 930
    		$objectresp=array('result'=>array('result_code'=>'NOT_FOUND', 'result_label'=>'No product or service with id '.join(',',$listofid).' found'), 'nbdeleted'=>0);
@@ -929,7 +949,9 @@  discard block
 block discarded – undo
929 949
 
930 950
     dol_syslog("Function: getListOfProductsOrServices login=".$authentication['login']);
931 951
 
932
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
952
+    if ($authentication['entity']) {
953
+    	$conf->entity=$authentication['entity'];
954
+    }
933 955
 
934 956
     // Init and check authentication
935 957
     $objectresp=array();
@@ -946,9 +968,15 @@  discard block
 block discarded – undo
946 968
         $sql.=" WHERE entity=".$conf->entity;
947 969
         foreach($filterproduct as $key => $val)
948 970
         {
949
-		if ($key == 'type' && $val >= 0)   	$sql.=" AND fk_product_type = ".$db->escape($val);
950
-		if ($key == 'status_tosell') 				$sql.=" AND tosell = ".$db->escape($val);
951
-		if ($key == 'status_tobuy')  				$sql.=" AND tobuy = ".$db->escape($val);
971
+		if ($key == 'type' && $val >= 0) {
972
+			$sql.=" AND fk_product_type = ".$db->escape($val);
973
+		}
974
+		if ($key == 'status_tosell') {
975
+			$sql.=" AND tosell = ".$db->escape($val);
976
+		}
977
+		if ($key == 'status_tobuy') {
978
+			$sql.=" AND tobuy = ".$db->escape($val);
979
+		}
952 980
         }
953 981
 		$resql=$db->query($sql);
954 982
         if ($resql)
@@ -962,8 +990,7 @@  discard block
 block discarded – undo
962 990
          		$arrayproducts[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
963 991
          		$i++;
964 992
          	}
965
-        }
966
-        else
993
+        } else
967 994
         {
968 995
             $error++;
969 996
             $errorcode=$db->lasterrno();
@@ -977,8 +1004,7 @@  discard block
 block discarded – undo
977 1004
 			'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
978 1005
         	'products'=>$arrayproducts
979 1006
         );
980
-    }
981
-    else
1007
+    } else
982 1008
     {
983 1009
         $objectresp = array(
984 1010
 			'result'=>array('result_code' => 'OK', 'result_label' => ''),
@@ -1007,7 +1033,9 @@  discard block
 block discarded – undo
1007 1033
 
1008 1034
 	dol_syslog("Function: getProductsForCategory login=".$authentication['login']." id=".$id);
1009 1035
 
1010
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
1036
+	if ($authentication['entity']) {
1037
+		$conf->entity=$authentication['entity'];
1038
+	}
1011 1039
 
1012 1040
 	$objectresp=array();
1013 1041
 	$errorcode='';$errorlabel='';
@@ -1113,22 +1141,19 @@  discard block
 block discarded – undo
1113 1141
 					'products'=> $products
1114 1142
 					);
1115 1143
 
1116
-				}
1117
-				else
1144
+				} else
1118 1145
 				{
1119 1146
 					$errorcode='NORECORDS_FOR_ASSOCIATION'; $errorlabel='No products associated'.$sql;
1120 1147
 					$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
1121 1148
 					dol_syslog("getProductsForCategory:: ".$c->error, LOG_DEBUG);
1122 1149
 
1123 1150
 				}
1124
-			}
1125
-			else
1151
+			} else
1126 1152
 			{
1127 1153
 				$error++;
1128 1154
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id;
1129 1155
 			}
1130
-		}
1131
-		else
1156
+		} else
1132 1157
 		{
1133 1158
 			$error++;
1134 1159
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
Please login to merge, or discard this patch.
htdocs/webservices/server_payment.php 3 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 // Enable and test if module web services is enabled
45 45
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
46 46
 {
47
-       $langs->load("admin");
48
-       dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
-       print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
50
-       print $langs->trans("ToActivateModule");
51
-       exit;
47
+	   $langs->load("admin");
48
+	   dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
+	   print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
50
+	   print $langs->trans("ToActivateModule");
51
+	   exit;
52 52
 }
53 53
 
54 54
 // Create the soap Object
@@ -62,50 +62,50 @@  discard block
 block discarded – undo
62 62
 
63 63
 // Define WSDL Authentication object
64 64
 $server->wsdl->addComplexType(
65
-    'authentication',
66
-    'complexType',
67
-    'struct',
68
-    'all',
69
-    '',
70
-    array(
71
-        'dolibarrkey'       => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
-       'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
-       'login'             => array('name'=>'login','type'=>'xsd:string'),
74
-        'password'          => array('name'=>'password','type'=>'xsd:string'),
75
-        'entity'            => array('name'=>'entity','type'=>'xsd:string')
76
-    )
65
+	'authentication',
66
+	'complexType',
67
+	'struct',
68
+	'all',
69
+	'',
70
+	array(
71
+		'dolibarrkey'       => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
+	   'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
+	   'login'             => array('name'=>'login','type'=>'xsd:string'),
74
+		'password'          => array('name'=>'password','type'=>'xsd:string'),
75
+		'entity'            => array('name'=>'entity','type'=>'xsd:string')
76
+	)
77 77
 );
78 78
 // Define WSDL Return object
79 79
 $server->wsdl->addComplexType(
80
-    'result',
81
-    'complexType',
82
-    'struct',
83
-    'all',
84
-    '',
85
-    array(
86
-        'result_code'  => array('name'=>'result_code','type'=>'xsd:string'),
87
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
88
-    )
80
+	'result',
81
+	'complexType',
82
+	'struct',
83
+	'all',
84
+	'',
85
+	array(
86
+		'result_code'  => array('name'=>'result_code','type'=>'xsd:string'),
87
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
88
+	)
89 89
 );
90 90
 
91 91
 // Define WSDL for Payment object
92 92
 $server->wsdl->addComplexType(
93
-    'payment',
94
-    'complexType',
95
-    'struct',
96
-    'all',
97
-    '',
98
-    array(
99
-        'amount'          => array('name'=>'amount','type'=>'xsd:double'),
100
-        'num_paiement'    => array('name'=>'num_paiement','type'=>'xsd:string'),
101
-        'thirdparty_id'   => array('name'=>'thirdparty_id','type'=>'xsd:int'),
102
-               'bank_account'    => array('name'=>'bank_account','type'=>'xsd:int'),
103
-               'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:int'),
104
-               'invoice_id'      => array('name'=>'invoice_id','type'=>'xsd:int'),
105
-               'int_label'       => array('name'=>'int_label','type'=>'xsd:string'),
106
-               'emitter'         => array('name'=>'emitter','type'=>'xsd:string'),
107
-               'bank_source'     => array('name'=>'bank_source','type'=>'xsd:string'),
108
-    )
93
+	'payment',
94
+	'complexType',
95
+	'struct',
96
+	'all',
97
+	'',
98
+	array(
99
+		'amount'          => array('name'=>'amount','type'=>'xsd:double'),
100
+		'num_paiement'    => array('name'=>'num_paiement','type'=>'xsd:string'),
101
+		'thirdparty_id'   => array('name'=>'thirdparty_id','type'=>'xsd:int'),
102
+			   'bank_account'    => array('name'=>'bank_account','type'=>'xsd:int'),
103
+			   'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:int'),
104
+			   'invoice_id'      => array('name'=>'invoice_id','type'=>'xsd:int'),
105
+			   'int_label'       => array('name'=>'int_label','type'=>'xsd:string'),
106
+			   'emitter'         => array('name'=>'emitter','type'=>'xsd:string'),
107
+			   'bank_source'     => array('name'=>'bank_source','type'=>'xsd:string'),
108
+	)
109 109
 );
110 110
 
111 111
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 
118 118
 // Register WSDL
119 119
 $server->register(
120
-    'createPayment',
121
-    // Entry values
122
-    array('authentication'=>'tns:authentication','payment'=>'tns:payment'),
123
-    // Exit values
124
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
125
-    $ns,
126
-    $ns.'#createPayment',
127
-    $styledoc,
128
-    $styleuse,
129
-    'WS to create a new payment'
120
+	'createPayment',
121
+	// Entry values
122
+	array('authentication'=>'tns:authentication','payment'=>'tns:payment'),
123
+	// Exit values
124
+	array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
125
+	$ns,
126
+	$ns.'#createPayment',
127
+	$styledoc,
128
+	$styleuse,
129
+	'WS to create a new payment'
130 130
 );
131 131
 
132 132
 
@@ -139,80 +139,80 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function createPayment($authentication, $payment)
141 141
 {
142
-    global $db,$conf,$langs;
143
-
144
-    $now = dol_now();
145
-
146
-    dol_syslog("Function: createPayment login=".$authentication['login']." id=".$payment->id.
147
-               ", ref=".$payment->ref.", ref_ext=".$payment->ref_ext);
148
-
149
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
150
-
151
-    // Init and check authentication
152
-    $objectresp = array();
153
-    $errorcode  = '';
154
-       $errorlabel = '';
155
-    $error      = 0;
156
-    $fuser      = check_authentication($authentication,$error,$errorcode,$errorlabel);
157
-
158
-    // Check parameters
159
-    if (empty($payment['amount']) && empty($payment['thirdparty_id'])) {
160
-       $error++;
161
-               $errorcode  ='KO';
162
-               $errorlabel ="You must specify the amount and the third party's ID.";
163
-    }
164
-
165
-    if (! $error)
166
-    {
167
-               $soc = new Societe($db);
168
-        $res = $soc->fetch($payment['thirdparty_id']);
169
-
170
-               $new_payment               = new Paiement($db);
171
-               $new_payment->amount       = doubleval($payment['amount']);
172
-               $new_payment->num_paiement = $payment['num_paiement'];
173
-               $new_payment->bank_account = intval($payment['bank_account']);
174
-               $new_payment->paiementid   = !empty($payment['payment_mode_id']) ? intval($payment['payment_mode_id']) : $soc->mode_reglement_id;
175
-               $new_payment->datepaye     = $now;
176
-               $new_payment->author       = $payment['thirdparty_id'];
177
-               $new_payment->amounts      = array();
178
-
179
-               if(intval($payment['invoice_id']) > 0) {
180
-                       $new_payment->amounts[ $payment['invoice_id'] ] = $new_payment->amount;
181
-               }
182
-
183
-        $db->begin();
184
-               $result = $new_payment->create($fuser, true);
185
-
186
-               if($payment['bank_account']) {
187
-                       $new_payment->addPaymentToBank($fuser, 'payment', $payment['int_label'], $payment['bank_account'], $payment['emitter'], $payment['bank_source']);
188
-               }
189
-
190
-        if ($result < 0)
191
-        {
192
-            $error++;
193
-        }
194
-
195
-        if (! $error)
196
-        {
197
-            $db->commit();
198
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_payment->id);
199
-        }
200
-        else
201
-        {
202
-            $db->rollback();
203
-            $error++;
204
-            $errorcode='KO';
205
-            $errorlabel=$new_payment->error;
206
-            dol_syslog("Function: createInvoice error while creating".$errorlabel);
207
-        }
208
-    }
209
-
210
-    if ($error)
211
-    {
212
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
213
-    }
214
-
215
-    return $objectresp;
142
+	global $db,$conf,$langs;
143
+
144
+	$now = dol_now();
145
+
146
+	dol_syslog("Function: createPayment login=".$authentication['login']." id=".$payment->id.
147
+			   ", ref=".$payment->ref.", ref_ext=".$payment->ref_ext);
148
+
149
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
150
+
151
+	// Init and check authentication
152
+	$objectresp = array();
153
+	$errorcode  = '';
154
+	   $errorlabel = '';
155
+	$error      = 0;
156
+	$fuser      = check_authentication($authentication,$error,$errorcode,$errorlabel);
157
+
158
+	// Check parameters
159
+	if (empty($payment['amount']) && empty($payment['thirdparty_id'])) {
160
+	   $error++;
161
+			   $errorcode  ='KO';
162
+			   $errorlabel ="You must specify the amount and the third party's ID.";
163
+	}
164
+
165
+	if (! $error)
166
+	{
167
+			   $soc = new Societe($db);
168
+		$res = $soc->fetch($payment['thirdparty_id']);
169
+
170
+			   $new_payment               = new Paiement($db);
171
+			   $new_payment->amount       = doubleval($payment['amount']);
172
+			   $new_payment->num_paiement = $payment['num_paiement'];
173
+			   $new_payment->bank_account = intval($payment['bank_account']);
174
+			   $new_payment->paiementid   = !empty($payment['payment_mode_id']) ? intval($payment['payment_mode_id']) : $soc->mode_reglement_id;
175
+			   $new_payment->datepaye     = $now;
176
+			   $new_payment->author       = $payment['thirdparty_id'];
177
+			   $new_payment->amounts      = array();
178
+
179
+			   if(intval($payment['invoice_id']) > 0) {
180
+					   $new_payment->amounts[ $payment['invoice_id'] ] = $new_payment->amount;
181
+			   }
182
+
183
+		$db->begin();
184
+			   $result = $new_payment->create($fuser, true);
185
+
186
+			   if($payment['bank_account']) {
187
+					   $new_payment->addPaymentToBank($fuser, 'payment', $payment['int_label'], $payment['bank_account'], $payment['emitter'], $payment['bank_source']);
188
+			   }
189
+
190
+		if ($result < 0)
191
+		{
192
+			$error++;
193
+		}
194
+
195
+		if (! $error)
196
+		{
197
+			$db->commit();
198
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_payment->id);
199
+		}
200
+		else
201
+		{
202
+			$db->rollback();
203
+			$error++;
204
+			$errorcode='KO';
205
+			$errorlabel=$new_payment->error;
206
+			dol_syslog("Function: createInvoice error while creating".$errorlabel);
207
+		}
208
+	}
209
+
210
+	if ($error)
211
+	{
212
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
213
+	}
214
+
215
+	return $objectresp;
216 216
 }
217 217
 
218 218
 // Return the results.
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
29 29
 
30 30
 require_once '../master.inc.php';
31
-require_once NUSOAP_PATH.'/nusoap.php';                // Include SOAP
31
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 33
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
34 34
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 {
47 47
        $langs->load("admin");
48 48
        dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
49
-       print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
49
+       print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
50 50
        print $langs->trans("ToActivateModule");
51 51
        exit;
52 52
 }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 $server->soap_defencoding            = 'UTF-8';
57 57
 $server->decode_utf8                 = false;
58 58
 $ns                                  = 'http://www.dolibarr.org/ns/';
59
-$server->configureWSDL('WebServicesDolibarrPayment',$ns);
59
+$server->configureWSDL('WebServicesDolibarrPayment', $ns);
60 60
 $server->wsdl->schemaTargetNamespace = $ns;
61 61
 
62 62
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
     'all',
69 69
     '',
70 70
     array(
71
-        'dolibarrkey'       => array('name'=>'dolibarrkey','type'=>'xsd:string'),
72
-       'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
73
-       'login'             => array('name'=>'login','type'=>'xsd:string'),
74
-        'password'          => array('name'=>'password','type'=>'xsd:string'),
75
-        'entity'            => array('name'=>'entity','type'=>'xsd:string')
71
+        'dolibarrkey'       => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
72
+       'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
73
+       'login'             => array('name'=>'login', 'type'=>'xsd:string'),
74
+        'password'          => array('name'=>'password', 'type'=>'xsd:string'),
75
+        'entity'            => array('name'=>'entity', 'type'=>'xsd:string')
76 76
     )
77 77
 );
78 78
 // Define WSDL Return object
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
     'all',
84 84
     '',
85 85
     array(
86
-        'result_code'  => array('name'=>'result_code','type'=>'xsd:string'),
87
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
86
+        'result_code'  => array('name'=>'result_code', 'type'=>'xsd:string'),
87
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
88 88
     )
89 89
 );
90 90
 
@@ -96,32 +96,32 @@  discard block
 block discarded – undo
96 96
     'all',
97 97
     '',
98 98
     array(
99
-        'amount'          => array('name'=>'amount','type'=>'xsd:double'),
100
-        'num_paiement'    => array('name'=>'num_paiement','type'=>'xsd:string'),
101
-        'thirdparty_id'   => array('name'=>'thirdparty_id','type'=>'xsd:int'),
102
-               'bank_account'    => array('name'=>'bank_account','type'=>'xsd:int'),
103
-               'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:int'),
104
-               'invoice_id'      => array('name'=>'invoice_id','type'=>'xsd:int'),
105
-               'int_label'       => array('name'=>'int_label','type'=>'xsd:string'),
106
-               'emitter'         => array('name'=>'emitter','type'=>'xsd:string'),
107
-               'bank_source'     => array('name'=>'bank_source','type'=>'xsd:string'),
99
+        'amount'          => array('name'=>'amount', 'type'=>'xsd:double'),
100
+        'num_paiement'    => array('name'=>'num_paiement', 'type'=>'xsd:string'),
101
+        'thirdparty_id'   => array('name'=>'thirdparty_id', 'type'=>'xsd:int'),
102
+               'bank_account'    => array('name'=>'bank_account', 'type'=>'xsd:int'),
103
+               'payment_mode_id' => array('name'=>'payment_mode_id', 'type'=>'xsd:int'),
104
+               'invoice_id'      => array('name'=>'invoice_id', 'type'=>'xsd:int'),
105
+               'int_label'       => array('name'=>'int_label', 'type'=>'xsd:string'),
106
+               'emitter'         => array('name'=>'emitter', 'type'=>'xsd:string'),
107
+               'bank_source'     => array('name'=>'bank_source', 'type'=>'xsd:string'),
108 108
     )
109 109
 );
110 110
 
111 111
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
112 112
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
113 113
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
114
-$styledoc = 'rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
115
-$styleuse = 'encoded';   // encoded/literal/literal wrapped
114
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
115
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
116 116
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
117 117
 
118 118
 // Register WSDL
119 119
 $server->register(
120 120
     'createPayment',
121 121
     // Entry values
122
-    array('authentication'=>'tns:authentication','payment'=>'tns:payment'),
122
+    array('authentication'=>'tns:authentication', 'payment'=>'tns:payment'),
123 123
     // Exit values
124
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
124
+    array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
125 125
     $ns,
126 126
     $ns.'#createPayment',
127 127
     $styledoc,
@@ -139,30 +139,30 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function createPayment($authentication, $payment)
141 141
 {
142
-    global $db,$conf,$langs;
142
+    global $db, $conf, $langs;
143 143
 
144 144
     $now = dol_now();
145 145
 
146 146
     dol_syslog("Function: createPayment login=".$authentication['login']." id=".$payment->id.
147 147
                ", ref=".$payment->ref.", ref_ext=".$payment->ref_ext);
148 148
 
149
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
149
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
150 150
 
151 151
     // Init and check authentication
152 152
     $objectresp = array();
153 153
     $errorcode  = '';
154 154
        $errorlabel = '';
155 155
     $error      = 0;
156
-    $fuser      = check_authentication($authentication,$error,$errorcode,$errorlabel);
156
+    $fuser      = check_authentication($authentication, $error, $errorcode, $errorlabel);
157 157
 
158 158
     // Check parameters
159 159
     if (empty($payment['amount']) && empty($payment['thirdparty_id'])) {
160 160
        $error++;
161
-               $errorcode  ='KO';
162
-               $errorlabel ="You must specify the amount and the third party's ID.";
161
+               $errorcode  = 'KO';
162
+               $errorlabel = "You must specify the amount and the third party's ID.";
163 163
     }
164 164
 
165
-    if (! $error)
165
+    if (!$error)
166 166
     {
167 167
                $soc = new Societe($db);
168 168
         $res = $soc->fetch($payment['thirdparty_id']);
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
                $new_payment->author       = $payment['thirdparty_id'];
177 177
                $new_payment->amounts      = array();
178 178
 
179
-               if(intval($payment['invoice_id']) > 0) {
180
-                       $new_payment->amounts[ $payment['invoice_id'] ] = $new_payment->amount;
179
+               if (intval($payment['invoice_id']) > 0) {
180
+                       $new_payment->amounts[$payment['invoice_id']] = $new_payment->amount;
181 181
                }
182 182
 
183 183
         $db->begin();
184 184
                $result = $new_payment->create($fuser, true);
185 185
 
186
-               if($payment['bank_account']) {
186
+               if ($payment['bank_account']) {
187 187
                        $new_payment->addPaymentToBank($fuser, 'payment', $payment['int_label'], $payment['bank_account'], $payment['emitter'], $payment['bank_source']);
188 188
                }
189 189
 
@@ -192,17 +192,17 @@  discard block
 block discarded – undo
192 192
             $error++;
193 193
         }
194 194
 
195
-        if (! $error)
195
+        if (!$error)
196 196
         {
197 197
             $db->commit();
198
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_payment->id);
198
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$new_payment->id);
199 199
         }
200 200
         else
201 201
         {
202 202
             $db->rollback();
203 203
             $error++;
204
-            $errorcode='KO';
205
-            $errorlabel=$new_payment->error;
204
+            $errorcode = 'KO';
205
+            $errorlabel = $new_payment->error;
206 206
             dol_syslog("Function: createInvoice error while creating".$errorlabel);
207 207
         }
208 208
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -146,7 +146,9 @@  discard block
 block discarded – undo
146 146
     dol_syslog("Function: createPayment login=".$authentication['login']." id=".$payment->id.
147 147
                ", ref=".$payment->ref.", ref_ext=".$payment->ref_ext);
148 148
 
149
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
149
+    if ($authentication['entity']) {
150
+    	$conf->entity=$authentication['entity'];
151
+    }
150 152
 
151 153
     // Init and check authentication
152 154
     $objectresp = array();
@@ -196,8 +198,7 @@  discard block
 block discarded – undo
196 198
         {
197 199
             $db->commit();
198 200
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_payment->id);
199
-        }
200
-        else
201
+        } else
201 202
         {
202 203
             $db->rollback();
203 204
             $error++;
Please login to merge, or discard this patch.
htdocs/webservices/server_supplier_invoice.php 3 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -55,127 +55,127 @@  discard block
 block discarded – undo
55 55
 
56 56
 // Define WSDL Authentication object
57 57
 $server->wsdl->addComplexType(
58
-    'authentication',
59
-    'complexType',
60
-    'struct',
61
-    'all',
62
-    '',
63
-    array(
64
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
67
-        'password' => array('name'=>'password','type'=>'xsd:string'),
68
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
69
-    )
58
+	'authentication',
59
+	'complexType',
60
+	'struct',
61
+	'all',
62
+	'',
63
+	array(
64
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
+		'login' => array('name'=>'login','type'=>'xsd:string'),
67
+		'password' => array('name'=>'password','type'=>'xsd:string'),
68
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
69
+	)
70 70
 );
71 71
 // Define WSDL Return object
72 72
 $server->wsdl->addComplexType(
73
-    'result',
74
-    'complexType',
75
-    'struct',
76
-    'all',
77
-    '',
78
-    array(
79
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
81
-    )
73
+	'result',
74
+	'complexType',
75
+	'struct',
76
+	'all',
77
+	'',
78
+	array(
79
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
81
+	)
82 82
 );
83 83
 
84 84
 // Define other specific objects
85 85
 $server->wsdl->addComplexType(
86
-    'line',
87
-    'element',
88
-    'struct',
89
-    'all',
90
-    '',
91
-    array(
92
-        'id' => array('name'=>'id','type'=>'xsd:string'),
93
-        'type' => array('name'=>'type','type'=>'xsd:int'),
94
-        'desc' => array('name'=>'desc','type'=>'xsd:string'),
95
-    	'fk_product' => array('name'=>'fk_product','type'=>'xsd:int'),
96
-        'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
97
-    	'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
98
-    	'total' => array('name'=>'total','type'=>'xsd:double'),
99
-        'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
100
-        'qty' => array('name'=>'qty','type'=>'xsd:double'),
101
-        'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
102
-        'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
103
-        // From product
104
-        'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
105
-        'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
106
-        'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
107
-    )
86
+	'line',
87
+	'element',
88
+	'struct',
89
+	'all',
90
+	'',
91
+	array(
92
+		'id' => array('name'=>'id','type'=>'xsd:string'),
93
+		'type' => array('name'=>'type','type'=>'xsd:int'),
94
+		'desc' => array('name'=>'desc','type'=>'xsd:string'),
95
+		'fk_product' => array('name'=>'fk_product','type'=>'xsd:int'),
96
+		'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
97
+		'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
98
+		'total' => array('name'=>'total','type'=>'xsd:double'),
99
+		'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
100
+		'qty' => array('name'=>'qty','type'=>'xsd:double'),
101
+		'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
102
+		'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
103
+		// From product
104
+		'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
105
+		'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
106
+		'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
107
+	)
108 108
 );
109 109
 
110 110
 $server->wsdl->addComplexType(
111
-    'LinesArray',
112
-    'complexType',
113
-    'array',
114
-    '',
115
-    'SOAP-ENC:Array',
116
-    array(),
117
-    array(
118
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:line[]')
119
-    ),
120
-    'tns:line'
111
+	'LinesArray',
112
+	'complexType',
113
+	'array',
114
+	'',
115
+	'SOAP-ENC:Array',
116
+	array(),
117
+	array(
118
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:line[]')
119
+	),
120
+	'tns:line'
121 121
 );
122 122
 
123 123
 $server->wsdl->addComplexType(
124
-    'invoice',
125
-    'element',		// If we put element here instead of complexType to have tag called invoice in getInvoicesForThirdParty we brek getInvoice
126
-    'struct',
127
-    'all',
128
-    '',
129
-    array(
130
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
131
-        'ref' => array('name'=>'ref','type'=>'xsd:string'),
132
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
133
-        'ref_supplier' => array('name'=>'ref_supplier','type'=>'xsd:string'),
134
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:int'),
135
-        'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:int'),
136
-        'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:int'),
137
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
138
-        'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
139
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
140
-        'date_invoice' => array('name'=>'date_invoice','type'=>'xsd:date'),
141
-        'date_term' => array('name'=>'date_modification','type'=>'xsd:date'),
142
-        'type' => array('name'=>'type','type'=>'xsd:int'),
143
-        'total_net' => array('name'=>'type','type'=>'xsd:double'),
144
-        'total_vat' => array('name'=>'type','type'=>'xsd:double'),
145
-        'total' => array('name'=>'type','type'=>'xsd:double'),
146
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
147
-        'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
148
-        'status' => array('name'=>'status','type'=>'xsd:int'),
149
-        'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
150
-        'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
151
-    	'lines' => array('name'=>'lines','type'=>'tns:LinesArray')
152
-    )
124
+	'invoice',
125
+	'element',		// If we put element here instead of complexType to have tag called invoice in getInvoicesForThirdParty we brek getInvoice
126
+	'struct',
127
+	'all',
128
+	'',
129
+	array(
130
+		'id' => array('name'=>'id','type'=>'xsd:string'),
131
+		'ref' => array('name'=>'ref','type'=>'xsd:string'),
132
+		'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
133
+		'ref_supplier' => array('name'=>'ref_supplier','type'=>'xsd:string'),
134
+		'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:int'),
135
+		'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:int'),
136
+		'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:int'),
137
+		'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
138
+		'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
139
+		'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
140
+		'date_invoice' => array('name'=>'date_invoice','type'=>'xsd:date'),
141
+		'date_term' => array('name'=>'date_modification','type'=>'xsd:date'),
142
+		'type' => array('name'=>'type','type'=>'xsd:int'),
143
+		'total_net' => array('name'=>'type','type'=>'xsd:double'),
144
+		'total_vat' => array('name'=>'type','type'=>'xsd:double'),
145
+		'total' => array('name'=>'type','type'=>'xsd:double'),
146
+		'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
147
+		'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
148
+		'status' => array('name'=>'status','type'=>'xsd:int'),
149
+		'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
150
+		'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
151
+		'lines' => array('name'=>'lines','type'=>'tns:LinesArray')
152
+	)
153 153
 );
154 154
 
155 155
 $server->wsdl->addComplexType(
156
-    'InvoicesArray',
157
-    'complexType',
158
-    'array',
159
-    '',
160
-    'SOAP-ENC:Array',
161
-    array(),
162
-    array(
163
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
164
-    ),
165
-    'tns:invoice'
156
+	'InvoicesArray',
157
+	'complexType',
158
+	'array',
159
+	'',
160
+	'SOAP-ENC:Array',
161
+	array(),
162
+	array(
163
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
164
+	),
165
+	'tns:invoice'
166 166
 );
167 167
 
168 168
 $server->wsdl->addComplexType(
169
-    'invoices',
170
-    'complexType',
171
-    'array',
172
-    '',
173
-    'SOAP-ENC:Array',
174
-    array(),
175
-    array(
176
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
177
-    ),
178
-    'tns:invoice'
169
+	'invoices',
170
+	'complexType',
171
+	'array',
172
+	'',
173
+	'SOAP-ENC:Array',
174
+	array(),
175
+	array(
176
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
177
+	),
178
+	'tns:invoice'
179 179
 );
180 180
 
181 181
 
@@ -189,28 +189,28 @@  discard block
 block discarded – undo
189 189
 
190 190
 // Register WSDL
191 191
 $server->register(
192
-    'getSupplierInvoice',
193
-    // Entry values
194
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
195
-    // Exit values
196
-    array('result'=>'tns:result','invoice'=>'tns:invoice'),
197
-    $ns,
198
-    $ns.'#getSupplierInvoice',
199
-    $styledoc,
200
-    $styleuse,
201
-    'WS to get SupplierInvoice'
192
+	'getSupplierInvoice',
193
+	// Entry values
194
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
195
+	// Exit values
196
+	array('result'=>'tns:result','invoice'=>'tns:invoice'),
197
+	$ns,
198
+	$ns.'#getSupplierInvoice',
199
+	$styledoc,
200
+	$styleuse,
201
+	'WS to get SupplierInvoice'
202 202
 );
203 203
 $server->register(
204
-    'getSupplierInvoicesForThirdParty',
205
-    // Entry values
206
-    array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
207
-    // Exit values
208
-    array('result'=>'tns:result','invoices'=>'tns:invoices'),
209
-    $ns,
210
-    $ns.'#getSupplierInvoicesForThirdParty',
211
-    $styledoc,
212
-    $styleuse,
213
-    'WS to get SupplierInvoicesForThirdParty'
204
+	'getSupplierInvoicesForThirdParty',
205
+	// Entry values
206
+	array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
207
+	// Exit values
208
+	array('result'=>'tns:result','invoices'=>'tns:invoices'),
209
+	$ns,
210
+	$ns.'#getSupplierInvoicesForThirdParty',
211
+	$styledoc,
212
+	$styleuse,
213
+	'WS to get SupplierInvoicesForThirdParty'
214 214
 );
215 215
 
216 216
 
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 
232 232
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
233 233
 
234
-    // Init and check authentication
235
-    $objectresp=array();
236
-    $errorcode='';$errorlabel='';
237
-    $error=0;
238
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
239
-    // Check parameters
234
+	// Init and check authentication
235
+	$objectresp=array();
236
+	$errorcode='';$errorlabel='';
237
+	$error=0;
238
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
239
+	// Check parameters
240 240
 	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
241 241
 	{
242 242
 		$error++;
@@ -264,44 +264,44 @@  discard block
 block discarded – undo
264 264
 						'total_net'=>$line->total_ht,
265 265
 						'total_vat'=>$line->total_tva,
266 266
 						'total'=>$line->total_ttc,
267
-                        'vat_rate'=>$line->tva_tx,
268
-                        'qty'=>$line->qty
267
+						'vat_rate'=>$line->tva_tx,
268
+						'qty'=>$line->qty
269 269
 					);
270 270
 					$i++;
271 271
 				}
272 272
 
273
-			    // Create invoice
274
-			    $objectresp = array(
275
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
276
-			        'invoice'=>array(
277
-				    	'id' => $invoice->id,
273
+				// Create invoice
274
+				$objectresp = array(
275
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
276
+					'invoice'=>array(
277
+						'id' => $invoice->id,
278 278
 			   			'ref' => $invoice->ref,
279
-                        'ref_supplier'=>$invoice->ref_supplier,
280
-			            'ref_ext' => $invoice->ref_ext,
281
-			            'fk_user_author' => $invoice->fk_user_author,
282
-			            'fk_user_valid' => $invoice->fk_user_valid,
283
-                        'fk_thirdparty' => $invoice->fk_soc,
284
-                        'type'=>$invoice->type,
285
-                        'status'=>$invoice->statut,
286
-                        'total_net'=>$invoice->total_ht,
287
-                        'total_vat'=>$invoice->total_tva,
288
-                        'total'=>$invoice->total_ttc,
289
-                        'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
290
-                        'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
291
-                        'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
292
-                        'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
293
-                        'label'=>$invoice->libelle,
294
-                        'paid'=>$invoice->paye,
295
-                        'note_private'=>$invoice->note_private,
296
-                        'note_public'=>$invoice->note_public,
297
-                        'close_code'=>$invoice->close_code,
298
-                        'close_note'=>$invoice->close_note,
299
-
300
-                        'lines' => $linesresp
279
+						'ref_supplier'=>$invoice->ref_supplier,
280
+						'ref_ext' => $invoice->ref_ext,
281
+						'fk_user_author' => $invoice->fk_user_author,
282
+						'fk_user_valid' => $invoice->fk_user_valid,
283
+						'fk_thirdparty' => $invoice->fk_soc,
284
+						'type'=>$invoice->type,
285
+						'status'=>$invoice->statut,
286
+						'total_net'=>$invoice->total_ht,
287
+						'total_vat'=>$invoice->total_tva,
288
+						'total'=>$invoice->total_ttc,
289
+						'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
290
+						'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
291
+						'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
292
+						'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
293
+						'label'=>$invoice->libelle,
294
+						'paid'=>$invoice->paye,
295
+						'note_private'=>$invoice->note_private,
296
+						'note_public'=>$invoice->note_public,
297
+						'close_code'=>$invoice->close_code,
298
+						'close_note'=>$invoice->close_note,
299
+
300
+						'lines' => $linesresp
301 301
 //					        'lines' => array('0'=>array('id'=>222,'type'=>1),
302 302
 //				        				 '1'=>array('id'=>333,'type'=>1))
303 303
 
304
-			    ));
304
+				));
305 305
 			}
306 306
 			else
307 307
 			{
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 
342 342
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
343 343
 
344
-    // Init and check authentication
345
-    $objectresp=array();
346
-    $errorcode='';$errorlabel='';
347
-    $error=0;
348
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
349
-    // Check parameters
344
+	// Init and check authentication
345
+	$objectresp=array();
346
+	$errorcode='';$errorlabel='';
347
+	$error=0;
348
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
349
+	// Check parameters
350 350
 	if (! $error && empty($idthirdparty))
351 351
 	{
352 352
 		$error++;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		//$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
364 364
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
365 365
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
366
-        $sql.=" WHERE f.entity = ".$conf->entity;
366
+		$sql.=" WHERE f.entity = ".$conf->entity;
367 367
 		if ($idthirdparty != 'all') $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
368 368
 
369 369
 		$resql=$db->query($sql);
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
 			$i=0;
374 374
 			while ($i < $num)
375 375
 			{
376
-                // En attendant remplissage par boucle
377
-			    $obj=$db->fetch_object($resql);
376
+				// En attendant remplissage par boucle
377
+				$obj=$db->fetch_object($resql);
378 378
 
379
-			    $invoice=new FactureFournisseur($db);
380
-			    $result=$invoice->fetch($obj->facid);
379
+				$invoice=new FactureFournisseur($db);
380
+				$result=$invoice->fetch($obj->facid);
381 381
 				if ($result < 0)
382 382
 				{
383 383
 					$error++;
@@ -389,55 +389,55 @@  discard block
 block discarded – undo
389 389
 				$linesresp=array();
390 390
 				foreach($invoice->lines as $line)
391 391
 				{
392
-   				    $linesresp[]=array(
393
-    					'id'=>$line->rowid,
394
-    					'type'=>$line->product_type,
395
-                        'desc'=>dol_htmlcleanlastbr($line->description),
396
-    					'total_net'=>$line->total_ht,
397
-    					'total_vat'=>$line->total_tva,
398
-    					'total'=>$line->total_ttc,
399
-                        'vat_rate'=>$line->tva_tx,
400
-                        'qty'=>$line->qty,
401
-   				        'product_ref'=>$line->product_ref,
402
-                        'product_label'=>$line->product_label,
403
-                        'product_desc'=>$line->product_desc,
404
-   				    );
392
+   					$linesresp[]=array(
393
+						'id'=>$line->rowid,
394
+						'type'=>$line->product_type,
395
+						'desc'=>dol_htmlcleanlastbr($line->description),
396
+						'total_net'=>$line->total_ht,
397
+						'total_vat'=>$line->total_tva,
398
+						'total'=>$line->total_ttc,
399
+						'vat_rate'=>$line->tva_tx,
400
+						'qty'=>$line->qty,
401
+   						'product_ref'=>$line->product_ref,
402
+						'product_label'=>$line->product_label,
403
+						'product_desc'=>$line->product_desc,
404
+   					);
405 405
 				}
406 406
 
407 407
 				// Now define invoice
408 408
 				$linesinvoice[]=array(
409 409
 					'id'=>$invoice->id,
410
-				    'ref'=>$invoice->ref,
411
-				    'ref_supplier'=>$invoice->ref_supplier,
412
-				    'ref_ext'=>$invoice->ref_ext,
413
-                    'fk_user_author' => $invoice->fk_user_author,
414
-                    'fk_user_valid' => $invoice->fk_user_valid,
415
-                    'fk_thirdparty' => $invoice->fk_soc,
416
-				    'type'=>$invoice->type,
417
-                    'status'=>$invoice->statut,
418
-				    'total_net'=>$invoice->total_ht,
410
+					'ref'=>$invoice->ref,
411
+					'ref_supplier'=>$invoice->ref_supplier,
412
+					'ref_ext'=>$invoice->ref_ext,
413
+					'fk_user_author' => $invoice->fk_user_author,
414
+					'fk_user_valid' => $invoice->fk_user_valid,
415
+					'fk_thirdparty' => $invoice->fk_soc,
416
+					'type'=>$invoice->type,
417
+					'status'=>$invoice->statut,
418
+					'total_net'=>$invoice->total_ht,
419 419
 					'total_vat'=>$invoice->total_tva,
420 420
 					'total'=>$invoice->total_ttc,
421
-                    'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
422
-                    'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
423
-                    'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
424
-                    'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
425
-                    'label'=>$invoice->libelle,
426
-                    'paid'=>$invoice->paye,
427
-                    'note_private'=>$invoice->note_private,
428
-                    'note_public'=>$invoice->note_public,
429
-                    'close_code'=>$invoice->close_code,
430
-                    'close_note'=>$invoice->close_note,
431
-
432
-				    'lines' => $linesresp
421
+					'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
422
+					'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
423
+					'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
424
+					'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
425
+					'label'=>$invoice->libelle,
426
+					'paid'=>$invoice->paye,
427
+					'note_private'=>$invoice->note_private,
428
+					'note_public'=>$invoice->note_public,
429
+					'close_code'=>$invoice->close_code,
430
+					'close_note'=>$invoice->close_note,
431
+
432
+					'lines' => $linesresp
433 433
 				);
434 434
 
435 435
 				$i++;
436 436
 			}
437 437
 
438 438
 			$objectresp=array(
439
-		    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
440
-		        'invoices'=>$linesinvoice
439
+				'result'=>array('result_code'=>'OK', 'result_label'=>''),
440
+				'invoices'=>$linesinvoice
441 441
 
442 442
 			);
443 443
 		}
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
24 24
 
25 25
 require_once '../master.inc.php';
26
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
26
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
27 27
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
28 28
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
29 29
 
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 {
40 40
 	$langs->load("admin");
41 41
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
42
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
42
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
43 43
 	print $langs->trans("ToActivateModule");
44 44
 	exit;
45 45
 }
46 46
 
47 47
 // Create the soap Object
48 48
 $server = new nusoap_server();
49
-$server->soap_defencoding='UTF-8';
50
-$server->decode_utf8=false;
51
-$ns='http://www.dolibarr.org/ns/';
52
-$server->configureWSDL('WebServicesDolibarrSupplierInvoice',$ns);
53
-$server->wsdl->schemaTargetNamespace=$ns;
49
+$server->soap_defencoding = 'UTF-8';
50
+$server->decode_utf8 = false;
51
+$ns = 'http://www.dolibarr.org/ns/';
52
+$server->configureWSDL('WebServicesDolibarrSupplierInvoice', $ns);
53
+$server->wsdl->schemaTargetNamespace = $ns;
54 54
 
55 55
 
56 56
 // Define WSDL Authentication object
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
     'all',
62 62
     '',
63 63
     array(
64
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
65
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
66
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
67
-        'password' => array('name'=>'password','type'=>'xsd:string'),
68
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
64
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
65
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
66
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
67
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
68
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
69 69
     )
70 70
 );
71 71
 // Define WSDL Return object
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
     'all',
77 77
     '',
78 78
     array(
79
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
80
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
79
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
80
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
81 81
     )
82 82
 );
83 83
 
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
     'all',
90 90
     '',
91 91
     array(
92
-        'id' => array('name'=>'id','type'=>'xsd:string'),
93
-        'type' => array('name'=>'type','type'=>'xsd:int'),
94
-        'desc' => array('name'=>'desc','type'=>'xsd:string'),
95
-    	'fk_product' => array('name'=>'fk_product','type'=>'xsd:int'),
96
-        'total_net' => array('name'=>'total_net','type'=>'xsd:double'),
97
-    	'total_vat' => array('name'=>'total_vat','type'=>'xsd:double'),
98
-    	'total' => array('name'=>'total','type'=>'xsd:double'),
99
-        'vat_rate' => array('name'=>'vat_rate','type'=>'xsd:double'),
100
-        'qty' => array('name'=>'qty','type'=>'xsd:double'),
101
-        'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
102
-        'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
92
+        'id' => array('name'=>'id', 'type'=>'xsd:string'),
93
+        'type' => array('name'=>'type', 'type'=>'xsd:int'),
94
+        'desc' => array('name'=>'desc', 'type'=>'xsd:string'),
95
+    	'fk_product' => array('name'=>'fk_product', 'type'=>'xsd:int'),
96
+        'total_net' => array('name'=>'total_net', 'type'=>'xsd:double'),
97
+    	'total_vat' => array('name'=>'total_vat', 'type'=>'xsd:double'),
98
+    	'total' => array('name'=>'total', 'type'=>'xsd:double'),
99
+        'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:double'),
100
+        'qty' => array('name'=>'qty', 'type'=>'xsd:double'),
101
+        'date_start' => array('name'=>'date_start', 'type'=>'xsd:date'),
102
+        'date_end' => array('name'=>'date_end', 'type'=>'xsd:date'),
103 103
         // From product
104
-        'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'),
105
-        'product_label' => array('name'=>'product_label','type'=>'xsd:string'),
106
-        'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
104
+        'product_ref' => array('name'=>'product_ref', 'type'=>'xsd:string'),
105
+        'product_label' => array('name'=>'product_label', 'type'=>'xsd:string'),
106
+        'product_desc' => array('name'=>'product_desc', 'type'=>'xsd:string')
107 107
     )
108 108
 );
109 109
 
@@ -115,40 +115,40 @@  discard block
 block discarded – undo
115 115
     'SOAP-ENC:Array',
116 116
     array(),
117 117
     array(
118
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:line[]')
118
+        array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:line[]')
119 119
     ),
120 120
     'tns:line'
121 121
 );
122 122
 
123 123
 $server->wsdl->addComplexType(
124 124
     'invoice',
125
-    'element',		// If we put element here instead of complexType to have tag called invoice in getInvoicesForThirdParty we brek getInvoice
125
+    'element', // If we put element here instead of complexType to have tag called invoice in getInvoicesForThirdParty we brek getInvoice
126 126
     'struct',
127 127
     'all',
128 128
     '',
129 129
     array(
130
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
131
-        'ref' => array('name'=>'ref','type'=>'xsd:string'),
132
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
133
-        'ref_supplier' => array('name'=>'ref_supplier','type'=>'xsd:string'),
134
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:int'),
135
-        'fk_user_valid' => array('name'=>'fk_user_valid','type'=>'xsd:int'),
136
-        'fk_thirdparty' => array('name'=>'fk_thirdparty','type'=>'xsd:int'),
137
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
138
-        'date_validation' => array('name'=>'date_validation','type'=>'xsd:dateTime'),
139
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
140
-        'date_invoice' => array('name'=>'date_invoice','type'=>'xsd:date'),
141
-        'date_term' => array('name'=>'date_modification','type'=>'xsd:date'),
142
-        'type' => array('name'=>'type','type'=>'xsd:int'),
143
-        'total_net' => array('name'=>'type','type'=>'xsd:double'),
144
-        'total_vat' => array('name'=>'type','type'=>'xsd:double'),
145
-        'total' => array('name'=>'type','type'=>'xsd:double'),
146
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
147
-        'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
148
-        'status' => array('name'=>'status','type'=>'xsd:int'),
149
-        'close_code' => array('name'=>'close_code','type'=>'xsd:string'),
150
-        'close_note' => array('name'=>'close_note','type'=>'xsd:string'),
151
-    	'lines' => array('name'=>'lines','type'=>'tns:LinesArray')
130
+    	'id' => array('name'=>'id', 'type'=>'xsd:string'),
131
+        'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
132
+        'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
133
+        'ref_supplier' => array('name'=>'ref_supplier', 'type'=>'xsd:string'),
134
+        'fk_user_author' => array('name'=>'fk_user_author', 'type'=>'xsd:int'),
135
+        'fk_user_valid' => array('name'=>'fk_user_valid', 'type'=>'xsd:int'),
136
+        'fk_thirdparty' => array('name'=>'fk_thirdparty', 'type'=>'xsd:int'),
137
+        'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'),
138
+        'date_validation' => array('name'=>'date_validation', 'type'=>'xsd:dateTime'),
139
+        'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'),
140
+        'date_invoice' => array('name'=>'date_invoice', 'type'=>'xsd:date'),
141
+        'date_term' => array('name'=>'date_modification', 'type'=>'xsd:date'),
142
+        'type' => array('name'=>'type', 'type'=>'xsd:int'),
143
+        'total_net' => array('name'=>'type', 'type'=>'xsd:double'),
144
+        'total_vat' => array('name'=>'type', 'type'=>'xsd:double'),
145
+        'total' => array('name'=>'type', 'type'=>'xsd:double'),
146
+        'note_private' => array('name'=>'note_private', 'type'=>'xsd:string'),
147
+        'note_public' => array('name'=>'note_public', 'type'=>'xsd:string'),
148
+        'status' => array('name'=>'status', 'type'=>'xsd:int'),
149
+        'close_code' => array('name'=>'close_code', 'type'=>'xsd:string'),
150
+        'close_note' => array('name'=>'close_note', 'type'=>'xsd:string'),
151
+    	'lines' => array('name'=>'lines', 'type'=>'tns:LinesArray')
152 152
     )
153 153
 );
154 154
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     'SOAP-ENC:Array',
161 161
     array(),
162 162
     array(
163
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
163
+        array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:invoice[]')
164 164
     ),
165 165
     'tns:invoice'
166 166
 );
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     'SOAP-ENC:Array',
174 174
     array(),
175 175
     array(
176
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:invoice[]')
176
+        array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:invoice[]')
177 177
     ),
178 178
     'tns:invoice'
179 179
 );
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
184 184
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
185 185
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
186
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
187
-$styleuse='encoded';   // encoded/literal/literal wrapped
186
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
187
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
188 188
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
189 189
 
190 190
 // Register WSDL
191 191
 $server->register(
192 192
     'getSupplierInvoice',
193 193
     // Entry values
194
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
194
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
195 195
     // Exit values
196
-    array('result'=>'tns:result','invoice'=>'tns:invoice'),
196
+    array('result'=>'tns:result', 'invoice'=>'tns:invoice'),
197 197
     $ns,
198 198
     $ns.'#getSupplierInvoice',
199 199
     $styledoc,
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 $server->register(
204 204
     'getSupplierInvoicesForThirdParty',
205 205
     // Entry values
206
-    array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'),
206
+    array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'),
207 207
     // Exit values
208
-    array('result'=>'tns:result','invoices'=>'tns:invoices'),
208
+    array('result'=>'tns:result', 'invoices'=>'tns:invoices'),
209 209
     $ns,
210 210
     $ns.'#getSupplierInvoicesForThirdParty',
211 211
     $styledoc,
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
  * @param	string		$ref_ext			Ref_ext
224 224
  * @return	array							Array result
225 225
  */
226
-function getSupplierInvoice($authentication,$id='',$ref='',$ref_ext='')
226
+function getSupplierInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
227 227
 {
228
-	global $db,$conf,$langs;
228
+	global $db, $conf, $langs;
229 229
 
230 230
 	dol_syslog("Function: getSupplierInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
231 231
 
232
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
232
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
233 233
 
234 234
     // Init and check authentication
235
-    $objectresp=array();
236
-    $errorcode='';$errorlabel='';
237
-    $error=0;
238
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
235
+    $objectresp = array();
236
+    $errorcode = ''; $errorlabel = '';
237
+    $error = 0;
238
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
239 239
     // Check parameters
240
-	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
240
+	if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
241 241
 	{
242 242
 		$error++;
243
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
243
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
244 244
 	}
245 245
 
246
-	if (! $error)
246
+	if (!$error)
247 247
 	{
248 248
 		$fuser->getrights();
249 249
 
250 250
 		if ($fuser->rights->fournisseur->facture->lire)
251 251
 		{
252
-			$invoice=new FactureFournisseur($db);
253
-			$result=$invoice->fetch($id,$ref,$ref_ext);
252
+			$invoice = new FactureFournisseur($db);
253
+			$result = $invoice->fetch($id, $ref, $ref_ext);
254 254
 			if ($result > 0)
255 255
 			{
256
-				$linesresp=array();
257
-				$i=0;
258
-				foreach($invoice->lines as $line)
256
+				$linesresp = array();
257
+				$i = 0;
258
+				foreach ($invoice->lines as $line)
259 259
 				{
260 260
 					//var_dump($line); exit;
261
-					$linesresp[]=array(
261
+					$linesresp[] = array(
262 262
 						'id'=>$line->rowid,
263 263
 						'type'=>$line->product_type,
264 264
 						'total_net'=>$line->total_ht,
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
                         'total_net'=>$invoice->total_ht,
287 287
                         'total_vat'=>$invoice->total_tva,
288 288
                         'total'=>$invoice->total_ttc,
289
-                        'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
290
-                        'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
291
-                        'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
292
-                        'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
289
+                        'date_creation'=>dol_print_date($invoice->datec, 'dayhourrfc'),
290
+                        'date_modification'=>dol_print_date($invoice->tms, 'dayhourrfc'),
291
+                        'date_invoice'=>dol_print_date($invoice->date, 'dayhourrfc'),
292
+                        'date_term'=>dol_print_date($invoice->date_echeance, 'dayhourrfc'),
293 293
                         'label'=>$invoice->libelle,
294 294
                         'paid'=>$invoice->paye,
295 295
                         'note_private'=>$invoice->note_private,
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 			else
307 307
 			{
308 308
 				$error++;
309
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
309
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
310 310
 			}
311 311
 		}
312 312
 		else
313 313
 		{
314 314
 			$error++;
315
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
315
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
316 316
 		}
317 317
 	}
318 318
 
@@ -333,63 +333,63 @@  discard block
 block discarded – undo
333 333
  * @return	array							Array result
334 334
  *
335 335
  */
336
-function getSupplierInvoicesForThirdParty($authentication,$idthirdparty)
336
+function getSupplierInvoicesForThirdParty($authentication, $idthirdparty)
337 337
 {
338
-	global $db,$conf,$langs;
338
+	global $db, $conf, $langs;
339 339
 
340 340
 	dol_syslog("Function: getSupplierInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
341 341
 
342
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
342
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
343 343
 
344 344
     // Init and check authentication
345
-    $objectresp=array();
346
-    $errorcode='';$errorlabel='';
347
-    $error=0;
348
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
345
+    $objectresp = array();
346
+    $errorcode = ''; $errorlabel = '';
347
+    $error = 0;
348
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
349 349
     // Check parameters
350
-	if (! $error && empty($idthirdparty))
350
+	if (!$error && empty($idthirdparty))
351 351
 	{
352 352
 		$error++;
353
-		$errorcode='BAD_PARAMETERS'; $errorlabel='Parameter id is not provided';
353
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = 'Parameter id is not provided';
354 354
 	}
355 355
 
356
-	if (! $error)
356
+	if (!$error)
357 357
 	{
358
-		$linesinvoice=array();
358
+		$linesinvoice = array();
359 359
 
360
-		$sql.='SELECT f.rowid as facid';
361
-		$sql.=' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
360
+		$sql .= 'SELECT f.rowid as facid';
361
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
362 362
 		//$sql.=', '.MAIN_DB_PREFIX.'societe as s';
363 363
 		//$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
364 364
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
365 365
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
366
-        $sql.=" WHERE f.entity = ".$conf->entity;
367
-		if ($idthirdparty != 'all') $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
366
+        $sql .= " WHERE f.entity = ".$conf->entity;
367
+		if ($idthirdparty != 'all') $sql .= " AND f.fk_soc = ".$db->escape($idthirdparty);
368 368
 
369
-		$resql=$db->query($sql);
369
+		$resql = $db->query($sql);
370 370
 		if ($resql)
371 371
 		{
372
-			$num=$db->num_rows($resql);
373
-			$i=0;
372
+			$num = $db->num_rows($resql);
373
+			$i = 0;
374 374
 			while ($i < $num)
375 375
 			{
376 376
                 // En attendant remplissage par boucle
377
-			    $obj=$db->fetch_object($resql);
377
+			    $obj = $db->fetch_object($resql);
378 378
 
379
-			    $invoice=new FactureFournisseur($db);
380
-			    $result=$invoice->fetch($obj->facid);
379
+			    $invoice = new FactureFournisseur($db);
380
+			    $result = $invoice->fetch($obj->facid);
381 381
 				if ($result < 0)
382 382
 				{
383 383
 					$error++;
384
-					$errorcode=$result; $errorlabel=$invoice->error;
384
+					$errorcode = $result; $errorlabel = $invoice->error;
385 385
 					break;
386 386
 				}
387 387
 
388 388
 				// Define lines of invoice
389
-				$linesresp=array();
390
-				foreach($invoice->lines as $line)
389
+				$linesresp = array();
390
+				foreach ($invoice->lines as $line)
391 391
 				{
392
-   				    $linesresp[]=array(
392
+   				    $linesresp[] = array(
393 393
     					'id'=>$line->rowid,
394 394
     					'type'=>$line->product_type,
395 395
                         'desc'=>dol_htmlcleanlastbr($line->description),
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				}
406 406
 
407 407
 				// Now define invoice
408
-				$linesinvoice[]=array(
408
+				$linesinvoice[] = array(
409 409
 					'id'=>$invoice->id,
410 410
 				    'ref'=>$invoice->ref,
411 411
 				    'ref_supplier'=>$invoice->ref_supplier,
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 				    'total_net'=>$invoice->total_ht,
419 419
 					'total_vat'=>$invoice->total_tva,
420 420
 					'total'=>$invoice->total_ttc,
421
-                    'date_creation'=>dol_print_date($invoice->datec,'dayhourrfc'),
422
-                    'date_modification'=>dol_print_date($invoice->tms,'dayhourrfc'),
423
-                    'date_invoice'=>dol_print_date($invoice->date,'dayhourrfc'),
424
-                    'date_term'=>dol_print_date($invoice->date_echeance,'dayhourrfc'),
421
+                    'date_creation'=>dol_print_date($invoice->datec, 'dayhourrfc'),
422
+                    'date_modification'=>dol_print_date($invoice->tms, 'dayhourrfc'),
423
+                    'date_invoice'=>dol_print_date($invoice->date, 'dayhourrfc'),
424
+                    'date_term'=>dol_print_date($invoice->date_echeance, 'dayhourrfc'),
425 425
                     'label'=>$invoice->libelle,
426 426
                     'paid'=>$invoice->paye,
427 427
                     'note_private'=>$invoice->note_private,
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 				$i++;
436 436
 			}
437 437
 
438
-			$objectresp=array(
438
+			$objectresp = array(
439 439
 		    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
440 440
 		        'invoices'=>$linesinvoice
441 441
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		else
445 445
 		{
446 446
 			$error++;
447
-			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
447
+			$errorcode = $db->lasterrno(); $errorlabel = $db->lasterror();
448 448
 		}
449 449
 	}
450 450
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (! defined("NOCSRFCHECK")) {
24
+	define("NOCSRFCHECK",'1');
25
+}
24 26
 
25 27
 require_once '../master.inc.php';
26 28
 require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
@@ -229,7 +231,9 @@  discard block
 block discarded – undo
229 231
 
230 232
 	dol_syslog("Function: getSupplierInvoice login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
231 233
 
232
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
234
+	if ($authentication['entity']) {
235
+		$conf->entity=$authentication['entity'];
236
+	}
233 237
 
234 238
     // Init and check authentication
235 239
     $objectresp=array();
@@ -302,14 +306,12 @@  discard block
 block discarded – undo
302 306
 //				        				 '1'=>array('id'=>333,'type'=>1))
303 307
 
304 308
 			    ));
305
-			}
306
-			else
309
+			} else
307 310
 			{
308 311
 				$error++;
309 312
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
310 313
 			}
311
-		}
312
-		else
314
+		} else
313 315
 		{
314 316
 			$error++;
315 317
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -339,7 +341,9 @@  discard block
 block discarded – undo
339 341
 
340 342
 	dol_syslog("Function: getSupplierInvoicesForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty);
341 343
 
342
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
344
+	if ($authentication['entity']) {
345
+		$conf->entity=$authentication['entity'];
346
+	}
343 347
 
344 348
     // Init and check authentication
345 349
     $objectresp=array();
@@ -364,7 +368,9 @@  discard block
 block discarded – undo
364 368
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
365 369
 		//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
366 370
         $sql.=" WHERE f.entity = ".$conf->entity;
367
-		if ($idthirdparty != 'all') $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
371
+		if ($idthirdparty != 'all') {
372
+			$sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
373
+		}
368 374
 
369 375
 		$resql=$db->query($sql);
370 376
 		if ($resql)
@@ -440,8 +446,7 @@  discard block
 block discarded – undo
440 446
 		        'invoices'=>$linesinvoice
441 447
 
442 448
 			);
443
-		}
444
-		else
449
+		} else
445 450
 		{
446 451
 			$error++;
447 452
 			$errorcode=$db->lasterrno(); $errorlabel=$db->lasterror();
Please login to merge, or discard this patch.
htdocs/webservices/server_thirdparty.php 3 patches
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -56,69 +56,69 @@  discard block
 block discarded – undo
56 56
 
57 57
 // Define WSDL Authentication object
58 58
 $server->wsdl->addComplexType(
59
-    'authentication',
60
-    'complexType',
61
-    'struct',
62
-    'all',
63
-    '',
64
-    array(
65
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
68
-        'password' => array('name'=>'password','type'=>'xsd:string'),
69
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
70
-    )
59
+	'authentication',
60
+	'complexType',
61
+	'struct',
62
+	'all',
63
+	'',
64
+	array(
65
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
+		'login' => array('name'=>'login','type'=>'xsd:string'),
68
+		'password' => array('name'=>'password','type'=>'xsd:string'),
69
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
70
+	)
71 71
 );
72 72
 // Define WSDL Return object
73 73
 $server->wsdl->addComplexType(
74
-    'result',
75
-    'complexType',
76
-    'struct',
77
-    'all',
78
-    '',
79
-    array(
80
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
81
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
82
-    )
74
+	'result',
75
+	'complexType',
76
+	'struct',
77
+	'all',
78
+	'',
79
+	array(
80
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
81
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
82
+	)
83 83
 );
84 84
 
85 85
 
86 86
 $thirdparty_fields= array(
87
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
88
-        'ref' => array('name'=>'name','type'=>'xsd:string'),
89
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
90
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
87
+		'id' => array('name'=>'id','type'=>'xsd:string'),
88
+		'ref' => array('name'=>'name','type'=>'xsd:string'),
89
+		'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
90
+		'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
91 91
 		'status' => array('name'=>'status','type'=>'xsd:string'),
92
-        'client' => array('name'=>'client','type'=>'xsd:string'),
93
-        'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
94
-        'customer_code' => array('name'=>'customer_code','type'=>'xsd:string'),
95
-        'supplier_code' => array('name'=>'supplier_code','type'=>'xsd:string'),
96
-        'customer_code_accountancy' => array('name'=>'customer_code_accountancy','type'=>'xsd:string'),
97
-        'supplier_code_accountancy' => array('name'=>'supplier_code_accountancy','type'=>'xsd:string'),
98
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
92
+		'client' => array('name'=>'client','type'=>'xsd:string'),
93
+		'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
94
+		'customer_code' => array('name'=>'customer_code','type'=>'xsd:string'),
95
+		'supplier_code' => array('name'=>'supplier_code','type'=>'xsd:string'),
96
+		'customer_code_accountancy' => array('name'=>'customer_code_accountancy','type'=>'xsd:string'),
97
+		'supplier_code_accountancy' => array('name'=>'supplier_code_accountancy','type'=>'xsd:string'),
98
+		'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
+		'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
+		'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
101 101
 		'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
102
-    	'address' => array('name'=>'address','type'=>'xsd:string'),
103
-    	'zip' => array('name'=>'zip','type'=>'xsd:string'),
104
-    	'town' => array('name'=>'town','type'=>'xsd:string'),
105
-    	'province_id' => array('name'=>'province_id','type'=>'xsd:string'),
106
-    	'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
107
-    	'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
108
-    	'country' => array('name'=>'country','type'=>'xsd:string'),
109
-        'phone' => array('name'=>'phone','type'=>'xsd:string'),
110
-    	'fax' => array('name'=>'fax','type'=>'xsd:string'),
111
-    	'email' => array('name'=>'email','type'=>'xsd:string'),
112
-    	'url' => array('name'=>'url','type'=>'xsd:string'),
113
-    	'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
114
-    	'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
115
-    	'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
116
-    	'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
117
-    	'profid5' => array('name'=>'profid5','type'=>'xsd:string'),
118
-    	'profid6' => array('name'=>'profid6','type'=>'xsd:string'),
119
-        'capital' => array('name'=>'capital','type'=>'xsd:string'),
120
-    	'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
121
-    	'vat_number' => array('name'=>'vat_number','type'=>'xsd:string'));
102
+		'address' => array('name'=>'address','type'=>'xsd:string'),
103
+		'zip' => array('name'=>'zip','type'=>'xsd:string'),
104
+		'town' => array('name'=>'town','type'=>'xsd:string'),
105
+		'province_id' => array('name'=>'province_id','type'=>'xsd:string'),
106
+		'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
107
+		'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
108
+		'country' => array('name'=>'country','type'=>'xsd:string'),
109
+		'phone' => array('name'=>'phone','type'=>'xsd:string'),
110
+		'fax' => array('name'=>'fax','type'=>'xsd:string'),
111
+		'email' => array('name'=>'email','type'=>'xsd:string'),
112
+		'url' => array('name'=>'url','type'=>'xsd:string'),
113
+		'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
114
+		'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
115
+		'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
116
+		'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
117
+		'profid5' => array('name'=>'profid5','type'=>'xsd:string'),
118
+		'profid6' => array('name'=>'profid6','type'=>'xsd:string'),
119
+		'capital' => array('name'=>'capital','type'=>'xsd:string'),
120
+		'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
121
+		'vat_number' => array('name'=>'vat_number','type'=>'xsd:string'));
122 122
 
123 123
 // Retrieve all extrafields for thirdsparty
124 124
 // fetch optionals attributes and labels
@@ -141,55 +141,55 @@  discard block
 block discarded – undo
141 141
 
142 142
 // Define other specific objects
143 143
 $server->wsdl->addComplexType(
144
-    'thirdparty',
145
-    'complexType',
146
-    'struct',
147
-    'all',
148
-    '',
144
+	'thirdparty',
145
+	'complexType',
146
+	'struct',
147
+	'all',
148
+	'',
149 149
 	$thirdparty_fields
150 150
 );
151 151
 
152 152
 // Define other specific objects
153 153
 $server->wsdl->addComplexType(
154
-    'filterthirdparty',
155
-    'complexType',
156
-    'struct',
157
-    'all',
158
-    '',
159
-    array(
160
-        //'limit' => array('name'=>'limit','type'=>'xsd:string'),
161
-        'client' => array('name'=>'client','type'=>'xsd:string'),
162
-        'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
163
-    	'category' => array('name'=>'category','type'=>'xsd:string')
164
-    )
154
+	'filterthirdparty',
155
+	'complexType',
156
+	'struct',
157
+	'all',
158
+	'',
159
+	array(
160
+		//'limit' => array('name'=>'limit','type'=>'xsd:string'),
161
+		'client' => array('name'=>'client','type'=>'xsd:string'),
162
+		'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
163
+		'category' => array('name'=>'category','type'=>'xsd:string')
164
+	)
165 165
 );
166 166
 
167 167
 $server->wsdl->addComplexType(
168
-    'ThirdPartiesArray',
169
-    'complexType',
170
-    'array',
171
-    '',
172
-    'SOAP-ENC:Array',
173
-    array(),
174
-    array(
175
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:thirdparty[]')
176
-    ),
177
-    'tns:thirdparty'
168
+	'ThirdPartiesArray',
169
+	'complexType',
170
+	'array',
171
+	'',
172
+	'SOAP-ENC:Array',
173
+	array(),
174
+	array(
175
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:thirdparty[]')
176
+	),
177
+	'tns:thirdparty'
178 178
 );
179 179
 $server->wsdl->addComplexType(
180
-    'ThirdPartiesArray2',
181
-    'complexType',
182
-    'array',
183
-    'sequence',
184
-    '',
185
-    array(
186
-        'thirdparty' => array(
187
-            'name' => 'thirdparty',
188
-            'type' => 'tns:thirdparty',
189
-            'minOccurs' => '0',
190
-            'maxOccurs' => 'unbounded'
191
-        )
192
-    )
180
+	'ThirdPartiesArray2',
181
+	'complexType',
182
+	'array',
183
+	'sequence',
184
+	'',
185
+	array(
186
+		'thirdparty' => array(
187
+			'name' => 'thirdparty',
188
+			'type' => 'tns:thirdparty',
189
+			'minOccurs' => '0',
190
+			'maxOccurs' => 'unbounded'
191
+		)
192
+	)
193 193
 );
194 194
 
195 195
 
@@ -202,30 +202,30 @@  discard block
 block discarded – undo
202 202
 
203 203
 // Register WSDL
204 204
 $server->register(
205
-    'getThirdParty',
206
-    // Entry values
207
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
208
-    // Exit values
209
-    array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'),
210
-    $ns,
211
-    $ns.'#getThirdParty',
212
-    $styledoc,
213
-    $styleuse,
214
-    'WS to get a thirdparty from its id, ref or ref_ext'
205
+	'getThirdParty',
206
+	// Entry values
207
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
208
+	// Exit values
209
+	array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'),
210
+	$ns,
211
+	$ns.'#getThirdParty',
212
+	$styledoc,
213
+	$styleuse,
214
+	'WS to get a thirdparty from its id, ref or ref_ext'
215 215
 );
216 216
 
217 217
 // Register WSDL
218 218
 $server->register(
219
-    'createThirdParty',
220
-    // Entry values
221
-    array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
222
-    // Exit values
223
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
224
-    $ns,
225
-    $ns.'#createThirdParty',
226
-    $styledoc,
227
-    $styleuse,
228
-    'WS to create a thirdparty'
219
+	'createThirdParty',
220
+	// Entry values
221
+	array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
222
+	// Exit values
223
+	array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
224
+	$ns,
225
+	$ns.'#createThirdParty',
226
+	$styledoc,
227
+	$styleuse,
228
+	'WS to create a thirdparty'
229 229
 );
230 230
 
231 231
 // Register WSDL
@@ -245,16 +245,16 @@  discard block
 block discarded – undo
245 245
 
246 246
 // Register WSDL
247 247
 $server->register(
248
-    'getListOfThirdParties',
249
-    // Entry values
250
-    array('authentication'=>'tns:authentication','filterthirdparty'=>'tns:filterthirdparty'),
251
-    // Exit values
252
-    array('result'=>'tns:result','thirdparties'=>'tns:ThirdPartiesArray2'),
253
-    $ns,
254
-    $ns.'#getListOfThirdParties',
255
-    $styledoc,
256
-    $styleuse,
257
-    'WS to get list of thirdparties id and ref'
248
+	'getListOfThirdParties',
249
+	// Entry values
250
+	array('authentication'=>'tns:authentication','filterthirdparty'=>'tns:filterthirdparty'),
251
+	// Exit values
252
+	array('result'=>'tns:result','thirdparties'=>'tns:ThirdPartiesArray2'),
253
+	$ns,
254
+	$ns.'#getListOfThirdParties',
255
+	$styledoc,
256
+	$styleuse,
257
+	'WS to get list of thirdparties id and ref'
258 258
 );
259 259
 
260 260
 // Register WSDL
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
 
291 291
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
292 292
 
293
-    // Init and check authentication
294
-    $objectresp=array();
295
-    $errorcode='';$errorlabel='';
296
-    $error=0;
297
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
298
-    // Check parameters
293
+	// Init and check authentication
294
+	$objectresp=array();
295
+	$errorcode='';$errorlabel='';
296
+	$error=0;
297
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
298
+	// Check parameters
299 299
 	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
300 300
 	{
301 301
 		$error++;
@@ -314,40 +314,40 @@  discard block
 block discarded – undo
314 314
 			{
315 315
 
316 316
 				$thirdparty_result_fields=array(
317
-				    	'id' => $thirdparty->id,
317
+						'id' => $thirdparty->id,
318 318
 			   			'ref' => $thirdparty->name,
319 319
 			   			'ref_ext' => $thirdparty->ref_ext,
320 320
 			   			'status' => $thirdparty->status,
321
-			            'client' => $thirdparty->client,
322
-			            'supplier' => $thirdparty->fournisseur,
323
-				        'customer_code' => $thirdparty->code_client,
324
-			            'supplier_code' => $thirdparty->code_fournisseur,
325
-				        'customer_code_accountancy' => $thirdparty->code_compta,
326
-			            'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
327
-			            'fk_user_author' => $thirdparty->fk_user_author,
328
-			    		'date_creation' => dol_print_date($thirdparty->date_creation,'dayhourrfc'),
329
-			    		'date_modification' => dol_print_date($thirdparty->date_modification,'dayhourrfc'),
330
-			            'address' => $thirdparty->address,
331
-				        'zip' => $thirdparty->zip,
332
-				        'town' => $thirdparty->town,
333
-				        'province_id' => $thirdparty->state_id,
334
-				        'country_id' => $thirdparty->country_id,
335
-				        'country_code' => $thirdparty->country_code,
336
-				        'country' => $thirdparty->country,
337
-			            'phone' => $thirdparty->phone,
338
-				        'fax' => $thirdparty->fax,
339
-				        'email' => $thirdparty->email,
340
-				        'url' => $thirdparty->url,
341
-				        'profid1' => $thirdparty->idprof1,
342
-				        'profid2' => $thirdparty->idprof2,
343
-				        'profid3' => $thirdparty->idprof3,
344
-				        'profid4' => $thirdparty->idprof4,
345
-				        'profid5' => $thirdparty->idprof5,
346
-				        'profid6' => $thirdparty->idprof6,
347
-			            'capital' => $thirdparty->capital,
321
+						'client' => $thirdparty->client,
322
+						'supplier' => $thirdparty->fournisseur,
323
+						'customer_code' => $thirdparty->code_client,
324
+						'supplier_code' => $thirdparty->code_fournisseur,
325
+						'customer_code_accountancy' => $thirdparty->code_compta,
326
+						'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
327
+						'fk_user_author' => $thirdparty->fk_user_author,
328
+						'date_creation' => dol_print_date($thirdparty->date_creation,'dayhourrfc'),
329
+						'date_modification' => dol_print_date($thirdparty->date_modification,'dayhourrfc'),
330
+						'address' => $thirdparty->address,
331
+						'zip' => $thirdparty->zip,
332
+						'town' => $thirdparty->town,
333
+						'province_id' => $thirdparty->state_id,
334
+						'country_id' => $thirdparty->country_id,
335
+						'country_code' => $thirdparty->country_code,
336
+						'country' => $thirdparty->country,
337
+						'phone' => $thirdparty->phone,
338
+						'fax' => $thirdparty->fax,
339
+						'email' => $thirdparty->email,
340
+						'url' => $thirdparty->url,
341
+						'profid1' => $thirdparty->idprof1,
342
+						'profid2' => $thirdparty->idprof2,
343
+						'profid3' => $thirdparty->idprof3,
344
+						'profid4' => $thirdparty->idprof4,
345
+						'profid5' => $thirdparty->idprof5,
346
+						'profid6' => $thirdparty->idprof6,
347
+						'capital' => $thirdparty->capital,
348 348
 			   			'barcode' => $thirdparty->barcode,
349
-			            'vat_used' => $thirdparty->tva_assuj,
350
-				        'vat_number' => $thirdparty->tva_intra,
349
+						'vat_used' => $thirdparty->tva_assuj,
350
+						'vat_number' => $thirdparty->tva_intra,
351 351
 						'note_private' => $thirdparty->note_private,
352 352
 						'note_public' => $thirdparty->note_public);
353 353
 
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 					$thirdparty_result_fields=array_merge($thirdparty_result_fields,array('options_'.$key => $thirdparty->array_options['options_'.$key]));
364 364
 				}
365 365
 
366
-			    // Create
367
-			    $objectresp = array(
368
-			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
369
-			        'thirdparty'=>$thirdparty_result_fields);
366
+				// Create
367
+				$objectresp = array(
368
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
369
+					'thirdparty'=>$thirdparty_result_fields);
370 370
 			}
371 371
 			else
372 372
 			{
@@ -400,121 +400,121 @@  discard block
 block discarded – undo
400 400
  */
401 401
 function createThirdParty($authentication,$thirdparty)
402 402
 {
403
-    global $db,$conf,$langs;
404
-
405
-    $now=dol_now();
406
-
407
-    dol_syslog("Function: createThirdParty login=".$authentication['login']);
408
-
409
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
410
-
411
-    // Init and check authentication
412
-    $objectresp=array();
413
-    $errorcode='';$errorlabel='';
414
-    $error=0;
415
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
416
-    // Check parameters
417
-    if (empty($thirdparty['ref']))
418
-    {
419
-        $error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
420
-    }
421
-
422
-
423
-    if (! $error)
424
-    {
425
-        include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
426
-
427
-        $newobject=new Societe($db);
428
-        $newobject->ref=$thirdparty['ref'];
429
-        $newobject->name=$thirdparty['ref'];
430
-        $newobject->ref_ext=$thirdparty['ref_ext'];
431
-        $newobject->status=$thirdparty['status'];
432
-        $newobject->client=$thirdparty['client'];
433
-        $newobject->fournisseur=$thirdparty['supplier'];
434
-        $newobject->code_client=$thirdparty['customer_code'];
435
-        $newobject->code_fournisseur=$thirdparty['supplier_code'];
436
-        $newobject->code_compta=$thirdparty['customer_code_accountancy'];
437
-        $newobject->code_compta_fournisseur=$thirdparty['supplier_code_accountancy'];
438
-        $newobject->date_creation=$now;
439
-        $newobject->note_private=$thirdparty['note_private'];
440
-        $newobject->note_public=$thirdparty['note_public'];
441
-        $newobject->address=$thirdparty['address'];
442
-        $newobject->zip=$thirdparty['zip'];
443
-        $newobject->town=$thirdparty['town'];
444
-
445
-        $newobject->country_id=$thirdparty['country_id'];
446
-        if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3);
447
-        $newobject->province_id=$thirdparty['province_id'];
448
-        //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
449
-
450
-        $newobject->phone=$thirdparty['phone'];
451
-        $newobject->fax=$thirdparty['fax'];
452
-        $newobject->email=$thirdparty['email'];
453
-        $newobject->url=$thirdparty['url'];
454
-        $newobject->idprof1=$thirdparty['profid1'];
455
-        $newobject->idprof2=$thirdparty['profid2'];
456
-        $newobject->idprof3=$thirdparty['profid3'];
457
-        $newobject->idprof4=$thirdparty['profid4'];
458
-        $newobject->idprof5=$thirdparty['profid5'];
459
-        $newobject->idprof6=$thirdparty['profid6'];
460
-
461
-        $newobject->capital=$thirdparty['capital'];
462
-
463
-        $newobject->barcode=$thirdparty['barcode'];
464
-        $newobject->tva_assuj=$thirdparty['vat_used'];
465
-        $newobject->tva_intra=$thirdparty['vat_number'];
466
-
467
-        $newobject->canvas=$thirdparty['canvas'];
468
-        $newobject->particulier=$thirdparty['individual'];
469
-
470
-        // Retrieve all extrafields for thirdsparty
471
-        // fetch optionals attributes and labels
472
-        $extrafields=new ExtraFields($db);
473
-        $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
474
-        foreach($extrafields->attribute_label as $key=>$label)
475
-        {
476
-        	$key='options_'.$key;
477
-        	$newobject->array_options[$key]=$thirdparty[$key];
478
-        }
479
-
480
-        $db->begin();
481
-
482
-        $result=$newobject->create($fuser);
483
-        if ($newobject->particulier && $result > 0) {
484
-            $newobject->firstname = $thirdparty['firstname'];
485
-            $newobject->name_bis = $thirdparty['lastname'];
486
-            $result = $newobject->create_individual($fuser);
487
-        }
488
-        if ($result <= 0)
489
-        {
490
-            $error++;
491
-        }
492
-
493
-        if (! $error)
494
-        {
495
-            $db->commit();
496
-
497
-            // Patch to add capability to associate (one) sale representative
498
-            if($thirdparty['commid'] && $thirdparty['commid']>0)
499
-                $newobject->add_commercial($fuser, $thirdparty["commid"]);
500
-
501
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
502
-        }
503
-        else
504
-        {
505
-            $db->rollback();
506
-            $error++;
507
-            $errorcode='KO';
508
-            $errorlabel=$newobject->error;
509
-        }
510
-    }
511
-
512
-    if ($error)
513
-    {
514
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
515
-    }
516
-
517
-    return $objectresp;
403
+	global $db,$conf,$langs;
404
+
405
+	$now=dol_now();
406
+
407
+	dol_syslog("Function: createThirdParty login=".$authentication['login']);
408
+
409
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
410
+
411
+	// Init and check authentication
412
+	$objectresp=array();
413
+	$errorcode='';$errorlabel='';
414
+	$error=0;
415
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
416
+	// Check parameters
417
+	if (empty($thirdparty['ref']))
418
+	{
419
+		$error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
420
+	}
421
+
422
+
423
+	if (! $error)
424
+	{
425
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
426
+
427
+		$newobject=new Societe($db);
428
+		$newobject->ref=$thirdparty['ref'];
429
+		$newobject->name=$thirdparty['ref'];
430
+		$newobject->ref_ext=$thirdparty['ref_ext'];
431
+		$newobject->status=$thirdparty['status'];
432
+		$newobject->client=$thirdparty['client'];
433
+		$newobject->fournisseur=$thirdparty['supplier'];
434
+		$newobject->code_client=$thirdparty['customer_code'];
435
+		$newobject->code_fournisseur=$thirdparty['supplier_code'];
436
+		$newobject->code_compta=$thirdparty['customer_code_accountancy'];
437
+		$newobject->code_compta_fournisseur=$thirdparty['supplier_code_accountancy'];
438
+		$newobject->date_creation=$now;
439
+		$newobject->note_private=$thirdparty['note_private'];
440
+		$newobject->note_public=$thirdparty['note_public'];
441
+		$newobject->address=$thirdparty['address'];
442
+		$newobject->zip=$thirdparty['zip'];
443
+		$newobject->town=$thirdparty['town'];
444
+
445
+		$newobject->country_id=$thirdparty['country_id'];
446
+		if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3);
447
+		$newobject->province_id=$thirdparty['province_id'];
448
+		//if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
449
+
450
+		$newobject->phone=$thirdparty['phone'];
451
+		$newobject->fax=$thirdparty['fax'];
452
+		$newobject->email=$thirdparty['email'];
453
+		$newobject->url=$thirdparty['url'];
454
+		$newobject->idprof1=$thirdparty['profid1'];
455
+		$newobject->idprof2=$thirdparty['profid2'];
456
+		$newobject->idprof3=$thirdparty['profid3'];
457
+		$newobject->idprof4=$thirdparty['profid4'];
458
+		$newobject->idprof5=$thirdparty['profid5'];
459
+		$newobject->idprof6=$thirdparty['profid6'];
460
+
461
+		$newobject->capital=$thirdparty['capital'];
462
+
463
+		$newobject->barcode=$thirdparty['barcode'];
464
+		$newobject->tva_assuj=$thirdparty['vat_used'];
465
+		$newobject->tva_intra=$thirdparty['vat_number'];
466
+
467
+		$newobject->canvas=$thirdparty['canvas'];
468
+		$newobject->particulier=$thirdparty['individual'];
469
+
470
+		// Retrieve all extrafields for thirdsparty
471
+		// fetch optionals attributes and labels
472
+		$extrafields=new ExtraFields($db);
473
+		$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
474
+		foreach($extrafields->attribute_label as $key=>$label)
475
+		{
476
+			$key='options_'.$key;
477
+			$newobject->array_options[$key]=$thirdparty[$key];
478
+		}
479
+
480
+		$db->begin();
481
+
482
+		$result=$newobject->create($fuser);
483
+		if ($newobject->particulier && $result > 0) {
484
+			$newobject->firstname = $thirdparty['firstname'];
485
+			$newobject->name_bis = $thirdparty['lastname'];
486
+			$result = $newobject->create_individual($fuser);
487
+		}
488
+		if ($result <= 0)
489
+		{
490
+			$error++;
491
+		}
492
+
493
+		if (! $error)
494
+		{
495
+			$db->commit();
496
+
497
+			// Patch to add capability to associate (one) sale representative
498
+			if($thirdparty['commid'] && $thirdparty['commid']>0)
499
+				$newobject->add_commercial($fuser, $thirdparty["commid"]);
500
+
501
+			$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
502
+		}
503
+		else
504
+		{
505
+			$db->rollback();
506
+			$error++;
507
+			$errorcode='KO';
508
+			$errorlabel=$newobject->error;
509
+		}
510
+	}
511
+
512
+	if ($error)
513
+	{
514
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
515
+	}
516
+
517
+	return $objectresp;
518 518
 }
519 519
 
520 520
 /**
@@ -656,98 +656,98 @@  discard block
 block discarded – undo
656 656
  */
657 657
 function getListOfThirdParties($authentication,$filterthirdparty)
658 658
 {
659
-    global $db,$conf,$langs;
660
-
661
-    $now=dol_now();
662
-
663
-    dol_syslog("Function: getListOfThirdParties login=".$authentication['login']);
664
-
665
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
666
-
667
-    // Init and check authentication
668
-    $objectresp=array();
669
-    $arraythirdparties=array();
670
-
671
-    $errorcode='';$errorlabel='';
672
-    $error=0;
673
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
674
-    // Check parameters
675
-
676
-    if (! $error)
677
-    {
678
-        $sql  = "SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*";
679
-        $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
680
-        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON s.fk_pays = c.rowid";
681
-        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as extra ON s.rowid=fk_object";
682
-
683
-        $sql.=" WHERE entity=".$conf->entity;
684
-        foreach($filterthirdparty as $key => $val)
685
-        {
686
-            if ($key == 'name'     && $val != '')  $sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
687
-        	if ($key == 'client'   && (int) $val > 0)  $sql.=" AND s.client = ".$db->escape($val);
688
-            if ($key == 'supplier' && (int) $val > 0)  $sql.=" AND s.fournisseur = ".$db->escape($val);
689
-            if ($key == 'category' && (int) $val > 0)  $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
690
-        }
691
-        dol_syslog("Function: getListOfThirdParties", LOG_DEBUG);
692
-
693
-        $extrafields=new ExtraFields($db);
694
-        $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
695
-
696
-
697
-        $resql=$db->query($sql);
698
-        if ($resql)
699
-        {
700
-            $num=$db->num_rows($resql);
701
-
702
-            $i=0;
703
-            while ($i < $num)
704
-            {
705
-                $extrafieldsOptions=array();
706
-                $obj=$db->fetch_object($resql);
707
-                foreach($extrafields->attribute_label as $key=>$label)
708
-                {
709
-                    $extrafieldsOptions['options_'.$key] = $obj->{$key};
710
-                }
711
-                $arraythirdparties[]=array('id'=>$obj->socRowid,
712
-                    'ref'=>$obj->ref,
713
-                    'ref_ext'=>$obj->ref_ext,
714
-                    'adress'=>$obj->adress,
715
-                    'zip'=>$obj->zip,
716
-                    'town'=>$obj->town,
717
-                    'country'=>$obj->country,
718
-                    'phone'=>$obj->phone,
719
-                    'fax'=>$obj->fax,
720
-                    'url'=>$obj->url
721
-                );
722
-                $arraythirdparties[$i] = array_merge($arraythirdparties[$i],$extrafieldsOptions);
723
-
724
-                $i++;
725
-            }
726
-        }
727
-        else
728
-        {
729
-            $error++;
730
-            $errorcode=$db->lasterrno();
731
-            $errorlabel=$db->lasterror();
732
-        }
733
-    }
734
-
735
-    if ($error)
736
-    {
737
-        $objectresp = array(
738
-            'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
739
-            'thirdparties'=>$arraythirdparties
740
-        );
741
-    }
742
-    else
743
-    {
744
-        $objectresp = array(
745
-            'result'=>array('result_code' => 'OK', 'result_label' => ''),
746
-            'thirdparties'=>$arraythirdparties
747
-        );
748
-    }
749
-
750
-    return $objectresp;
659
+	global $db,$conf,$langs;
660
+
661
+	$now=dol_now();
662
+
663
+	dol_syslog("Function: getListOfThirdParties login=".$authentication['login']);
664
+
665
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
666
+
667
+	// Init and check authentication
668
+	$objectresp=array();
669
+	$arraythirdparties=array();
670
+
671
+	$errorcode='';$errorlabel='';
672
+	$error=0;
673
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
674
+	// Check parameters
675
+
676
+	if (! $error)
677
+	{
678
+		$sql  = "SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*";
679
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
680
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON s.fk_pays = c.rowid";
681
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as extra ON s.rowid=fk_object";
682
+
683
+		$sql.=" WHERE entity=".$conf->entity;
684
+		foreach($filterthirdparty as $key => $val)
685
+		{
686
+			if ($key == 'name'     && $val != '')  $sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
687
+			if ($key == 'client'   && (int) $val > 0)  $sql.=" AND s.client = ".$db->escape($val);
688
+			if ($key == 'supplier' && (int) $val > 0)  $sql.=" AND s.fournisseur = ".$db->escape($val);
689
+			if ($key == 'category' && (int) $val > 0)  $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
690
+		}
691
+		dol_syslog("Function: getListOfThirdParties", LOG_DEBUG);
692
+
693
+		$extrafields=new ExtraFields($db);
694
+		$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
695
+
696
+
697
+		$resql=$db->query($sql);
698
+		if ($resql)
699
+		{
700
+			$num=$db->num_rows($resql);
701
+
702
+			$i=0;
703
+			while ($i < $num)
704
+			{
705
+				$extrafieldsOptions=array();
706
+				$obj=$db->fetch_object($resql);
707
+				foreach($extrafields->attribute_label as $key=>$label)
708
+				{
709
+					$extrafieldsOptions['options_'.$key] = $obj->{$key};
710
+				}
711
+				$arraythirdparties[]=array('id'=>$obj->socRowid,
712
+					'ref'=>$obj->ref,
713
+					'ref_ext'=>$obj->ref_ext,
714
+					'adress'=>$obj->adress,
715
+					'zip'=>$obj->zip,
716
+					'town'=>$obj->town,
717
+					'country'=>$obj->country,
718
+					'phone'=>$obj->phone,
719
+					'fax'=>$obj->fax,
720
+					'url'=>$obj->url
721
+				);
722
+				$arraythirdparties[$i] = array_merge($arraythirdparties[$i],$extrafieldsOptions);
723
+
724
+				$i++;
725
+			}
726
+		}
727
+		else
728
+		{
729
+			$error++;
730
+			$errorcode=$db->lasterrno();
731
+			$errorlabel=$db->lasterror();
732
+		}
733
+	}
734
+
735
+	if ($error)
736
+	{
737
+		$objectresp = array(
738
+			'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
739
+			'thirdparties'=>$arraythirdparties
740
+		);
741
+	}
742
+	else
743
+	{
744
+		$objectresp = array(
745
+			'result'=>array('result_code' => 'OK', 'result_label' => ''),
746
+			'thirdparties'=>$arraythirdparties
747
+		);
748
+	}
749
+
750
+	return $objectresp;
751 751
 }
752 752
 
753 753
 /**
Please login to merge, or discard this patch.
Spacing   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
24 24
 
25 25
 require_once '../master.inc.php';
26
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
26
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
27 27
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
28 28
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
29 29
 
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 {
41 41
 	$langs->load("admin");
42 42
 	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
43
-	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
43
+	print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
44 44
 	print $langs->trans("ToActivateModule");
45 45
 	exit;
46 46
 }
47 47
 
48 48
 // Create the soap Object
49 49
 $server = new nusoap_server();
50
-$server->soap_defencoding='UTF-8';
51
-$server->decode_utf8=false;
52
-$ns='http://www.dolibarr.org/ns/';
53
-$server->configureWSDL('WebServicesDolibarrThirdParty',$ns);
54
-$server->wsdl->schemaTargetNamespace=$ns;
50
+$server->soap_defencoding = 'UTF-8';
51
+$server->decode_utf8 = false;
52
+$ns = 'http://www.dolibarr.org/ns/';
53
+$server->configureWSDL('WebServicesDolibarrThirdParty', $ns);
54
+$server->wsdl->schemaTargetNamespace = $ns;
55 55
 
56 56
 
57 57
 // Define WSDL Authentication object
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     'all',
63 63
     '',
64 64
     array(
65
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
66
-    	'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
67
-    	'login' => array('name'=>'login','type'=>'xsd:string'),
68
-        'password' => array('name'=>'password','type'=>'xsd:string'),
69
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
65
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
66
+    	'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
67
+    	'login' => array('name'=>'login', 'type'=>'xsd:string'),
68
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
69
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
70 70
     )
71 71
 );
72 72
 // Define WSDL Return object
@@ -77,67 +77,67 @@  discard block
 block discarded – undo
77 77
     'all',
78 78
     '',
79 79
     array(
80
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
81
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
80
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
81
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
82 82
     )
83 83
 );
84 84
 
85 85
 
86
-$thirdparty_fields= array(
87
-    	'id' => array('name'=>'id','type'=>'xsd:string'),
88
-        'ref' => array('name'=>'name','type'=>'xsd:string'),
89
-        'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
90
-        'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'),
91
-		'status' => array('name'=>'status','type'=>'xsd:string'),
92
-        'client' => array('name'=>'client','type'=>'xsd:string'),
93
-        'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
94
-        'customer_code' => array('name'=>'customer_code','type'=>'xsd:string'),
95
-        'supplier_code' => array('name'=>'supplier_code','type'=>'xsd:string'),
96
-        'customer_code_accountancy' => array('name'=>'customer_code_accountancy','type'=>'xsd:string'),
97
-        'supplier_code_accountancy' => array('name'=>'supplier_code_accountancy','type'=>'xsd:string'),
98
-        'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
99
-        'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
100
-        'note_private' => array('name'=>'note_private','type'=>'xsd:string'),
101
-		'note_public' => array('name'=>'note_public','type'=>'xsd:string'),
102
-    	'address' => array('name'=>'address','type'=>'xsd:string'),
103
-    	'zip' => array('name'=>'zip','type'=>'xsd:string'),
104
-    	'town' => array('name'=>'town','type'=>'xsd:string'),
105
-    	'province_id' => array('name'=>'province_id','type'=>'xsd:string'),
106
-    	'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
107
-    	'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
108
-    	'country' => array('name'=>'country','type'=>'xsd:string'),
109
-        'phone' => array('name'=>'phone','type'=>'xsd:string'),
110
-    	'fax' => array('name'=>'fax','type'=>'xsd:string'),
111
-    	'email' => array('name'=>'email','type'=>'xsd:string'),
112
-    	'url' => array('name'=>'url','type'=>'xsd:string'),
113
-    	'profid1' => array('name'=>'profid1','type'=>'xsd:string'),
114
-    	'profid2' => array('name'=>'profid2','type'=>'xsd:string'),
115
-    	'profid3' => array('name'=>'profid3','type'=>'xsd:string'),
116
-    	'profid4' => array('name'=>'profid4','type'=>'xsd:string'),
117
-    	'profid5' => array('name'=>'profid5','type'=>'xsd:string'),
118
-    	'profid6' => array('name'=>'profid6','type'=>'xsd:string'),
119
-        'capital' => array('name'=>'capital','type'=>'xsd:string'),
120
-    	'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
121
-    	'vat_number' => array('name'=>'vat_number','type'=>'xsd:string'));
86
+$thirdparty_fields = array(
87
+    	'id' => array('name'=>'id', 'type'=>'xsd:string'),
88
+        'ref' => array('name'=>'name', 'type'=>'xsd:string'),
89
+        'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
90
+        'fk_user_author' => array('name'=>'fk_user_author', 'type'=>'xsd:string'),
91
+		'status' => array('name'=>'status', 'type'=>'xsd:string'),
92
+        'client' => array('name'=>'client', 'type'=>'xsd:string'),
93
+        'supplier' => array('name'=>'supplier', 'type'=>'xsd:string'),
94
+        'customer_code' => array('name'=>'customer_code', 'type'=>'xsd:string'),
95
+        'supplier_code' => array('name'=>'supplier_code', 'type'=>'xsd:string'),
96
+        'customer_code_accountancy' => array('name'=>'customer_code_accountancy', 'type'=>'xsd:string'),
97
+        'supplier_code_accountancy' => array('name'=>'supplier_code_accountancy', 'type'=>'xsd:string'),
98
+        'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'),
99
+        'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'),
100
+        'note_private' => array('name'=>'note_private', 'type'=>'xsd:string'),
101
+		'note_public' => array('name'=>'note_public', 'type'=>'xsd:string'),
102
+    	'address' => array('name'=>'address', 'type'=>'xsd:string'),
103
+    	'zip' => array('name'=>'zip', 'type'=>'xsd:string'),
104
+    	'town' => array('name'=>'town', 'type'=>'xsd:string'),
105
+    	'province_id' => array('name'=>'province_id', 'type'=>'xsd:string'),
106
+    	'country_id' => array('name'=>'country_id', 'type'=>'xsd:string'),
107
+    	'country_code' => array('name'=>'country_code', 'type'=>'xsd:string'),
108
+    	'country' => array('name'=>'country', 'type'=>'xsd:string'),
109
+        'phone' => array('name'=>'phone', 'type'=>'xsd:string'),
110
+    	'fax' => array('name'=>'fax', 'type'=>'xsd:string'),
111
+    	'email' => array('name'=>'email', 'type'=>'xsd:string'),
112
+    	'url' => array('name'=>'url', 'type'=>'xsd:string'),
113
+    	'profid1' => array('name'=>'profid1', 'type'=>'xsd:string'),
114
+    	'profid2' => array('name'=>'profid2', 'type'=>'xsd:string'),
115
+    	'profid3' => array('name'=>'profid3', 'type'=>'xsd:string'),
116
+    	'profid4' => array('name'=>'profid4', 'type'=>'xsd:string'),
117
+    	'profid5' => array('name'=>'profid5', 'type'=>'xsd:string'),
118
+    	'profid6' => array('name'=>'profid6', 'type'=>'xsd:string'),
119
+        'capital' => array('name'=>'capital', 'type'=>'xsd:string'),
120
+    	'vat_used' => array('name'=>'vat_used', 'type'=>'xsd:string'),
121
+    	'vat_number' => array('name'=>'vat_number', 'type'=>'xsd:string'));
122 122
 
123 123
 // Retrieve all extrafields for thirdsparty
124 124
 // fetch optionals attributes and labels
125
-$extrafields=new ExtraFields($db);
126
-$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
127
-if (count($extrafields)>0) {
125
+$extrafields = new ExtraFields($db);
126
+$extralabels = $extrafields->fetch_name_optionals_label('societe', true);
127
+if (count($extrafields) > 0) {
128 128
 	$extrafield_array = array();
129 129
 }
130
-foreach($extrafields->attribute_label as $key=>$label)
130
+foreach ($extrafields->attribute_label as $key=>$label)
131 131
 {
132 132
 	//$value=$object->array_options["options_".$key];
133
-	$type =$extrafields->attribute_type[$key];
134
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
135
-	else {$type='xsd:string';}
133
+	$type = $extrafields->attribute_type[$key];
134
+	if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
135
+	else {$type = 'xsd:string'; }
136 136
 
137
-	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
137
+	$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
138 138
 }
139 139
 
140
-$thirdparty_fields=array_merge($thirdparty_fields,$extrafield_array);
140
+$thirdparty_fields = array_merge($thirdparty_fields, $extrafield_array);
141 141
 
142 142
 // Define other specific objects
143 143
 $server->wsdl->addComplexType(
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
     '',
159 159
     array(
160 160
         //'limit' => array('name'=>'limit','type'=>'xsd:string'),
161
-        'client' => array('name'=>'client','type'=>'xsd:string'),
162
-        'supplier' => array('name'=>'supplier','type'=>'xsd:string'),
163
-    	'category' => array('name'=>'category','type'=>'xsd:string')
161
+        'client' => array('name'=>'client', 'type'=>'xsd:string'),
162
+        'supplier' => array('name'=>'supplier', 'type'=>'xsd:string'),
163
+    	'category' => array('name'=>'category', 'type'=>'xsd:string')
164 164
     )
165 165
 );
166 166
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     'SOAP-ENC:Array',
173 173
     array(),
174 174
     array(
175
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:thirdparty[]')
175
+        array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:thirdparty[]')
176 176
     ),
177 177
     'tns:thirdparty'
178 178
 );
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
197 197
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
198 198
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
199
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
200
-$styleuse='encoded';   // encoded/literal/literal wrapped
199
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
200
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
201 201
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
202 202
 
203 203
 // Register WSDL
204 204
 $server->register(
205 205
     'getThirdParty',
206 206
     // Entry values
207
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
207
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
208 208
     // Exit values
209
-    array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'),
209
+    array('result'=>'tns:result', 'thirdparty'=>'tns:thirdparty'),
210 210
     $ns,
211 211
     $ns.'#getThirdParty',
212 212
     $styledoc,
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 $server->register(
219 219
     'createThirdParty',
220 220
     // Entry values
221
-    array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
221
+    array('authentication'=>'tns:authentication', 'thirdparty'=>'tns:thirdparty'),
222 222
     // Exit values
223
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
223
+    array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'),
224 224
     $ns,
225 225
     $ns.'#createThirdParty',
226 226
     $styledoc,
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 $server->register(
233 233
 	'updateThirdParty',
234 234
 	// Entry values
235
-	array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
235
+	array('authentication'=>'tns:authentication', 'thirdparty'=>'tns:thirdparty'),
236 236
 	// Exit values
237
-	array('result'=>'tns:result','id'=>'xsd:string'),
237
+	array('result'=>'tns:result', 'id'=>'xsd:string'),
238 238
 	$ns,
239 239
 	$ns.'#updateThirdParty',
240 240
 	$styledoc,
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 $server->register(
248 248
     'getListOfThirdParties',
249 249
     // Entry values
250
-    array('authentication'=>'tns:authentication','filterthirdparty'=>'tns:filterthirdparty'),
250
+    array('authentication'=>'tns:authentication', 'filterthirdparty'=>'tns:filterthirdparty'),
251 251
     // Exit values
252
-    array('result'=>'tns:result','thirdparties'=>'tns:ThirdPartiesArray2'),
252
+    array('result'=>'tns:result', 'thirdparties'=>'tns:ThirdPartiesArray2'),
253 253
     $ns,
254 254
     $ns.'#getListOfThirdParties',
255 255
     $styledoc,
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 $server->register(
262 262
 		'deleteThirdParty',
263 263
 		// Entry values
264
-		array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
264
+		array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'),
265 265
 		// Exit values
266
-		array('result'=>'tns:result','id'=>'xsd:string'),
266
+		array('result'=>'tns:result', 'id'=>'xsd:string'),
267 267
 		$ns,
268 268
 		$ns.'#deleteThirdParty',
269 269
 		$styledoc,
@@ -282,38 +282,38 @@  discard block
 block discarded – undo
282 282
  * @param	string		$ref_ext	   		external reference
283 283
  * @return	array							Array result
284 284
  */
285
-function getThirdParty($authentication,$id='',$ref='',$ref_ext='')
285
+function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
286 286
 {
287
-	global $db,$conf,$langs;
287
+	global $db, $conf, $langs;
288 288
 
289 289
 	dol_syslog("Function: getThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
290 290
 
291
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
291
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
292 292
 
293 293
     // Init and check authentication
294
-    $objectresp=array();
295
-    $errorcode='';$errorlabel='';
296
-    $error=0;
297
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
294
+    $objectresp = array();
295
+    $errorcode = ''; $errorlabel = '';
296
+    $error = 0;
297
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
298 298
     // Check parameters
299
-	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
299
+	if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
300 300
 	{
301 301
 		$error++;
302
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
302
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
303 303
 	}
304 304
 
305
-	if (! $error)
305
+	if (!$error)
306 306
 	{
307 307
 		$fuser->getrights();
308 308
 
309 309
 		if ($fuser->rights->societe->lire)
310 310
 		{
311
-			$thirdparty=new Societe($db);
312
-			$result=$thirdparty->fetch($id,$ref,$ref_ext);
311
+			$thirdparty = new Societe($db);
312
+			$result = $thirdparty->fetch($id, $ref, $ref_ext);
313 313
 			if ($result > 0)
314 314
 			{
315 315
 
316
-				$thirdparty_result_fields=array(
316
+				$thirdparty_result_fields = array(
317 317
 				    	'id' => $thirdparty->id,
318 318
 			   			'ref' => $thirdparty->name,
319 319
 			   			'ref_ext' => $thirdparty->ref_ext,
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 				        'customer_code_accountancy' => $thirdparty->code_compta,
326 326
 			            'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
327 327
 			            'fk_user_author' => $thirdparty->fk_user_author,
328
-			    		'date_creation' => dol_print_date($thirdparty->date_creation,'dayhourrfc'),
329
-			    		'date_modification' => dol_print_date($thirdparty->date_modification,'dayhourrfc'),
328
+			    		'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'),
329
+			    		'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'),
330 330
 			            'address' => $thirdparty->address,
331 331
 				        'zip' => $thirdparty->zip,
332 332
 				        'town' => $thirdparty->town,
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
 
354 354
 				// Retrieve all extrafields for thirdsparty
355 355
 				// fetch optionals attributes and labels
356
-				$extrafields=new ExtraFields($db);
357
-				$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
356
+				$extrafields = new ExtraFields($db);
357
+				$extralabels = $extrafields->fetch_name_optionals_label('societe', true);
358 358
 				//Get extrafield values
359
-				$thirdparty->fetch_optionals($thirdparty->id,$extralabels);
359
+				$thirdparty->fetch_optionals($thirdparty->id, $extralabels);
360 360
 
361
-				foreach($extrafields->attribute_label as $key=>$label)
361
+				foreach ($extrafields->attribute_label as $key=>$label)
362 362
 				{
363
-					$thirdparty_result_fields=array_merge($thirdparty_result_fields,array('options_'.$key => $thirdparty->array_options['options_'.$key]));
363
+					$thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key]));
364 364
 				}
365 365
 
366 366
 			    // Create
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 			else
372 372
 			{
373 373
 				$error++;
374
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
374
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
375 375
 			}
376 376
 		}
377 377
 		else
378 378
 		{
379 379
 			$error++;
380
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
380
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
381 381
 		}
382 382
 	}
383 383
 
@@ -398,88 +398,88 @@  discard block
 block discarded – undo
398 398
  * @param	Societe		$thirdparty		    Thirdparty
399 399
  * @return	array							Array result
400 400
  */
401
-function createThirdParty($authentication,$thirdparty)
401
+function createThirdParty($authentication, $thirdparty)
402 402
 {
403
-    global $db,$conf,$langs;
403
+    global $db, $conf, $langs;
404 404
 
405
-    $now=dol_now();
405
+    $now = dol_now();
406 406
 
407 407
     dol_syslog("Function: createThirdParty login=".$authentication['login']);
408 408
 
409
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
409
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
410 410
 
411 411
     // Init and check authentication
412
-    $objectresp=array();
413
-    $errorcode='';$errorlabel='';
414
-    $error=0;
415
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
412
+    $objectresp = array();
413
+    $errorcode = ''; $errorlabel = '';
414
+    $error = 0;
415
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
416 416
     // Check parameters
417 417
     if (empty($thirdparty['ref']))
418 418
     {
419
-        $error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
419
+        $error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory.";
420 420
     }
421 421
 
422 422
 
423
-    if (! $error)
423
+    if (!$error)
424 424
     {
425 425
         include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
426 426
 
427
-        $newobject=new Societe($db);
428
-        $newobject->ref=$thirdparty['ref'];
429
-        $newobject->name=$thirdparty['ref'];
430
-        $newobject->ref_ext=$thirdparty['ref_ext'];
431
-        $newobject->status=$thirdparty['status'];
432
-        $newobject->client=$thirdparty['client'];
433
-        $newobject->fournisseur=$thirdparty['supplier'];
434
-        $newobject->code_client=$thirdparty['customer_code'];
435
-        $newobject->code_fournisseur=$thirdparty['supplier_code'];
436
-        $newobject->code_compta=$thirdparty['customer_code_accountancy'];
437
-        $newobject->code_compta_fournisseur=$thirdparty['supplier_code_accountancy'];
438
-        $newobject->date_creation=$now;
439
-        $newobject->note_private=$thirdparty['note_private'];
440
-        $newobject->note_public=$thirdparty['note_public'];
441
-        $newobject->address=$thirdparty['address'];
442
-        $newobject->zip=$thirdparty['zip'];
443
-        $newobject->town=$thirdparty['town'];
444
-
445
-        $newobject->country_id=$thirdparty['country_id'];
446
-        if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3);
447
-        $newobject->province_id=$thirdparty['province_id'];
427
+        $newobject = new Societe($db);
428
+        $newobject->ref = $thirdparty['ref'];
429
+        $newobject->name = $thirdparty['ref'];
430
+        $newobject->ref_ext = $thirdparty['ref_ext'];
431
+        $newobject->status = $thirdparty['status'];
432
+        $newobject->client = $thirdparty['client'];
433
+        $newobject->fournisseur = $thirdparty['supplier'];
434
+        $newobject->code_client = $thirdparty['customer_code'];
435
+        $newobject->code_fournisseur = $thirdparty['supplier_code'];
436
+        $newobject->code_compta = $thirdparty['customer_code_accountancy'];
437
+        $newobject->code_compta_fournisseur = $thirdparty['supplier_code_accountancy'];
438
+        $newobject->date_creation = $now;
439
+        $newobject->note_private = $thirdparty['note_private'];
440
+        $newobject->note_public = $thirdparty['note_public'];
441
+        $newobject->address = $thirdparty['address'];
442
+        $newobject->zip = $thirdparty['zip'];
443
+        $newobject->town = $thirdparty['town'];
444
+
445
+        $newobject->country_id = $thirdparty['country_id'];
446
+        if ($thirdparty['country_code']) $newobject->country_id = getCountry($thirdparty['country_code'], 3);
447
+        $newobject->province_id = $thirdparty['province_id'];
448 448
         //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
449 449
 
450
-        $newobject->phone=$thirdparty['phone'];
451
-        $newobject->fax=$thirdparty['fax'];
452
-        $newobject->email=$thirdparty['email'];
453
-        $newobject->url=$thirdparty['url'];
454
-        $newobject->idprof1=$thirdparty['profid1'];
455
-        $newobject->idprof2=$thirdparty['profid2'];
456
-        $newobject->idprof3=$thirdparty['profid3'];
457
-        $newobject->idprof4=$thirdparty['profid4'];
458
-        $newobject->idprof5=$thirdparty['profid5'];
459
-        $newobject->idprof6=$thirdparty['profid6'];
450
+        $newobject->phone = $thirdparty['phone'];
451
+        $newobject->fax = $thirdparty['fax'];
452
+        $newobject->email = $thirdparty['email'];
453
+        $newobject->url = $thirdparty['url'];
454
+        $newobject->idprof1 = $thirdparty['profid1'];
455
+        $newobject->idprof2 = $thirdparty['profid2'];
456
+        $newobject->idprof3 = $thirdparty['profid3'];
457
+        $newobject->idprof4 = $thirdparty['profid4'];
458
+        $newobject->idprof5 = $thirdparty['profid5'];
459
+        $newobject->idprof6 = $thirdparty['profid6'];
460 460
 
461
-        $newobject->capital=$thirdparty['capital'];
461
+        $newobject->capital = $thirdparty['capital'];
462 462
 
463
-        $newobject->barcode=$thirdparty['barcode'];
464
-        $newobject->tva_assuj=$thirdparty['vat_used'];
465
-        $newobject->tva_intra=$thirdparty['vat_number'];
463
+        $newobject->barcode = $thirdparty['barcode'];
464
+        $newobject->tva_assuj = $thirdparty['vat_used'];
465
+        $newobject->tva_intra = $thirdparty['vat_number'];
466 466
 
467
-        $newobject->canvas=$thirdparty['canvas'];
468
-        $newobject->particulier=$thirdparty['individual'];
467
+        $newobject->canvas = $thirdparty['canvas'];
468
+        $newobject->particulier = $thirdparty['individual'];
469 469
 
470 470
         // Retrieve all extrafields for thirdsparty
471 471
         // fetch optionals attributes and labels
472
-        $extrafields=new ExtraFields($db);
473
-        $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
474
-        foreach($extrafields->attribute_label as $key=>$label)
472
+        $extrafields = new ExtraFields($db);
473
+        $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
474
+        foreach ($extrafields->attribute_label as $key=>$label)
475 475
         {
476
-        	$key='options_'.$key;
477
-        	$newobject->array_options[$key]=$thirdparty[$key];
476
+        	$key = 'options_'.$key;
477
+        	$newobject->array_options[$key] = $thirdparty[$key];
478 478
         }
479 479
 
480 480
         $db->begin();
481 481
 
482
-        $result=$newobject->create($fuser);
482
+        $result = $newobject->create($fuser);
483 483
         if ($newobject->particulier && $result > 0) {
484 484
             $newobject->firstname = $thirdparty['firstname'];
485 485
             $newobject->name_bis = $thirdparty['lastname'];
@@ -490,22 +490,22 @@  discard block
 block discarded – undo
490 490
             $error++;
491 491
         }
492 492
 
493
-        if (! $error)
493
+        if (!$error)
494 494
         {
495 495
             $db->commit();
496 496
 
497 497
             // Patch to add capability to associate (one) sale representative
498
-            if($thirdparty['commid'] && $thirdparty['commid']>0)
498
+            if ($thirdparty['commid'] && $thirdparty['commid'] > 0)
499 499
                 $newobject->add_commercial($fuser, $thirdparty["commid"]);
500 500
 
501
-            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
501
+            $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
502 502
         }
503 503
         else
504 504
         {
505 505
             $db->rollback();
506 506
             $error++;
507
-            $errorcode='KO';
508
-            $errorlabel=$newobject->error;
507
+            $errorcode = 'KO';
508
+            $errorlabel = $newobject->error;
509 509
         }
510 510
     }
511 511
 
@@ -524,102 +524,102 @@  discard block
 block discarded – undo
524 524
  * @param	Societe		$thirdparty		    Thirdparty
525 525
  * @return	array							Array result
526 526
  */
527
-function updateThirdParty($authentication,$thirdparty)
527
+function updateThirdParty($authentication, $thirdparty)
528 528
 {
529
-	global $db,$conf,$langs;
529
+	global $db, $conf, $langs;
530 530
 
531
-	$now=dol_now();
531
+	$now = dol_now();
532 532
 
533 533
 	dol_syslog("Function: updateThirdParty login=".$authentication['login']);
534 534
 
535
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
535
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
536 536
 
537 537
 	// Init and check authentication
538
-	$objectresp=array();
539
-	$errorcode='';$errorlabel='';
540
-	$error=0;
541
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
538
+	$objectresp = array();
539
+	$errorcode = ''; $errorlabel = '';
540
+	$error = 0;
541
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
542 542
 	// Check parameters
543
-	if (empty($thirdparty['id']))	{
544
-		$error++; $errorcode='KO'; $errorlabel="Thirdparty id is mandatory.";
543
+	if (empty($thirdparty['id'])) {
544
+		$error++; $errorcode = 'KO'; $errorlabel = "Thirdparty id is mandatory.";
545 545
 	}
546 546
 
547
-	if (! $error)
547
+	if (!$error)
548 548
 	{
549
-		$objectfound=false;
549
+		$objectfound = false;
550 550
 
551 551
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
552 552
 
553
-		$object=new Societe($db);
554
-		$result=$object->fetch($thirdparty['id']);
553
+		$object = new Societe($db);
554
+		$result = $object->fetch($thirdparty['id']);
555 555
 
556 556
 		if (!empty($object->id)) {
557 557
 
558
-			$objectfound=true;
559
-
560
-			$object->ref=$thirdparty['ref'];
561
-			$object->name=$thirdparty['ref'];
562
-			$object->ref_ext=$thirdparty['ref_ext'];
563
-			$object->status=$thirdparty['status'];
564
-			$object->client=$thirdparty['client'];
565
-			$object->fournisseur=$thirdparty['supplier'];
566
-			$object->code_client=$thirdparty['customer_code'];
567
-			$object->code_fournisseur=$thirdparty['supplier_code'];
568
-			$object->code_compta=$thirdparty['customer_code_accountancy'];
569
-			$object->code_compta_fournisseur=$thirdparty['supplier_code_accountancy'];
570
-			$object->date_creation=$now;
571
-			$object->note_private=$thirdparty['note_private'];
572
-			$object->note_public=$thirdparty['note_public'];
573
-			$object->address=$thirdparty['address'];
574
-			$object->zip=$thirdparty['zip'];
575
-			$object->town=$thirdparty['town'];
576
-
577
-			$object->country_id=$thirdparty['country_id'];
578
-			if ($thirdparty['country_code']) $object->country_id=getCountry($thirdparty['country_code'],3);
579
-			$object->province_id=$thirdparty['province_id'];
558
+			$objectfound = true;
559
+
560
+			$object->ref = $thirdparty['ref'];
561
+			$object->name = $thirdparty['ref'];
562
+			$object->ref_ext = $thirdparty['ref_ext'];
563
+			$object->status = $thirdparty['status'];
564
+			$object->client = $thirdparty['client'];
565
+			$object->fournisseur = $thirdparty['supplier'];
566
+			$object->code_client = $thirdparty['customer_code'];
567
+			$object->code_fournisseur = $thirdparty['supplier_code'];
568
+			$object->code_compta = $thirdparty['customer_code_accountancy'];
569
+			$object->code_compta_fournisseur = $thirdparty['supplier_code_accountancy'];
570
+			$object->date_creation = $now;
571
+			$object->note_private = $thirdparty['note_private'];
572
+			$object->note_public = $thirdparty['note_public'];
573
+			$object->address = $thirdparty['address'];
574
+			$object->zip = $thirdparty['zip'];
575
+			$object->town = $thirdparty['town'];
576
+
577
+			$object->country_id = $thirdparty['country_id'];
578
+			if ($thirdparty['country_code']) $object->country_id = getCountry($thirdparty['country_code'], 3);
579
+			$object->province_id = $thirdparty['province_id'];
580 580
 			//if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
581 581
 
582
-			$object->phone=$thirdparty['phone'];
583
-			$object->fax=$thirdparty['fax'];
584
-			$object->email=$thirdparty['email'];
585
-			$object->url=$thirdparty['url'];
586
-			$object->idprof1=$thirdparty['profid1'];
587
-			$object->idprof2=$thirdparty['profid2'];
588
-			$object->idprof3=$thirdparty['profid3'];
589
-			$object->idprof4=$thirdparty['profid4'];
590
-			$object->idprof5=$thirdparty['profid5'];
591
-			$object->idprof6=$thirdparty['profid6'];
582
+			$object->phone = $thirdparty['phone'];
583
+			$object->fax = $thirdparty['fax'];
584
+			$object->email = $thirdparty['email'];
585
+			$object->url = $thirdparty['url'];
586
+			$object->idprof1 = $thirdparty['profid1'];
587
+			$object->idprof2 = $thirdparty['profid2'];
588
+			$object->idprof3 = $thirdparty['profid3'];
589
+			$object->idprof4 = $thirdparty['profid4'];
590
+			$object->idprof5 = $thirdparty['profid5'];
591
+			$object->idprof6 = $thirdparty['profid6'];
592 592
 
593
-			$object->capital=$thirdparty['capital'];
593
+			$object->capital = $thirdparty['capital'];
594 594
 
595
-			$object->barcode=$thirdparty['barcode'];
596
-			$object->tva_assuj=$thirdparty['vat_used'];
597
-			$object->tva_intra=$thirdparty['vat_number'];
595
+			$object->barcode = $thirdparty['barcode'];
596
+			$object->tva_assuj = $thirdparty['vat_used'];
597
+			$object->tva_intra = $thirdparty['vat_number'];
598 598
 
599
-			$object->canvas=$thirdparty['canvas'];
599
+			$object->canvas = $thirdparty['canvas'];
600 600
 
601 601
 			// Retrieve all extrafields for thirdsparty
602 602
 			// fetch optionals attributes and labels
603
-			$extrafields=new ExtraFields($db);
604
-			$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
605
-			foreach($extrafields->attribute_label as $key=>$label)
603
+			$extrafields = new ExtraFields($db);
604
+			$extralabels = $extrafields->fetch_name_optionals_label('societe', true);
605
+			foreach ($extrafields->attribute_label as $key=>$label)
606 606
 			{
607
-				$key='options_'.$key;
608
-				$object->array_options[$key]=$thirdparty[$key];
607
+				$key = 'options_'.$key;
608
+				$object->array_options[$key] = $thirdparty[$key];
609 609
 			}
610 610
 
611 611
 			$db->begin();
612 612
 
613
-			$result=$object->update($thirdparty['id'],$fuser);
613
+			$result = $object->update($thirdparty['id'], $fuser);
614 614
 			if ($result <= 0) {
615 615
 				$error++;
616 616
 			}
617 617
 		}
618 618
 
619
-		if ((! $error) && ($objectfound))
619
+		if ((!$error) && ($objectfound))
620 620
 		{
621 621
 			$db->commit();
622
-			$objectresp=array(
622
+			$objectresp = array(
623 623
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
624 624
 					'id'=>$object->id
625 625
 			);
@@ -628,12 +628,12 @@  discard block
 block discarded – undo
628 628
 		{
629 629
 			$db->rollback();
630 630
 			$error++;
631
-			$errorcode='KO';
632
-			$errorlabel=$object->error;
631
+			$errorcode = 'KO';
632
+			$errorlabel = $object->error;
633 633
 		} else {
634 634
 			$error++;
635
-			$errorcode='NOT_FOUND';
636
-			$errorlabel='Thirdparty id='.$thirdparty['id'].' cannot be found';
635
+			$errorcode = 'NOT_FOUND';
636
+			$errorlabel = 'Thirdparty id='.$thirdparty['id'].' cannot be found';
637 637
 		}
638 638
 	}
639 639
 
@@ -654,61 +654,61 @@  discard block
 block discarded – undo
654 654
  * @param	array		$filterthirdparty	Filter fields (key=>value to filer on. For example 'client'=>2, 'supplier'=>1, 'category'=>idcateg, 'name'=>'searchstring', ...)
655 655
  * @return	array							Array result
656 656
  */
657
-function getListOfThirdParties($authentication,$filterthirdparty)
657
+function getListOfThirdParties($authentication, $filterthirdparty)
658 658
 {
659
-    global $db,$conf,$langs;
659
+    global $db, $conf, $langs;
660 660
 
661
-    $now=dol_now();
661
+    $now = dol_now();
662 662
 
663 663
     dol_syslog("Function: getListOfThirdParties login=".$authentication['login']);
664 664
 
665
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
665
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
666 666
 
667 667
     // Init and check authentication
668
-    $objectresp=array();
669
-    $arraythirdparties=array();
668
+    $objectresp = array();
669
+    $arraythirdparties = array();
670 670
 
671
-    $errorcode='';$errorlabel='';
672
-    $error=0;
673
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
671
+    $errorcode = ''; $errorlabel = '';
672
+    $error = 0;
673
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
674 674
     // Check parameters
675 675
 
676
-    if (! $error)
676
+    if (!$error)
677 677
     {
678 678
         $sql  = "SELECT s.rowid as socRowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, c.label as country, s.phone, s.fax, s.url, extra.*";
679 679
         $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
680 680
         $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON s.fk_pays = c.rowid";
681 681
         $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as extra ON s.rowid=fk_object";
682 682
 
683
-        $sql.=" WHERE entity=".$conf->entity;
684
-        foreach($filterthirdparty as $key => $val)
683
+        $sql .= " WHERE entity=".$conf->entity;
684
+        foreach ($filterthirdparty as $key => $val)
685 685
         {
686
-            if ($key == 'name'     && $val != '')  $sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
687
-        	if ($key == 'client'   && (int) $val > 0)  $sql.=" AND s.client = ".$db->escape($val);
688
-            if ($key == 'supplier' && (int) $val > 0)  $sql.=" AND s.fournisseur = ".$db->escape($val);
689
-            if ($key == 'category' && (int) $val > 0)  $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
686
+            if ($key == 'name' && $val != '')  $sql .= " AND s.name LIKE '%".$db->escape($val)."%'";
687
+        	if ($key == 'client' && (int) $val > 0)  $sql .= " AND s.client = ".$db->escape($val);
688
+            if ($key == 'supplier' && (int) $val > 0)  $sql .= " AND s.fournisseur = ".$db->escape($val);
689
+            if ($key == 'category' && (int) $val > 0)  $sql .= " AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
690 690
         }
691 691
         dol_syslog("Function: getListOfThirdParties", LOG_DEBUG);
692 692
 
693
-        $extrafields=new ExtraFields($db);
694
-        $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
693
+        $extrafields = new ExtraFields($db);
694
+        $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
695 695
 
696 696
 
697
-        $resql=$db->query($sql);
697
+        $resql = $db->query($sql);
698 698
         if ($resql)
699 699
         {
700
-            $num=$db->num_rows($resql);
700
+            $num = $db->num_rows($resql);
701 701
 
702
-            $i=0;
702
+            $i = 0;
703 703
             while ($i < $num)
704 704
             {
705
-                $extrafieldsOptions=array();
706
-                $obj=$db->fetch_object($resql);
707
-                foreach($extrafields->attribute_label as $key=>$label)
705
+                $extrafieldsOptions = array();
706
+                $obj = $db->fetch_object($resql);
707
+                foreach ($extrafields->attribute_label as $key=>$label)
708 708
                 {
709 709
                     $extrafieldsOptions['options_'.$key] = $obj->{$key};
710 710
                 }
711
-                $arraythirdparties[]=array('id'=>$obj->socRowid,
711
+                $arraythirdparties[] = array('id'=>$obj->socRowid,
712 712
                     'ref'=>$obj->ref,
713 713
                     'ref_ext'=>$obj->ref_ext,
714 714
                     'adress'=>$obj->adress,
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
                     'fax'=>$obj->fax,
720 720
                     'url'=>$obj->url
721 721
                 );
722
-                $arraythirdparties[$i] = array_merge($arraythirdparties[$i],$extrafieldsOptions);
722
+                $arraythirdparties[$i] = array_merge($arraythirdparties[$i], $extrafieldsOptions);
723 723
 
724 724
                 $i++;
725 725
             }
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
         else
728 728
         {
729 729
             $error++;
730
-            $errorcode=$db->lasterrno();
731
-            $errorlabel=$db->lasterror();
730
+            $errorcode = $db->lasterrno();
731
+            $errorlabel = $db->lasterror();
732 732
         }
733 733
     }
734 734
 
@@ -759,42 +759,42 @@  discard block
 block discarded – undo
759 759
  * @param	string		$ref_ext	   		external reference
760 760
  * @return	array							Array result
761 761
  */
762
-function deleteThirdParty($authentication,$id='',$ref='',$ref_ext='')
762
+function deleteThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
763 763
 {
764
-	global $db,$conf,$langs;
764
+	global $db, $conf, $langs;
765 765
 
766 766
 	dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
767 767
 
768
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
768
+	if ($authentication['entity']) $conf->entity = $authentication['entity'];
769 769
 
770 770
 	// Init and check authentication
771
-	$objectresp=array();
772
-	$errorcode='';$errorlabel='';
773
-	$error=0;
774
-	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
771
+	$objectresp = array();
772
+	$errorcode = ''; $errorlabel = '';
773
+	$error = 0;
774
+	$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
775 775
 	// Check parameters
776
-	if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
776
+	if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
777 777
 	{
778 778
 		dol_syslog("Function: deleteThirdParty checkparam");
779 779
 		$error++;
780
-		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
780
+		$errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
781 781
 	}
782 782
 	dol_syslog("Function: deleteThirdParty 1");
783 783
 	
784
-	if (! $error)
784
+	if (!$error)
785 785
 	{
786 786
 		$fuser->getrights();
787 787
 
788 788
 		if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer)
789 789
 		{
790
-			$thirdparty=new Societe($db);
791
-			$result=$thirdparty->fetch($id,$ref,$ref_ext);
790
+			$thirdparty = new Societe($db);
791
+			$result = $thirdparty->fetch($id, $ref, $ref_ext);
792 792
 				
793 793
 			if ($result > 0)
794 794
 			{
795 795
 				$db->begin();
796 796
 				
797
-				$result=$thirdparty->delete($thirdparty->id, $fuser);
797
+				$result = $thirdparty->delete($thirdparty->id, $fuser);
798 798
 				
799 799
 				if ($result > 0)
800 800
 				{
@@ -806,22 +806,22 @@  discard block
 block discarded – undo
806 806
 				{						
807 807
 					$db->rollback();
808 808
 					$error++;
809
-					$errorcode='KO';
810
-					$errorlabel=$thirdparty->error;
809
+					$errorcode = 'KO';
810
+					$errorlabel = $thirdparty->error;
811 811
 					dol_syslog("Function: deleteThirdParty cant delete");
812 812
 				}
813 813
 			}
814 814
 			else
815 815
 			{
816 816
 				$error++;
817
-				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
817
+				$errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
818 818
 				
819 819
 			}
820 820
 		}
821 821
 		else
822 822
 		{
823 823
 			$error++;
824
-			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
824
+			$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
825 825
 		}
826 826
 	}
827 827
 
Please login to merge, or discard this patch.
Braces   +49 added lines, -34 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  *       \brief      File that is entry point to call Dolibarr WebServices
21 21
  */
22 22
 
23
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
23
+if (! defined("NOCSRFCHECK")) {
24
+	define("NOCSRFCHECK",'1');
25
+}
24 26
 
25 27
 require_once '../master.inc.php';
26 28
 require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
@@ -131,8 +133,7 @@  discard block
 block discarded – undo
131 133
 {
132 134
 	//$value=$object->array_options["options_".$key];
133 135
 	$type =$extrafields->attribute_type[$key];
134
-	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
135
-	else {$type='xsd:string';}
136
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
136 137
 
137 138
 	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
138 139
 }
@@ -288,7 +289,9 @@  discard block
 block discarded – undo
288 289
 
289 290
 	dol_syslog("Function: getThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
290 291
 
291
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
292
+	if ($authentication['entity']) {
293
+		$conf->entity=$authentication['entity'];
294
+	}
292 295
 
293 296
     // Init and check authentication
294 297
     $objectresp=array();
@@ -367,14 +370,12 @@  discard block
 block discarded – undo
367 370
 			    $objectresp = array(
368 371
 			    	'result'=>array('result_code'=>'OK', 'result_label'=>''),
369 372
 			        'thirdparty'=>$thirdparty_result_fields);
370
-			}
371
-			else
373
+			} else
372 374
 			{
373 375
 				$error++;
374 376
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
375 377
 			}
376
-		}
377
-		else
378
+		} else
378 379
 		{
379 380
 			$error++;
380 381
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -406,7 +407,9 @@  discard block
 block discarded – undo
406 407
 
407 408
     dol_syslog("Function: createThirdParty login=".$authentication['login']);
408 409
 
409
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
410
+    if ($authentication['entity']) {
411
+    	$conf->entity=$authentication['entity'];
412
+    }
410 413
 
411 414
     // Init and check authentication
412 415
     $objectresp=array();
@@ -443,7 +446,9 @@  discard block
 block discarded – undo
443 446
         $newobject->town=$thirdparty['town'];
444 447
 
445 448
         $newobject->country_id=$thirdparty['country_id'];
446
-        if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3);
449
+        if ($thirdparty['country_code']) {
450
+        	$newobject->country_id=getCountry($thirdparty['country_code'],3);
451
+        }
447 452
         $newobject->province_id=$thirdparty['province_id'];
448 453
         //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
449 454
 
@@ -495,12 +500,12 @@  discard block
 block discarded – undo
495 500
             $db->commit();
496 501
 
497 502
             // Patch to add capability to associate (one) sale representative
498
-            if($thirdparty['commid'] && $thirdparty['commid']>0)
499
-                $newobject->add_commercial($fuser, $thirdparty["commid"]);
503
+            if($thirdparty['commid'] && $thirdparty['commid']>0) {
504
+                            $newobject->add_commercial($fuser, $thirdparty["commid"]);
505
+            }
500 506
 
501 507
             $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
502
-        }
503
-        else
508
+        } else
504 509
         {
505 510
             $db->rollback();
506 511
             $error++;
@@ -532,7 +537,9 @@  discard block
 block discarded – undo
532 537
 
533 538
 	dol_syslog("Function: updateThirdParty login=".$authentication['login']);
534 539
 
535
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
540
+	if ($authentication['entity']) {
541
+		$conf->entity=$authentication['entity'];
542
+	}
536 543
 
537 544
 	// Init and check authentication
538 545
 	$objectresp=array();
@@ -575,7 +582,9 @@  discard block
 block discarded – undo
575 582
 			$object->town=$thirdparty['town'];
576 583
 
577 584
 			$object->country_id=$thirdparty['country_id'];
578
-			if ($thirdparty['country_code']) $object->country_id=getCountry($thirdparty['country_code'],3);
585
+			if ($thirdparty['country_code']) {
586
+				$object->country_id=getCountry($thirdparty['country_code'],3);
587
+			}
579 588
 			$object->province_id=$thirdparty['province_id'];
580 589
 			//if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
581 590
 
@@ -623,8 +632,7 @@  discard block
 block discarded – undo
623 632
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
624 633
 					'id'=>$object->id
625 634
 			);
626
-		}
627
-		elseif ($objectfound)
635
+		} elseif ($objectfound)
628 636
 		{
629 637
 			$db->rollback();
630 638
 			$error++;
@@ -662,7 +670,9 @@  discard block
 block discarded – undo
662 670
 
663 671
     dol_syslog("Function: getListOfThirdParties login=".$authentication['login']);
664 672
 
665
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
673
+    if ($authentication['entity']) {
674
+    	$conf->entity=$authentication['entity'];
675
+    }
666 676
 
667 677
     // Init and check authentication
668 678
     $objectresp=array();
@@ -683,10 +693,18 @@  discard block
 block discarded – undo
683 693
         $sql.=" WHERE entity=".$conf->entity;
684 694
         foreach($filterthirdparty as $key => $val)
685 695
         {
686
-            if ($key == 'name'     && $val != '')  $sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
687
-        	if ($key == 'client'   && (int) $val > 0)  $sql.=" AND s.client = ".$db->escape($val);
688
-            if ($key == 'supplier' && (int) $val > 0)  $sql.=" AND s.fournisseur = ".$db->escape($val);
689
-            if ($key == 'category' && (int) $val > 0)  $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
696
+            if ($key == 'name'     && $val != '') {
697
+            	$sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
698
+            }
699
+        	if ($key == 'client'   && (int) $val > 0) {
700
+        		$sql.=" AND s.client = ".$db->escape($val);
701
+        	}
702
+            if ($key == 'supplier' && (int) $val > 0) {
703
+            	$sql.=" AND s.fournisseur = ".$db->escape($val);
704
+            }
705
+            if ($key == 'category' && (int) $val > 0) {
706
+            	$sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
707
+            }
690 708
         }
691 709
         dol_syslog("Function: getListOfThirdParties", LOG_DEBUG);
692 710
 
@@ -723,8 +741,7 @@  discard block
 block discarded – undo
723 741
 
724 742
                 $i++;
725 743
             }
726
-        }
727
-        else
744
+        } else
728 745
         {
729 746
             $error++;
730 747
             $errorcode=$db->lasterrno();
@@ -738,8 +755,7 @@  discard block
 block discarded – undo
738 755
             'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
739 756
             'thirdparties'=>$arraythirdparties
740 757
         );
741
-    }
742
-    else
758
+    } else
743 759
     {
744 760
         $objectresp = array(
745 761
             'result'=>array('result_code' => 'OK', 'result_label' => ''),
@@ -765,7 +781,9 @@  discard block
 block discarded – undo
765 781
 
766 782
 	dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
767 783
 
768
-	if ($authentication['entity']) $conf->entity=$authentication['entity'];
784
+	if ($authentication['entity']) {
785
+		$conf->entity=$authentication['entity'];
786
+	}
769 787
 
770 788
 	// Init and check authentication
771 789
 	$objectresp=array();
@@ -801,8 +819,7 @@  discard block
 block discarded – undo
801 819
 					$db->commit();
802 820
 						
803 821
 					$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''));
804
-				}
805
-				else
822
+				} else
806 823
 				{						
807 824
 					$db->rollback();
808 825
 					$error++;
@@ -810,15 +827,13 @@  discard block
 block discarded – undo
810 827
 					$errorlabel=$thirdparty->error;
811 828
 					dol_syslog("Function: deleteThirdParty cant delete");
812 829
 				}
813
-			}
814
-			else
830
+			} else
815 831
 			{
816 832
 				$error++;
817 833
 				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
818 834
 				
819 835
 			}
820
-		}
821
-		else
836
+		} else
822 837
 		{
823 838
 			$error++;
824 839
 			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
Please login to merge, or discard this patch.
htdocs/webservices/server_project.php 3 patches
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -39,29 +39,29 @@  discard block
 block discarded – undo
39 39
 // Enable and test if module web services is enabled
40 40
 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
41 41
 {
42
-    $langs->load("admin");
43
-    dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
-    print $langs->trans("ToActivateModule");
46
-    exit;
42
+	$langs->load("admin");
43
+	dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
+	print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
45
+	print $langs->trans("ToActivateModule");
46
+	exit;
47 47
 }
48 48
 
49 49
 // Create associated types array, with each table
50 50
 $listofreferent=array(
51
-    'propal' => 'propal',
52
-    'order' => 'commande',
53
-    'invoice' => 'facture',
54
-    'invoice_predefined' => 'facture_rec',
55
-    'proposal_supplier' => 'commande_fournisseur',
56
-    'order_supplier' => 'commande_fournisseur',
57
-    'invoice_supplier' => 'facture_fourn',
58
-    'contract' => 'contrat',
59
-    'intervention' => 'fichinter',
60
-    'trip' => 'deplacement',
61
-    'expensereport' => 'expensereport_det',
62
-    'donation' => 'don',
63
-    'agenda' => 'actioncomm',
64
-    'project_task' => 'projet_task',
51
+	'propal' => 'propal',
52
+	'order' => 'commande',
53
+	'invoice' => 'facture',
54
+	'invoice_predefined' => 'facture_rec',
55
+	'proposal_supplier' => 'commande_fournisseur',
56
+	'order_supplier' => 'commande_fournisseur',
57
+	'invoice_supplier' => 'facture_fourn',
58
+	'contract' => 'contrat',
59
+	'intervention' => 'fichinter',
60
+	'trip' => 'deplacement',
61
+	'expensereport' => 'expensereport_det',
62
+	'donation' => 'don',
63
+	'agenda' => 'actioncomm',
64
+	'project_task' => 'projet_task',
65 65
 );
66 66
 
67 67
 // Create the soap Object
@@ -74,89 +74,89 @@  discard block
 block discarded – undo
74 74
 
75 75
 // Define WSDL Authentication object
76 76
 $server->wsdl->addComplexType(
77
-    'authentication',
78
-    'complexType',
79
-    'struct',
80
-    'all',
81
-    '',
82
-    array(
83
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
84
-        'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
85
-        'login' => array('name'=>'login','type'=>'xsd:string'),
86
-        'password' => array('name'=>'password','type'=>'xsd:string'),
87
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
88
-    )
77
+	'authentication',
78
+	'complexType',
79
+	'struct',
80
+	'all',
81
+	'',
82
+	array(
83
+		'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
84
+		'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
85
+		'login' => array('name'=>'login','type'=>'xsd:string'),
86
+		'password' => array('name'=>'password','type'=>'xsd:string'),
87
+		'entity' => array('name'=>'entity','type'=>'xsd:string'),
88
+	)
89 89
 );
90 90
 
91 91
 // Define WSDL Return object
92 92
 $server->wsdl->addComplexType(
93
-    'result',
94
-    'complexType',
95
-    'struct',
96
-    'all',
97
-    '',
98
-    array(
99
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
100
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
101
-    )
93
+	'result',
94
+	'complexType',
95
+	'struct',
96
+	'all',
97
+	'',
98
+	array(
99
+		'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
100
+		'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
101
+	)
102 102
 );
103 103
 
104 104
 // Define other specific objects
105 105
 $server->wsdl->addComplexType(
106
-    'element',
107
-    'complexType',
108
-    'struct',
109
-    'all',
110
-    '',
111
-    array(
112
-        'id' => array('name'=>'id','type'=>'xsd:int'),
113
-        'user' => array('name'=>'user','type'=>'xsd:int'),
114
-    )
106
+	'element',
107
+	'complexType',
108
+	'struct',
109
+	'all',
110
+	'',
111
+	array(
112
+		'id' => array('name'=>'id','type'=>'xsd:int'),
113
+		'user' => array('name'=>'user','type'=>'xsd:int'),
114
+	)
115 115
 );
116 116
 
117 117
 $server->wsdl->addComplexType(
118
-    'elementsArray',
119
-    'complexType',
120
-    'array',
121
-    'sequence',
122
-    '',
123
-    array(
124
-        'elements' => array(
125
-            'name' => 'elementsArray',
126
-            'type' => 'tns:element',
127
-            'minOccurs' => '0',
128
-            'maxOccurs' => 'unbounded'
129
-        )
130
-    )
118
+	'elementsArray',
119
+	'complexType',
120
+	'array',
121
+	'sequence',
122
+	'',
123
+	array(
124
+		'elements' => array(
125
+			'name' => 'elementsArray',
126
+			'type' => 'tns:element',
127
+			'minOccurs' => '0',
128
+			'maxOccurs' => 'unbounded'
129
+		)
130
+	)
131 131
 );
132 132
 
133 133
 $project_elements = array();
134 134
 foreach($listofreferent as $key => $_)
135 135
 {
136
-    $project_elements[$key] = array('name'=>$key,'type'=>'tns:elementsArray');
136
+	$project_elements[$key] = array('name'=>$key,'type'=>'tns:elementsArray');
137 137
 }
138 138
 $server->wsdl->addComplexType(
139
-    'elements',
140
-    'complexType',
141
-    'struct',
142
-    'all',
143
-    '',
144
-    $project_elements
139
+	'elements',
140
+	'complexType',
141
+	'struct',
142
+	'all',
143
+	'',
144
+	$project_elements
145 145
 );
146 146
 
147 147
 // Define project
148 148
 $project_fields = array(
149
-    'id' => array('name'=>'id','type'=>'xsd:string'),
150
-    'ref' => array('name'=>'ref','type'=>'xsd:string'),
151
-    'label' => array('name'=>'label','type'=>'xsd:string'),
152
-    'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
153
-    'public' => array('name'=>'public','type'=>'xsd:int'),
154
-    'status' => array('name'=>'status','type'=>'xsd:int'),
155
-    'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
156
-    'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
157
-    'budget' => array('name'=>'budget','type'=>'xsd:int'),
158
-    'description' => array('name'=>'description','type'=>'xsd:string'),
159
-    'elements' => array('name'=>'elements','type'=>'tns:elements')
149
+	'id' => array('name'=>'id','type'=>'xsd:string'),
150
+	'ref' => array('name'=>'ref','type'=>'xsd:string'),
151
+	'label' => array('name'=>'label','type'=>'xsd:string'),
152
+	'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
153
+	'public' => array('name'=>'public','type'=>'xsd:int'),
154
+	'status' => array('name'=>'status','type'=>'xsd:int'),
155
+	'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
156
+	'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
157
+	'budget' => array('name'=>'budget','type'=>'xsd:int'),
158
+	'description' => array('name'=>'description','type'=>'xsd:string'),
159
+	'elements' => array('name'=>'elements','type'=>'tns:elements')
160 160
 );
161 161
 
162 162
 //Retreive all extrafield for thirdsparty
@@ -164,25 +164,25 @@  discard block
 block discarded – undo
164 164
 $extrafields=new ExtraFields($db);
165 165
 $extralabels=$extrafields->fetch_name_optionals_label('project',true);
166 166
 if (count($extrafields)>0) {
167
-    $extrafield_array = array();
167
+	$extrafield_array = array();
168 168
 }
169 169
 foreach($extrafields->attribute_label as $key=>$label)
170 170
 {
171
-    //$value=$object->array_options["options_".$key];
172
-    $type =$extrafields->attribute_type[$key];
173
-    if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
174
-    else {$type='xsd:string';}
175
-    $extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
171
+	//$value=$object->array_options["options_".$key];
172
+	$type =$extrafields->attribute_type[$key];
173
+	if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
174
+	else {$type='xsd:string';}
175
+	$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
176 176
 }
177 177
 $project_fields=array_merge($project_fields,$extrafield_array);
178 178
 
179 179
 $server->wsdl->addComplexType(
180
-    'project',
181
-    'complexType',
182
-    'struct',
183
-    'all',
184
-    '',
185
-    $project_fields
180
+	'project',
181
+	'complexType',
182
+	'struct',
183
+	'all',
184
+	'',
185
+	$project_fields
186 186
 );
187 187
 
188 188
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 
195 195
 // Register WSDL
196 196
 $server->register(
197
-    'createProject',
198
-    // Entry values
199
-    array('authentication'=>'tns:authentication','project'=>'tns:project'),
200
-    // Exit values
201
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
202
-    $ns,
203
-    $ns.'#createProject',
204
-    $styledoc,
205
-    $styleuse,
206
-    'WS to create project'
197
+	'createProject',
198
+	// Entry values
199
+	array('authentication'=>'tns:authentication','project'=>'tns:project'),
200
+	// Exit values
201
+	array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
202
+	$ns,
203
+	$ns.'#createProject',
204
+	$styledoc,
205
+	$styleuse,
206
+	'WS to create project'
207 207
 );
208 208
 
209 209
 // Register WSDL
210 210
 $server->register(
211
-    'getProject',
212
-    // Entry values
213
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string'),
214
-    // Exit values
215
-    array('result'=>'tns:result','project'=>'tns:project'),
216
-    $ns,
217
-    $ns.'#getProject',
218
-    $styledoc,
219
-    $styleuse,
220
-    'WS to get project'
211
+	'getProject',
212
+	// Entry values
213
+	array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string'),
214
+	// Exit values
215
+	array('result'=>'tns:result','project'=>'tns:project'),
216
+	$ns,
217
+	$ns.'#getProject',
218
+	$styledoc,
219
+	$styleuse,
220
+	'WS to get project'
221 221
 );
222 222
 
223 223
 // Full methods code
@@ -230,94 +230,94 @@  discard block
 block discarded – undo
230 230
  */
231 231
 function createProject($authentication, $project)
232 232
 {
233
-    global $db,$conf;
234
-
235
-    dol_syslog("Function: createProject login=".$authentication['login']);
236
-
237
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
238
-
239
-    // Init and check authentication
240
-    $objectresp=array();
241
-    $errorcode='';$errorlabel='';
242
-    $error=0;
243
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
244
-    // Check parameters
245
-    if (empty($project['ref']))
246
-    {
247
-        $error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
248
-    }
249
-
250
-
251
-    if (! $error)
252
-    {
253
-        $fuser->getrights();
254
-
255
-        if ($fuser->rights->projet->creer)
256
-        {
257
-            $newobject=new Project($db);
258
-            $newobject->ref=$project['ref'];
259
-            $newobject->title=$project['label'];
260
-            $newobject->socid=$project['thirdparty_id'];
261
-            $newobject->public=$project['public'];
262
-            $newobject->statut=$project['status'];
263
-            $newobject->date_start=dol_stringtotime($project['date_start'],'dayrfc');
264
-            $newobject->date_end=dol_stringtotime($project['date_end'],'dayrfc');
265
-            $newobject->budget_amount=$project['budget'];
266
-            $newobject->description=$project['description'];
267
-
268
-            // Retrieve all extrafields for project
269
-            // fetch optionals attributes and labels
270
-            $extrafields=new ExtraFields($db);
271
-            $extralabels=$extrafields->fetch_name_optionals_label('project',true);
272
-            foreach($extrafields->attribute_label as $key=>$label)
273
-            {
274
-                $key='options_'.$key;
275
-                $newobject->array_options[$key]=$project[$key];
276
-            }
277
-
278
-            $db->begin();
279
-
280
-            $result = $newobject->create($fuser);
281
-            if (! $error && $result > 0)
282
-            {
283
-                // Add myself as project leader
284
-                $result = $newobject->add_contact($fuser->id, 'PROJECTLEADER', 'internal');
285
-                if ($result < 0)
286
-                {
287
-                    $error++;
288
-                }
289
-            }
290
-            else
291
-            {
292
-                $error++;
293
-            }
294
-
295
-            if (! $error)
296
-            {
297
-                $db->commit();
298
-                $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
299
-            }
300
-            else
301
-            {
302
-                $db->rollback();
303
-                $error++;
304
-                $errorcode='KO';
305
-                $errorlabel=$newobject->error;
306
-            }
307
-        }
308
-        else
309
-        {
310
-            $error++;
311
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
312
-        }
313
-    }
314
-
315
-    if ($error)
316
-    {
317
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
318
-    }
319
-
320
-    return $objectresp;
233
+	global $db,$conf;
234
+
235
+	dol_syslog("Function: createProject login=".$authentication['login']);
236
+
237
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
238
+
239
+	// Init and check authentication
240
+	$objectresp=array();
241
+	$errorcode='';$errorlabel='';
242
+	$error=0;
243
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
244
+	// Check parameters
245
+	if (empty($project['ref']))
246
+	{
247
+		$error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
248
+	}
249
+
250
+
251
+	if (! $error)
252
+	{
253
+		$fuser->getrights();
254
+
255
+		if ($fuser->rights->projet->creer)
256
+		{
257
+			$newobject=new Project($db);
258
+			$newobject->ref=$project['ref'];
259
+			$newobject->title=$project['label'];
260
+			$newobject->socid=$project['thirdparty_id'];
261
+			$newobject->public=$project['public'];
262
+			$newobject->statut=$project['status'];
263
+			$newobject->date_start=dol_stringtotime($project['date_start'],'dayrfc');
264
+			$newobject->date_end=dol_stringtotime($project['date_end'],'dayrfc');
265
+			$newobject->budget_amount=$project['budget'];
266
+			$newobject->description=$project['description'];
267
+
268
+			// Retrieve all extrafields for project
269
+			// fetch optionals attributes and labels
270
+			$extrafields=new ExtraFields($db);
271
+			$extralabels=$extrafields->fetch_name_optionals_label('project',true);
272
+			foreach($extrafields->attribute_label as $key=>$label)
273
+			{
274
+				$key='options_'.$key;
275
+				$newobject->array_options[$key]=$project[$key];
276
+			}
277
+
278
+			$db->begin();
279
+
280
+			$result = $newobject->create($fuser);
281
+			if (! $error && $result > 0)
282
+			{
283
+				// Add myself as project leader
284
+				$result = $newobject->add_contact($fuser->id, 'PROJECTLEADER', 'internal');
285
+				if ($result < 0)
286
+				{
287
+					$error++;
288
+				}
289
+			}
290
+			else
291
+			{
292
+				$error++;
293
+			}
294
+
295
+			if (! $error)
296
+			{
297
+				$db->commit();
298
+				$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
299
+			}
300
+			else
301
+			{
302
+				$db->rollback();
303
+				$error++;
304
+				$errorcode='KO';
305
+				$errorlabel=$newobject->error;
306
+			}
307
+		}
308
+		else
309
+		{
310
+			$error++;
311
+			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
312
+		}
313
+	}
314
+
315
+	if ($error)
316
+	{
317
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
318
+	}
319
+
320
+	return $objectresp;
321 321
 }
322 322
 
323 323
 /**
@@ -330,103 +330,103 @@  discard block
 block discarded – undo
330 330
  */
331 331
 function getProject($authentication,$id='',$ref='')
332 332
 {
333
-    global $db,$conf,$langs;
334
-
335
-    dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
336
-
337
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
338
-
339
-    // Init and check authentication
340
-    $objectresp=array();
341
-    $errorcode='';$errorlabel='';
342
-    $error=0;
343
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
344
-    // Check parameters
345
-    if (! $error && (($id && $ref)))
346
-    {
347
-        $error++;
348
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref can't be both provided. You must choose one or other but not both.";
349
-    }
350
-
351
-    if (! $error)
352
-    {
353
-        $fuser->getrights();
354
-
355
-        if ($fuser->rights->projet->lire)
356
-        {
357
-            $project=new Project($db);
358
-            $result=$project->fetch($id,$ref);
359
-            if ($result > 0)
360
-            {
361
-                $project_result_fields=array(
362
-                    'id' => $project->id,
363
-                    'ref' => $project->ref,
364
-                    'label' => $project->title,
365
-                    'thirdparty_id' => $project->socid,
366
-                    'public' => $project->public,
367
-                    'status' => $project->statut,
368
-                    'date_start' => $project->date_start ? dol_print_date($project->date_start, 'dayrfc') : '',
369
-                    'date_end' => $project->date_end ? dol_print_date($project->date_end, 'dayrfc') : '',
370
-                    'budget' => $project->budget_amount,
371
-                    'description' => $project->description,
372
-                );
373
-
374
-                //Retrieve all extrafields for project
375
-                $extrafields=new ExtraFields($db);
376
-                $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
377
-
378
-                //Get extrafield values
379
-                $project->fetch_optionals($project->id,$extralabels);
380
-                foreach($extrafields->attribute_label as $key=>$label)
381
-                {
382
-                    $project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key]));
383
-                }
384
-
385
-                //Get linked elements
386
-                global $listofreferent;
387
-                $elements = array();
388
-                foreach ($listofreferent as $key => $tablename)
389
-                {
390
-                    $elements[$key] = array();
391
-                    $element_array = $project->get_element_list($key, $tablename);
392
-                    if (count($element_array) > 0 && is_array($element_array))
393
-                    {
394
-                        foreach ($element_array as $element)
395
-                        {
396
-                            $tmp = explode('_', $element);
397
-                            $idofelement = count($tmp) > 0? $tmp[0] : "";
398
-                            $idofelementuser = count($tmp) > 1? $tmp[1] : "";
399
-                            $elements[$key][] = array('id' => $idofelement, 'user' => $idofelementuser);
400
-                        }
401
-                    }
402
-                }
403
-                $project_result_fields['elements'] = $elements;
404
-
405
-                //Result
406
-                $objectresp = array(
407
-                    'result'=>array('result_code'=>'OK', 'result_label'=>''),
408
-                    'project'=>$project_result_fields
409
-                );
410
-            }
411
-            else
412
-            {
413
-                $error++;
414
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref;
415
-            }
416
-        }
417
-        else
418
-        {
419
-            $error++;
420
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
421
-        }
422
-    }
423
-
424
-    if ($error)
425
-    {
426
-        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
427
-    }
428
-
429
-    return $objectresp;
333
+	global $db,$conf,$langs;
334
+
335
+	dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
336
+
337
+	if ($authentication['entity']) $conf->entity=$authentication['entity'];
338
+
339
+	// Init and check authentication
340
+	$objectresp=array();
341
+	$errorcode='';$errorlabel='';
342
+	$error=0;
343
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
344
+	// Check parameters
345
+	if (! $error && (($id && $ref)))
346
+	{
347
+		$error++;
348
+		$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref can't be both provided. You must choose one or other but not both.";
349
+	}
350
+
351
+	if (! $error)
352
+	{
353
+		$fuser->getrights();
354
+
355
+		if ($fuser->rights->projet->lire)
356
+		{
357
+			$project=new Project($db);
358
+			$result=$project->fetch($id,$ref);
359
+			if ($result > 0)
360
+			{
361
+				$project_result_fields=array(
362
+					'id' => $project->id,
363
+					'ref' => $project->ref,
364
+					'label' => $project->title,
365
+					'thirdparty_id' => $project->socid,
366
+					'public' => $project->public,
367
+					'status' => $project->statut,
368
+					'date_start' => $project->date_start ? dol_print_date($project->date_start, 'dayrfc') : '',
369
+					'date_end' => $project->date_end ? dol_print_date($project->date_end, 'dayrfc') : '',
370
+					'budget' => $project->budget_amount,
371
+					'description' => $project->description,
372
+				);
373
+
374
+				//Retrieve all extrafields for project
375
+				$extrafields=new ExtraFields($db);
376
+				$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
377
+
378
+				//Get extrafield values
379
+				$project->fetch_optionals($project->id,$extralabels);
380
+				foreach($extrafields->attribute_label as $key=>$label)
381
+				{
382
+					$project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key]));
383
+				}
384
+
385
+				//Get linked elements
386
+				global $listofreferent;
387
+				$elements = array();
388
+				foreach ($listofreferent as $key => $tablename)
389
+				{
390
+					$elements[$key] = array();
391
+					$element_array = $project->get_element_list($key, $tablename);
392
+					if (count($element_array) > 0 && is_array($element_array))
393
+					{
394
+						foreach ($element_array as $element)
395
+						{
396
+							$tmp = explode('_', $element);
397
+							$idofelement = count($tmp) > 0? $tmp[0] : "";
398
+							$idofelementuser = count($tmp) > 1? $tmp[1] : "";
399
+							$elements[$key][] = array('id' => $idofelement, 'user' => $idofelementuser);
400
+						}
401
+					}
402
+				}
403
+				$project_result_fields['elements'] = $elements;
404
+
405
+				//Result
406
+				$objectresp = array(
407
+					'result'=>array('result_code'=>'OK', 'result_label'=>''),
408
+					'project'=>$project_result_fields
409
+				);
410
+			}
411
+			else
412
+			{
413
+				$error++;
414
+				$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref;
415
+			}
416
+		}
417
+		else
418
+		{
419
+			$error++;
420
+			$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
421
+		}
422
+	}
423
+
424
+	if ($error)
425
+	{
426
+		$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
427
+	}
428
+
429
+	return $objectresp;
430 430
 }
431 431
 
432 432
 // Return the results.
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (!defined("NOCSRFCHECK"))    define("NOCSRFCHECK", '1');
25 25
 
26 26
 require_once '../master.inc.php';
27
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
27
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
28 28
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
29 29
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30 30
 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 {
42 42
     $langs->load("admin");
43 43
     dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
44
-    print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
44
+    print $langs->trans("WarningModuleNotActive", 'WebServices').'.<br><br>';
45 45
     print $langs->trans("ToActivateModule");
46 46
     exit;
47 47
 }
48 48
 
49 49
 // Create associated types array, with each table
50
-$listofreferent=array(
50
+$listofreferent = array(
51 51
     'propal' => 'propal',
52 52
     'order' => 'commande',
53 53
     'invoice' => 'facture',
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 
67 67
 // Create the soap Object
68 68
 $server = new nusoap_server();
69
-$server->soap_defencoding='UTF-8';
70
-$server->decode_utf8=false;
71
-$ns='http://www.dolibarr.org/ns/';
72
-$server->configureWSDL('WebServicesDolibarrOther',$ns);
73
-$server->wsdl->schemaTargetNamespace=$ns;
69
+$server->soap_defencoding = 'UTF-8';
70
+$server->decode_utf8 = false;
71
+$ns = 'http://www.dolibarr.org/ns/';
72
+$server->configureWSDL('WebServicesDolibarrOther', $ns);
73
+$server->wsdl->schemaTargetNamespace = $ns;
74 74
 
75 75
 // Define WSDL Authentication object
76 76
 $server->wsdl->addComplexType(
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
     'all',
81 81
     '',
82 82
     array(
83
-        'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
84
-        'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
85
-        'login' => array('name'=>'login','type'=>'xsd:string'),
86
-        'password' => array('name'=>'password','type'=>'xsd:string'),
87
-        'entity' => array('name'=>'entity','type'=>'xsd:string'),
83
+        'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
84
+        'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
85
+        'login' => array('name'=>'login', 'type'=>'xsd:string'),
86
+        'password' => array('name'=>'password', 'type'=>'xsd:string'),
87
+        'entity' => array('name'=>'entity', 'type'=>'xsd:string'),
88 88
     )
89 89
 );
90 90
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
     'all',
97 97
     '',
98 98
     array(
99
-        'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
100
-        'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
99
+        'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
100
+        'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
101 101
     )
102 102
 );
103 103
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
     'all',
110 110
     '',
111 111
     array(
112
-        'id' => array('name'=>'id','type'=>'xsd:int'),
113
-        'user' => array('name'=>'user','type'=>'xsd:int'),
112
+        'id' => array('name'=>'id', 'type'=>'xsd:int'),
113
+        'user' => array('name'=>'user', 'type'=>'xsd:int'),
114 114
     )
115 115
 );
116 116
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 );
132 132
 
133 133
 $project_elements = array();
134
-foreach($listofreferent as $key => $_)
134
+foreach ($listofreferent as $key => $_)
135 135
 {
136
-    $project_elements[$key] = array('name'=>$key,'type'=>'tns:elementsArray');
136
+    $project_elements[$key] = array('name'=>$key, 'type'=>'tns:elementsArray');
137 137
 }
138 138
 $server->wsdl->addComplexType(
139 139
     'elements',
@@ -146,35 +146,35 @@  discard block
 block discarded – undo
146 146
 
147 147
 // Define project
148 148
 $project_fields = array(
149
-    'id' => array('name'=>'id','type'=>'xsd:string'),
150
-    'ref' => array('name'=>'ref','type'=>'xsd:string'),
151
-    'label' => array('name'=>'label','type'=>'xsd:string'),
152
-    'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
153
-    'public' => array('name'=>'public','type'=>'xsd:int'),
154
-    'status' => array('name'=>'status','type'=>'xsd:int'),
155
-    'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
156
-    'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
157
-    'budget' => array('name'=>'budget','type'=>'xsd:int'),
158
-    'description' => array('name'=>'description','type'=>'xsd:string'),
159
-    'elements' => array('name'=>'elements','type'=>'tns:elements')
149
+    'id' => array('name'=>'id', 'type'=>'xsd:string'),
150
+    'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
151
+    'label' => array('name'=>'label', 'type'=>'xsd:string'),
152
+    'thirdparty_id' => array('name'=>'thirdparty_id', 'type'=>'xsd:int'),
153
+    'public' => array('name'=>'public', 'type'=>'xsd:int'),
154
+    'status' => array('name'=>'status', 'type'=>'xsd:int'),
155
+    'date_start' => array('name'=>'date_start', 'type'=>'xsd:date'),
156
+    'date_end' => array('name'=>'date_end', 'type'=>'xsd:date'),
157
+    'budget' => array('name'=>'budget', 'type'=>'xsd:int'),
158
+    'description' => array('name'=>'description', 'type'=>'xsd:string'),
159
+    'elements' => array('name'=>'elements', 'type'=>'tns:elements')
160 160
 );
161 161
 
162 162
 //Retreive all extrafield for thirdsparty
163 163
 // fetch optionals attributes and labels
164
-$extrafields=new ExtraFields($db);
165
-$extralabels=$extrafields->fetch_name_optionals_label('project',true);
166
-if (count($extrafields)>0) {
164
+$extrafields = new ExtraFields($db);
165
+$extralabels = $extrafields->fetch_name_optionals_label('project', true);
166
+if (count($extrafields) > 0) {
167 167
     $extrafield_array = array();
168 168
 }
169
-foreach($extrafields->attribute_label as $key=>$label)
169
+foreach ($extrafields->attribute_label as $key=>$label)
170 170
 {
171 171
     //$value=$object->array_options["options_".$key];
172
-    $type =$extrafields->attribute_type[$key];
173
-    if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
174
-    else {$type='xsd:string';}
175
-    $extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
172
+    $type = $extrafields->attribute_type[$key];
173
+    if ($type == 'date' || $type == 'datetime') {$type = 'xsd:dateTime'; }
174
+    else {$type = 'xsd:string'; }
175
+    $extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
176 176
 }
177
-$project_fields=array_merge($project_fields,$extrafield_array);
177
+$project_fields = array_merge($project_fields, $extrafield_array);
178 178
 
179 179
 $server->wsdl->addComplexType(
180 180
     'project',
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
189 189
 // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
190 190
 // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
191
-$styledoc='rpc';       // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
192
-$styleuse='encoded';   // encoded/literal/literal wrapped
191
+$styledoc = 'rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
192
+$styleuse = 'encoded'; // encoded/literal/literal wrapped
193 193
 // Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
194 194
 
195 195
 // Register WSDL
196 196
 $server->register(
197 197
     'createProject',
198 198
     // Entry values
199
-    array('authentication'=>'tns:authentication','project'=>'tns:project'),
199
+    array('authentication'=>'tns:authentication', 'project'=>'tns:project'),
200 200
     // Exit values
201
-    array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
201
+    array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'),
202 202
     $ns,
203 203
     $ns.'#createProject',
204 204
     $styledoc,
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 $server->register(
211 211
     'getProject',
212 212
     // Entry values
213
-    array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string'),
213
+    array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string'),
214 214
     // Exit values
215
-    array('result'=>'tns:result','project'=>'tns:project'),
215
+    array('result'=>'tns:result', 'project'=>'tns:project'),
216 216
     $ns,
217 217
     $ns.'#getProject',
218 218
     $styledoc,
@@ -230,55 +230,55 @@  discard block
 block discarded – undo
230 230
  */
231 231
 function createProject($authentication, $project)
232 232
 {
233
-    global $db,$conf;
233
+    global $db, $conf;
234 234
 
235 235
     dol_syslog("Function: createProject login=".$authentication['login']);
236 236
 
237
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
237
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
238 238
 
239 239
     // Init and check authentication
240
-    $objectresp=array();
241
-    $errorcode='';$errorlabel='';
242
-    $error=0;
243
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
240
+    $objectresp = array();
241
+    $errorcode = ''; $errorlabel = '';
242
+    $error = 0;
243
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
244 244
     // Check parameters
245 245
     if (empty($project['ref']))
246 246
     {
247
-        $error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
247
+        $error++; $errorcode = 'KO'; $errorlabel = "Name is mandatory.";
248 248
     }
249 249
 
250 250
 
251
-    if (! $error)
251
+    if (!$error)
252 252
     {
253 253
         $fuser->getrights();
254 254
 
255 255
         if ($fuser->rights->projet->creer)
256 256
         {
257
-            $newobject=new Project($db);
258
-            $newobject->ref=$project['ref'];
259
-            $newobject->title=$project['label'];
260
-            $newobject->socid=$project['thirdparty_id'];
261
-            $newobject->public=$project['public'];
262
-            $newobject->statut=$project['status'];
263
-            $newobject->date_start=dol_stringtotime($project['date_start'],'dayrfc');
264
-            $newobject->date_end=dol_stringtotime($project['date_end'],'dayrfc');
265
-            $newobject->budget_amount=$project['budget'];
266
-            $newobject->description=$project['description'];
257
+            $newobject = new Project($db);
258
+            $newobject->ref = $project['ref'];
259
+            $newobject->title = $project['label'];
260
+            $newobject->socid = $project['thirdparty_id'];
261
+            $newobject->public = $project['public'];
262
+            $newobject->statut = $project['status'];
263
+            $newobject->date_start = dol_stringtotime($project['date_start'], 'dayrfc');
264
+            $newobject->date_end = dol_stringtotime($project['date_end'], 'dayrfc');
265
+            $newobject->budget_amount = $project['budget'];
266
+            $newobject->description = $project['description'];
267 267
 
268 268
             // Retrieve all extrafields for project
269 269
             // fetch optionals attributes and labels
270
-            $extrafields=new ExtraFields($db);
271
-            $extralabels=$extrafields->fetch_name_optionals_label('project',true);
272
-            foreach($extrafields->attribute_label as $key=>$label)
270
+            $extrafields = new ExtraFields($db);
271
+            $extralabels = $extrafields->fetch_name_optionals_label('project', true);
272
+            foreach ($extrafields->attribute_label as $key=>$label)
273 273
             {
274
-                $key='options_'.$key;
275
-                $newobject->array_options[$key]=$project[$key];
274
+                $key = 'options_'.$key;
275
+                $newobject->array_options[$key] = $project[$key];
276 276
             }
277 277
 
278 278
             $db->begin();
279 279
 
280 280
             $result = $newobject->create($fuser);
281
-            if (! $error && $result > 0)
281
+            if (!$error && $result > 0)
282 282
             {
283 283
                 // Add myself as project leader
284 284
                 $result = $newobject->add_contact($fuser->id, 'PROJECTLEADER', 'internal');
@@ -292,23 +292,23 @@  discard block
 block discarded – undo
292 292
                 $error++;
293 293
             }
294 294
 
295
-            if (! $error)
295
+            if (!$error)
296 296
             {
297 297
                 $db->commit();
298
-                $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
298
+                $objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
299 299
             }
300 300
             else
301 301
             {
302 302
                 $db->rollback();
303 303
                 $error++;
304
-                $errorcode='KO';
305
-                $errorlabel=$newobject->error;
304
+                $errorcode = 'KO';
305
+                $errorlabel = $newobject->error;
306 306
             }
307 307
         }
308 308
         else
309 309
         {
310 310
             $error++;
311
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
311
+            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
312 312
         }
313 313
     }
314 314
 
@@ -328,37 +328,37 @@  discard block
 block discarded – undo
328 328
  * @param	string		$ref		    	internal reference
329 329
  * @return	array							Array result
330 330
  */
331
-function getProject($authentication,$id='',$ref='')
331
+function getProject($authentication, $id = '', $ref = '')
332 332
 {
333
-    global $db,$conf,$langs;
333
+    global $db, $conf, $langs;
334 334
 
335 335
     dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
336 336
 
337
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
337
+    if ($authentication['entity']) $conf->entity = $authentication['entity'];
338 338
 
339 339
     // Init and check authentication
340
-    $objectresp=array();
341
-    $errorcode='';$errorlabel='';
342
-    $error=0;
343
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
340
+    $objectresp = array();
341
+    $errorcode = ''; $errorlabel = '';
342
+    $error = 0;
343
+    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
344 344
     // Check parameters
345
-    if (! $error && (($id && $ref)))
345
+    if (!$error && (($id && $ref)))
346 346
     {
347 347
         $error++;
348
-        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref can't be both provided. You must choose one or other but not both.";
348
+        $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id and ref can't be both provided. You must choose one or other but not both.";
349 349
     }
350 350
 
351
-    if (! $error)
351
+    if (!$error)
352 352
     {
353 353
         $fuser->getrights();
354 354
 
355 355
         if ($fuser->rights->projet->lire)
356 356
         {
357
-            $project=new Project($db);
358
-            $result=$project->fetch($id,$ref);
357
+            $project = new Project($db);
358
+            $result = $project->fetch($id, $ref);
359 359
             if ($result > 0)
360 360
             {
361
-                $project_result_fields=array(
361
+                $project_result_fields = array(
362 362
                     'id' => $project->id,
363 363
                     'ref' => $project->ref,
364 364
                     'label' => $project->title,
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
                 );
373 373
 
374 374
                 //Retrieve all extrafields for project
375
-                $extrafields=new ExtraFields($db);
376
-                $extralabels=$extrafields->fetch_name_optionals_label('societe',true);
375
+                $extrafields = new ExtraFields($db);
376
+                $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
377 377
 
378 378
                 //Get extrafield values
379
-                $project->fetch_optionals($project->id,$extralabels);
380
-                foreach($extrafields->attribute_label as $key=>$label)
379
+                $project->fetch_optionals($project->id, $extralabels);
380
+                foreach ($extrafields->attribute_label as $key=>$label)
381 381
                 {
382
-                    $project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key]));
382
+                    $project_result_fields = array_merge($project_result_fields, array('options_'.$key => $project->array_options['options_'.$key]));
383 383
                 }
384 384
 
385 385
                 //Get linked elements
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
                         foreach ($element_array as $element)
395 395
                         {
396 396
                             $tmp = explode('_', $element);
397
-                            $idofelement = count($tmp) > 0? $tmp[0] : "";
398
-                            $idofelementuser = count($tmp) > 1? $tmp[1] : "";
397
+                            $idofelement = count($tmp) > 0 ? $tmp[0] : "";
398
+                            $idofelementuser = count($tmp) > 1 ? $tmp[1] : "";
399 399
                             $elements[$key][] = array('id' => $idofelement, 'user' => $idofelementuser);
400 400
                         }
401 401
                     }
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
             else
412 412
             {
413 413
                 $error++;
414
-                $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref;
414
+                $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref;
415 415
             }
416 416
         }
417 417
         else
418 418
         {
419 419
             $error++;
420
-            $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
420
+            $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
421 421
         }
422 422
     }
423 423
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
  *       \brief      File that is entry point to call Dolibarr WebServices
22 22
  */
23 23
 
24
-if (! defined("NOCSRFCHECK"))    define("NOCSRFCHECK",'1');
24
+if (! defined("NOCSRFCHECK")) {
25
+	define("NOCSRFCHECK",'1');
26
+}
25 27
 
26 28
 require_once '../master.inc.php';
27 29
 require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
@@ -170,8 +172,7 @@  discard block
 block discarded – undo
170 172
 {
171 173
     //$value=$object->array_options["options_".$key];
172 174
     $type =$extrafields->attribute_type[$key];
173
-    if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
174
-    else {$type='xsd:string';}
175
+    if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';} else {$type='xsd:string';}
175 176
     $extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
176 177
 }
177 178
 $project_fields=array_merge($project_fields,$extrafield_array);
@@ -234,7 +235,9 @@  discard block
 block discarded – undo
234 235
 
235 236
     dol_syslog("Function: createProject login=".$authentication['login']);
236 237
 
237
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
238
+    if ($authentication['entity']) {
239
+    	$conf->entity=$authentication['entity'];
240
+    }
238 241
 
239 242
     // Init and check authentication
240 243
     $objectresp=array();
@@ -286,8 +289,7 @@  discard block
 block discarded – undo
286 289
                 {
287 290
                     $error++;
288 291
                 }
289
-            }
290
-            else
292
+            } else
291 293
             {
292 294
                 $error++;
293 295
             }
@@ -296,16 +298,14 @@  discard block
 block discarded – undo
296 298
             {
297 299
                 $db->commit();
298 300
                 $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
299
-            }
300
-            else
301
+            } else
301 302
             {
302 303
                 $db->rollback();
303 304
                 $error++;
304 305
                 $errorcode='KO';
305 306
                 $errorlabel=$newobject->error;
306 307
             }
307
-        }
308
-        else
308
+        } else
309 309
         {
310 310
             $error++;
311 311
             $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
@@ -334,7 +334,9 @@  discard block
 block discarded – undo
334 334
 
335 335
     dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
336 336
 
337
-    if ($authentication['entity']) $conf->entity=$authentication['entity'];
337
+    if ($authentication['entity']) {
338
+    	$conf->entity=$authentication['entity'];
339
+    }
338 340
 
339 341
     // Init and check authentication
340 342
     $objectresp=array();
@@ -407,14 +409,12 @@  discard block
 block discarded – undo
407 409
                     'result'=>array('result_code'=>'OK', 'result_label'=>''),
408 410
                     'project'=>$project_result_fields
409 411
                 );
410
-            }
411
-            else
412
+            } else
412 413
             {
413 414
                 $error++;
414 415
                 $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref;
415 416
             }
416
-        }
417
-        else
417
+        } else
418 418
         {
419 419
             $error++;
420 420
             $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
Please login to merge, or discard this patch.