Completed
Branch develop (c604ce)
by
unknown
32:31
created
htdocs/webservices/server_payment.php 1 patch
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.
htdocs/webservices/server_thirdparty.php 1 patch
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.
htdocs/webservices/server_other.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -55,30 +55,30 @@  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 WSDL Return object for document
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 
110 110
 // Register WSDL
111 111
 $server->register(
112
-    'getVersions',
113
-    // Entry values
114
-    array('authentication'=>'tns:authentication'),
115
-    // Exit values
116
-    array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
117
-    $ns,
118
-    $ns.'#getVersions',
119
-    $styledoc,
120
-    $styleuse,
121
-    'WS to get Versions'
112
+	'getVersions',
113
+	// Entry values
114
+	array('authentication'=>'tns:authentication'),
115
+	// Exit values
116
+	array('result'=>'tns:result','dolibarr'=>'xsd:string','os'=>'xsd:string','php'=>'xsd:string','webserver'=>'xsd:string'),
117
+	$ns,
118
+	$ns.'#getVersions',
119
+	$styledoc,
120
+	$styleuse,
121
+	'WS to get Versions'
122 122
 );
123 123
 
124 124
 // Register WSDL
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 
147 147
 	if ($authentication['entity']) $conf->entity=$authentication['entity'];
148 148
 
149
-    // Init and check authentication
150
-    $objectresp=array();
151
-    $errorcode='';$errorlabel='';
152
-    $error=0;
153
-    $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
154
-    // Check parameters
149
+	// Init and check authentication
150
+	$objectresp=array();
151
+	$errorcode='';$errorlabel='';
152
+	$error=0;
153
+	$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
154
+	// Check parameters
155 155
 
156 156
 
157
-    if (! $error)
157
+	if (! $error)
158 158
 	{
159 159
 		$objectresp['result']=array('result_code'=>'OK', 'result_label'=>'');
160 160
 		$objectresp['dolibarr']=version_dolibarr();
Please login to merge, or discard this patch.
htdocs/webservices/server_category.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
  * Les catégories filles, sous tableau dez la catégorie
94 94
  */
95 95
  $server->wsdl->addComplexType(
96
-    'FillesArray',
97
-    'complexType',
98
-    'array',
99
-    '',
100
-    'SOAP-ENC:Array',
101
-    array(),
102
-    array(
103
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]')
104
-    ),
105
-    'tns:categorie'
96
+	'FillesArray',
97
+	'complexType',
98
+	'array',
99
+	'',
100
+	'SOAP-ENC:Array',
101
+	array(),
102
+	array(
103
+		array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]')
104
+	),
105
+	'tns:categorie'
106 106
 );
107 107
 
108 108
  /*
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	// Exit values
173 173
 	array('result'=>'tns:result','categorie'=>'tns:categorie'),
174 174
 	$ns,
175
-    $ns.'#getCategory',
176
-    $styledoc,
177
-    $styleuse,
178
-    'WS to get category'
175
+	$ns.'#getCategory',
176
+	$styledoc,
177
+	$styleuse,
178
+	'WS to get category'
179 179
 );
180 180
 
181 181
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 						'type' => $categorie->type,
230 230
 						'dir' => $pdir,
231 231
 						'photos' => $categorie->liste_photos($dir,$nbmax=10)
232
-			    	);
232
+					);
233 233
 
234 234
 					$cats = $categorie->get_filles();
235 235
 					if (count($cats) > 0)
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 
256 256
 					}
257 257
 
258
-			    // Create
259
-			    $objectresp = array(
258
+				// Create
259
+				$objectresp = array(
260 260
 					'result'=>array('result_code'=>'OK', 'result_label'=>''),
261 261
 					'categorie'=> $cat
262 262
 			   );
Please login to merge, or discard this patch.
htdocs/webservices/admin/index.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
 // Sauvegardes parametres
38 38
 if ($actionsave)
39 39
 {
40
-    $i=0;
41
-
42
-    $db->begin();
43
-
44
-    $i+=dolibarr_set_const($db,'WEBSERVICES_KEY',trim(GETPOST("WEBSERVICES_KEY")),'chaine',0,'',$conf->entity);
45
-
46
-    if ($i >= 1)
47
-    {
48
-        $db->commit();
49
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
-    }
51
-    else
52
-    {
53
-        $db->rollback();
54
-        setEventMessages($langs->trans("Error"), null, 'errors');
55
-    }
40
+	$i=0;
41
+
42
+	$db->begin();
43
+
44
+	$i+=dolibarr_set_const($db,'WEBSERVICES_KEY',trim(GETPOST("WEBSERVICES_KEY")),'chaine',0,'',$conf->entity);
45
+
46
+	if ($i >= 1)
47
+	{
48
+		$db->commit();
49
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
+	}
51
+	else
52
+	{
53
+		$db->rollback();
54
+		setEventMessages($langs->trans("Error"), null, 'errors');
55
+	}
56 56
 }
57 57
 
58 58
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		'actioncomm'		=> '!empty($conf->agenda->enabled)',
111 111
 		'category'			=> '!empty($conf->categorie->enabled)',
112 112
 		'project'			=> '!empty($conf->projet->enabled)',
113
-        'other'				=> ''
113
+		'other'				=> ''
114 114
 );
115 115
 
116 116
 
Please login to merge, or discard this patch.
htdocs/core/ajax/security.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
 {
46 46
 	if ($_GET['action'] == 'getrandompassword' && $user->admin)
47 47
 	{
48
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
49
-	    $generic = $_GET['generic'] ? true : false;
48
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
49
+		$generic = $_GET['generic'] ? true : false;
50 50
 		echo getRandomPassword($generic);
51 51
 	}
52 52
 }
Please login to merge, or discard this patch.
htdocs/core/ajax/check_notifications.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -46,73 +46,73 @@
 block discarded – undo
46 46
 // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
47 47
 if ($time >= $_SESSION['auto_check_events_not_before']) 
48 48
 {
49
-    $time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY;   // Always defined
50
-    if (! empty($_SESSION['auto_check_events_not_before'])) 
51
-    {
52
-        // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
53
-        // then we are not losing periods 
54
-        $starttime = $_SESSION['auto_check_events_not_before'];
55
-        // Protection to avoid too long sessions
56
-        if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT)) 
57
-        {
58
-            dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
59
-            $starttime = $time;
60
-        }
61
-    }
62
-    else 
63
-    {
64
-        $starttime = $time;
65
-    }
49
+	$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY;   // Always defined
50
+	if (! empty($_SESSION['auto_check_events_not_before'])) 
51
+	{
52
+		// We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
53
+		// then we are not losing periods 
54
+		$starttime = $_SESSION['auto_check_events_not_before'];
55
+		// Protection to avoid too long sessions
56
+		if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT)) 
57
+		{
58
+			dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
59
+			$starttime = $time;
60
+		}
61
+	}
62
+	else 
63
+	{
64
+		$starttime = $time;
65
+	}
66 66
     
67
-    $_SESSION['auto_check_events_not_before'] = $time + $time_update;
67
+	$_SESSION['auto_check_events_not_before'] = $time + $time_update;
68 68
     
69
-    // Force save of session change we did. 
70
-    // WARNING: Any change in sessions after that will not be saved !
71
-    session_write_close();
69
+	// Force save of session change we did. 
70
+	// WARNING: Any change in sessions after that will not be saved !
71
+	session_write_close();
72 72
     
73
-    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
73
+	require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
74 74
 	
75 75
     
76
-    dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
76
+	dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
77 77
     
78
-    $sql = 'SELECT id';
79
-    $sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
80
-    $sql .= ' WHERE a.id = ar.fk_actioncomm';
81
-    // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
82
-    // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
83
-    $sql .= " AND datep BETWEEN '" . $db->idate($starttime) . "' AND '" . $db->idate($time + $time_update - 1) . "'";
84
-    $sql .= ' AND a.code <> "AC_OTH_AUTO"';
85
-    $sql .= ' AND ar.element_type = "user"';
86
-    $sql .= ' AND ar.fk_element = ' . $user->id;
87
-    $sql .= ' LIMIT 10';    // Avoid too many notification at once
88
-
89
-    $resql = $db->query($sql);
90
-    if ($resql) {
91
-
92
-        $actionmod = new ActionComm($db);
93
-
94
-        while ($obj = $db->fetch_object($resql)) 
95
-        {
96
-            $langs->load("agenda");
97
-            $langs->load("commercial");
78
+	$sql = 'SELECT id';
79
+	$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
80
+	$sql .= ' WHERE a.id = ar.fk_actioncomm';
81
+	// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
82
+	// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet).
83
+	$sql .= " AND datep BETWEEN '" . $db->idate($starttime) . "' AND '" . $db->idate($time + $time_update - 1) . "'";
84
+	$sql .= ' AND a.code <> "AC_OTH_AUTO"';
85
+	$sql .= ' AND ar.element_type = "user"';
86
+	$sql .= ' AND ar.fk_element = ' . $user->id;
87
+	$sql .= ' LIMIT 10';    // Avoid too many notification at once
88
+
89
+	$resql = $db->query($sql);
90
+	if ($resql) {
91
+
92
+		$actionmod = new ActionComm($db);
93
+
94
+		while ($obj = $db->fetch_object($resql)) 
95
+		{
96
+			$langs->load("agenda");
97
+			$langs->load("commercial");
98 98
             
99
-            $actionmod->fetch($obj->id);
100
-
101
-            // Message must be formated and translated to be used with javascript directly
102
-            $event = array();
103
-            $event['type'] = 'agenda';
104
-            $event['id'] = $actionmod->id;
105
-            $event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
106
-            $event['titulo'] = $actionmod->label;
107
-            $event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
99
+			$actionmod->fetch($obj->id);
100
+
101
+			// Message must be formated and translated to be used with javascript directly
102
+			$event = array();
103
+			$event['type'] = 'agenda';
104
+			$event['id'] = $actionmod->id;
105
+			$event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
106
+			$event['titulo'] = $actionmod->label;
107
+			$event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
108 108
             
109
-            $eventfound[] = $event;
110
-        }
111
-    }
112
-    else
113
-    {
114
-        dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
115
-    }
109
+			$eventfound[] = $event;
110
+		}
111
+	}
112
+	else
113
+	{
114
+		dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR);
115
+	}
116 116
 
117 117
 }
118 118
 
Please login to merge, or discard this patch.
htdocs/core/ajax/objectonoff.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,4 +46,4 @@
 block discarded – undo
46 46
 
47 47
 // Registering new values
48 48
 if (($action == 'set') && ! empty($id))
49
-    $object->setValueFrom($field, $value, $element, $id);
49
+	$object->setValueFrom($field, $value, $element, $id);
Please login to merge, or discard this patch.
htdocs/core/ajax/box.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	$nbboxonright=substr_count($tmp[1],',');
61 61
 	print $nbboxonleft.'-'.$nbboxonright;
62 62
 	if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder);    // Insert id of new box into list
63
-    else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder);    // Insert id of new box into list
63
+	else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder);    // Insert id of new box into list
64 64
 }
65 65
 
66 66
 // Registering the location of boxes after a move
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	$result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid);
73 73
 	if ($result > 0) 
74 74
 	{
75
-	    $langs->load("boxes");
76
-	    if (! GETPOST('closing'))
77
-	    {
78
-	       setEventMessages($langs->trans("BoxAdded"), null);
79
-	    }
75
+		$langs->load("boxes");
76
+		if (! GETPOST('closing'))
77
+		{
78
+		   setEventMessages($langs->trans("BoxAdded"), null);
79
+		}
80 80
 	}
81 81
 }
82 82
 
Please login to merge, or discard this patch.