@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class Client extends Societe |
31 | 31 | { |
32 | - public $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method |
|
32 | + public $next_prev_filter = "te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method |
|
33 | 33 | |
34 | - public $cacheprospectstatus=array(); |
|
34 | + public $cacheprospectstatus = array(); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -58,28 +58,28 @@ discard block |
||
58 | 58 | // phpcs:enable |
59 | 59 | global $user; |
60 | 60 | |
61 | - $this->nb=array("customers" => 0,"prospects" => 0); |
|
61 | + $this->nb = array("customers" => 0, "prospects" => 0); |
|
62 | 62 | $clause = "WHERE"; |
63 | 63 | |
64 | 64 | $sql = "SELECT count(s.rowid) as nb, s.client"; |
65 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
65 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
66 | 66 | if (!$user->rights->societe->client->voir && !$user->societe_id) |
67 | 67 | { |
68 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; |
|
69 | - $sql.= " WHERE sc.fk_user = " .$user->id; |
|
68 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; |
|
69 | + $sql .= " WHERE sc.fk_user = ".$user->id; |
|
70 | 70 | $clause = "AND"; |
71 | 71 | } |
72 | - $sql.= " ".$clause." s.client IN (1,2,3)"; |
|
73 | - $sql.= ' AND s.entity IN ('.getEntity($this->element).')'; |
|
74 | - $sql.= " GROUP BY s.client"; |
|
72 | + $sql .= " ".$clause." s.client IN (1,2,3)"; |
|
73 | + $sql .= ' AND s.entity IN ('.getEntity($this->element).')'; |
|
74 | + $sql .= " GROUP BY s.client"; |
|
75 | 75 | |
76 | - $resql=$this->db->query($sql); |
|
76 | + $resql = $this->db->query($sql); |
|
77 | 77 | if ($resql) |
78 | 78 | { |
79 | - while ($obj=$this->db->fetch_object($resql)) |
|
79 | + while ($obj = $this->db->fetch_object($resql)) |
|
80 | 80 | { |
81 | - if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"]+=$obj->nb; |
|
82 | - if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"]+=$obj->nb; |
|
81 | + if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb; |
|
82 | + if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb; |
|
83 | 83 | } |
84 | 84 | $this->db->free($resql); |
85 | 85 | return 1; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | else |
88 | 88 | { |
89 | 89 | dol_print_error($this->db); |
90 | - $this->error=$this->db->lasterror(); |
|
90 | + $this->error = $this->db->lasterror(); |
|
91 | 91 | return -1; |
92 | 92 | } |
93 | 93 | } |
@@ -98,19 +98,19 @@ discard block |
||
98 | 98 | * @param int $active 1=Active only, 0=Not active only, -1=All |
99 | 99 | * @return int <0 if KO, >0 if OK |
100 | 100 | */ |
101 | - function loadCacheOfProspStatus($active=1) |
|
101 | + function loadCacheOfProspStatus($active = 1) |
|
102 | 102 | { |
103 | 103 | global $langs; |
104 | 104 | |
105 | - $sql="SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm"; |
|
106 | - if ($active >= 0) $sql.=" WHERE active = ".$active; |
|
107 | - $resql=$this->db->query($sql); |
|
108 | - $num=$this->db->num_rows($resql); |
|
109 | - $i=0; |
|
105 | + $sql = "SELECT id, code, libelle as label FROM ".MAIN_DB_PREFIX."c_stcomm"; |
|
106 | + if ($active >= 0) $sql .= " WHERE active = ".$active; |
|
107 | + $resql = $this->db->query($sql); |
|
108 | + $num = $this->db->num_rows($resql); |
|
109 | + $i = 0; |
|
110 | 110 | while ($i < $num) |
111 | 111 | { |
112 | - $obj=$this->db->fetch_object($resql); |
|
113 | - $this->cacheprospectstatus[$obj->id]=array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code))=="ST_".strtoupper($obj->code))?$obj->label:$langs->trans("ST_".strtoupper($obj->code))); |
|
112 | + $obj = $this->db->fetch_object($resql); |
|
113 | + $this->cacheprospectstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=> ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code))); |
|
114 | 114 | $i++; |
115 | 115 | } |
116 | 116 | return 1; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $this->company = new Societe($this->db); |
58 | 58 | |
59 | - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { |
|
59 | + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { |
|
60 | 60 | static::$FIELDS[] = 'email'; |
61 | 61 | } |
62 | 62 | } |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function get($id) |
75 | 75 | { |
76 | - if(! DolibarrApiAccess::$user->rights->societe->lire) { |
|
76 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
77 | 77 | throw new RestException(401); |
78 | 78 | } |
79 | 79 | |
80 | 80 | $result = $this->company->fetch($id); |
81 | - if( ! $result ) { |
|
81 | + if (!$result) { |
|
82 | 82 | throw new RestException(404, 'Thirdparty not found'); |
83 | 83 | } |
84 | 84 | |
85 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
85 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
86 | 86 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
87 | 87 | } |
88 | 88 | |
89 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
89 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
90 | 90 | $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice |
91 | 91 | $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice |
92 | 92 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')" |
118 | 118 | * @return array Array of thirdparty objects |
119 | 119 | */ |
120 | - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode=0, $sqlfilters = '') |
|
120 | + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '') |
|
121 | 121 | { |
122 | 122 | global $db, $conf; |
123 | 123 | |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | |
129 | 129 | // If the internal user must only see his customers, force searching by him |
130 | 130 | $search_sale = 0; |
131 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
131 | + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; |
|
132 | 132 | |
133 | 133 | $sql = "SELECT t.rowid"; |
134 | 134 | if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
135 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as t"; |
|
136 | - |
|
137 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
138 | - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; |
|
139 | - $sql.= " WHERE t.fk_stcomm = st.id"; |
|
140 | - if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; |
|
141 | - if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; |
|
142 | - if ($mode == 3) $sql.= " AND t.client IN (0)"; |
|
143 | - $sql.= ' AND t.entity IN ('.getEntity('societe').')'; |
|
144 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; |
|
135 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as t"; |
|
136 | + |
|
137 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
138 | + $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; |
|
139 | + $sql .= " WHERE t.fk_stcomm = st.id"; |
|
140 | + if ($mode == 1) $sql .= " AND t.client IN (1, 3)"; |
|
141 | + if ($mode == 2) $sql .= " AND t.client IN (2, 3)"; |
|
142 | + if ($mode == 3) $sql .= " AND t.client IN (0)"; |
|
143 | + $sql .= ' AND t.entity IN ('.getEntity('societe').')'; |
|
144 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; |
|
145 | 145 | //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; |
146 | - if ($socid) $sql.= " AND t.rowid IN (".$socids.")"; |
|
147 | - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
146 | + if ($socid) $sql .= " AND t.rowid IN (".$socids.")"; |
|
147 | + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale |
|
148 | 148 | // Insert sale filter |
149 | 149 | if ($search_sale > 0) |
150 | 150 | { |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | // Add sql filters |
154 | 154 | if ($sqlfilters) |
155 | 155 | { |
156 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
156 | + if (!DolibarrApi::_checkFilters($sqlfilters)) |
|
157 | 157 | { |
158 | 158 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
159 | 159 | } |
160 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
161 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
160 | + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
161 | + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
162 | 162 | } |
163 | 163 | |
164 | - $sql.= $db->order($sortfield, $sortorder); |
|
164 | + $sql .= $db->order($sortfield, $sortorder); |
|
165 | 165 | |
166 | 166 | if ($limit) { |
167 | 167 | if ($page < 0) |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | $offset = $limit * $page; |
172 | 172 | |
173 | - $sql.= $db->plimit($limit + 1, $offset); |
|
173 | + $sql .= $db->plimit($limit + 1, $offset); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $result = $db->query($sql); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | $obj = $db->fetch_object($result); |
184 | 184 | $soc_static = new Societe($db); |
185 | - if($soc_static->fetch($obj->rowid)) { |
|
185 | + if ($soc_static->fetch($obj->rowid)) { |
|
186 | 186 | $obj_ret[] = $this->_cleanObjectDatas($soc_static); |
187 | 187 | } |
188 | 188 | $i++; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | else { |
192 | 192 | throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror()); |
193 | 193 | } |
194 | - if( ! count($obj_ret)) { |
|
194 | + if (!count($obj_ret)) { |
|
195 | 195 | throw new RestException(404, 'Thirdparties not found'); |
196 | 196 | } |
197 | 197 | return $obj_ret; |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function post($request_data = null) |
207 | 207 | { |
208 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
208 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
209 | 209 | throw new RestException(401); |
210 | 210 | } |
211 | 211 | // Check mandatory fields |
212 | 212 | $result = $this->_validate($request_data); |
213 | 213 | |
214 | - foreach($request_data as $field => $value) { |
|
214 | + foreach ($request_data as $field => $value) { |
|
215 | 215 | $this->company->$field = $value; |
216 | 216 | } |
217 | 217 | if ($this->company->create(DolibarrApiAccess::$user) < 0) |
@@ -229,25 +229,25 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function put($id, $request_data = null) |
231 | 231 | { |
232 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
232 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
233 | 233 | throw new RestException(401); |
234 | 234 | } |
235 | 235 | |
236 | 236 | $result = $this->company->fetch($id); |
237 | - if( ! $result ) { |
|
237 | + if (!$result) { |
|
238 | 238 | throw new RestException(404, 'Thirdparty not found'); |
239 | 239 | } |
240 | 240 | |
241 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
241 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
242 | 242 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
243 | 243 | } |
244 | 244 | |
245 | - foreach($request_data as $field => $value) { |
|
245 | + foreach ($request_data as $field => $value) { |
|
246 | 246 | if ($field == 'id') continue; |
247 | 247 | $this->company->$field = $value; |
248 | 248 | } |
249 | 249 | |
250 | - if($this->company->update($id, DolibarrApiAccess::$user,1,'','','update')) |
|
250 | + if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) |
|
251 | 251 | return $this->get($id); |
252 | 252 | |
253 | 253 | return false; |
@@ -278,27 +278,27 @@ discard block |
||
278 | 278 | throw new RestException(400, 'Try to merge a thirdparty into itself'); |
279 | 279 | } |
280 | 280 | |
281 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
281 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
282 | 282 | throw new RestException(401); |
283 | 283 | } |
284 | 284 | |
285 | - $result = $this->company->fetch($id); // include the fetch of extra fields |
|
286 | - if( ! $result ) { |
|
285 | + $result = $this->company->fetch($id); // include the fetch of extra fields |
|
286 | + if (!$result) { |
|
287 | 287 | throw new RestException(404, 'Thirdparty not found'); |
288 | 288 | } |
289 | 289 | |
290 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
290 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
291 | 291 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
292 | 292 | } |
293 | 293 | |
294 | 294 | $this->companytoremove = new Societe($db); |
295 | 295 | |
296 | - $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields |
|
297 | - if( ! $result ) { |
|
296 | + $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields |
|
297 | + if (!$result) { |
|
298 | 298 | throw new RestException(404, 'Thirdparty not found'); |
299 | 299 | } |
300 | 300 | |
301 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->companytoremove->id)) { |
|
301 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { |
|
302 | 302 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
303 | 303 | } |
304 | 304 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | // Recopy some data |
316 | 316 | $object->client = $object->client | $soc_origin->client; |
317 | 317 | $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; |
318 | - $listofproperties=array( |
|
318 | + $listofproperties = array( |
|
319 | 319 | 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', |
320 | 320 | 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', |
321 | 321 | 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Concat some data |
332 | - $listofproperties=array( |
|
332 | + $listofproperties = array( |
|
333 | 333 | 'note_public', 'note_private' |
334 | 334 | ); |
335 | 335 | foreach ($listofproperties as $property) |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | // Move links |
376 | - if (! $error) |
|
376 | + if (!$error) |
|
377 | 377 | { |
378 | 378 | $objects = array( |
379 | 379 | 'Adherent' => '/adherents/class/adherent.class.php', |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | - if (! $error) |
|
431 | + if (!$error) |
|
432 | 432 | { |
433 | - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); |
|
433 | + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); |
|
434 | 434 | |
435 | 435 | // Call trigger |
436 | - $result=$object->call_trigger('COMPANY_MODIFY',$user); |
|
436 | + $result = $object->call_trigger('COMPANY_MODIFY', $user); |
|
437 | 437 | if ($result < 0) |
438 | 438 | { |
439 | 439 | //setEventMessages($object->error, $object->errors, 'errors'); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | // End call triggers |
443 | 443 | } |
444 | 444 | |
445 | - if (! $error) |
|
445 | + if (!$error) |
|
446 | 446 | { |
447 | 447 | //We finally remove the old thirdparty |
448 | 448 | if ($soc_origin->delete($soc_origin->id, $user) < 1) |
@@ -475,14 +475,14 @@ discard block |
||
475 | 475 | */ |
476 | 476 | function delete($id) |
477 | 477 | { |
478 | - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { |
|
478 | + if (!DolibarrApiAccess::$user->rights->societe->supprimer) { |
|
479 | 479 | throw new RestException(401); |
480 | 480 | } |
481 | 481 | $result = $this->company->fetch($id); |
482 | - if( ! $result ) { |
|
482 | + if (!$result) { |
|
483 | 483 | throw new RestException(404, 'Thirdparty not found'); |
484 | 484 | } |
485 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
485 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
486 | 486 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
487 | 487 | } |
488 | 488 | return $this->company->delete($id); |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | */ |
504 | 504 | function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) |
505 | 505 | { |
506 | - if (! DolibarrApiAccess::$user->rights->categorie->lire) { |
|
506 | + if (!DolibarrApiAccess::$user->rights->categorie->lire) { |
|
507 | 507 | throw new RestException(401); |
508 | 508 | } |
509 | 509 | |
510 | 510 | $result = $this->company->fetch($id); |
511 | - if( ! $result ) |
|
511 | + if (!$result) |
|
512 | 512 | { |
513 | 513 | throw new RestException(404, 'Thirdparty not found'); |
514 | 514 | } |
@@ -542,28 +542,28 @@ discard block |
||
542 | 542 | */ |
543 | 543 | function addCategory($id, $category_id) |
544 | 544 | { |
545 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
545 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
546 | 546 | throw new RestException(401); |
547 | 547 | } |
548 | 548 | |
549 | 549 | $result = $this->company->fetch($id); |
550 | - if( ! $result ) { |
|
550 | + if (!$result) { |
|
551 | 551 | throw new RestException(404, 'Thirdparty not found'); |
552 | 552 | } |
553 | 553 | $category = new Categorie($this->db); |
554 | 554 | $result = $category->fetch($category_id); |
555 | - if( ! $result ) { |
|
555 | + if (!$result) { |
|
556 | 556 | throw new RestException(404, 'category not found'); |
557 | 557 | } |
558 | 558 | |
559 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
559 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
560 | 560 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
561 | 561 | } |
562 | - if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) { |
|
562 | + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { |
|
563 | 563 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
564 | 564 | } |
565 | 565 | |
566 | - $category->add_type($this->company,'customer'); |
|
566 | + $category->add_type($this->company, 'customer'); |
|
567 | 567 | |
568 | 568 | return $this->_cleanObjectDatas($this->company); |
569 | 569 | } |
@@ -580,28 +580,28 @@ discard block |
||
580 | 580 | */ |
581 | 581 | function deleteCategory($id, $category_id) |
582 | 582 | { |
583 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
583 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
584 | 584 | throw new RestException(401); |
585 | 585 | } |
586 | 586 | |
587 | 587 | $result = $this->company->fetch($id); |
588 | - if( ! $result ) { |
|
588 | + if (!$result) { |
|
589 | 589 | throw new RestException(404, 'Thirdparty not found'); |
590 | 590 | } |
591 | 591 | $category = new Categorie($this->db); |
592 | 592 | $result = $category->fetch($category_id); |
593 | - if( ! $result ) { |
|
593 | + if (!$result) { |
|
594 | 594 | throw new RestException(404, 'category not found'); |
595 | 595 | } |
596 | 596 | |
597 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
597 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
598 | 598 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
599 | 599 | } |
600 | - if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) { |
|
600 | + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { |
|
601 | 601 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
602 | 602 | } |
603 | 603 | |
604 | - $category->del_type($this->company,'customer'); |
|
604 | + $category->del_type($this->company, 'customer'); |
|
605 | 605 | |
606 | 606 | return $this->_cleanObjectDatas($this->company); |
607 | 607 | } |
@@ -621,12 +621,12 @@ discard block |
||
621 | 621 | */ |
622 | 622 | function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) |
623 | 623 | { |
624 | - if (! DolibarrApiAccess::$user->rights->categorie->lire) { |
|
624 | + if (!DolibarrApiAccess::$user->rights->categorie->lire) { |
|
625 | 625 | throw new RestException(401); |
626 | 626 | } |
627 | 627 | |
628 | 628 | $result = $this->company->fetch($id); |
629 | - if( ! $result ) |
|
629 | + if (!$result) |
|
630 | 630 | { |
631 | 631 | throw new RestException(404, 'Thirdparty not found'); |
632 | 632 | } |
@@ -660,28 +660,28 @@ discard block |
||
660 | 660 | */ |
661 | 661 | function addSupplierCategory($id, $category_id) |
662 | 662 | { |
663 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
663 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
664 | 664 | throw new RestException(401); |
665 | 665 | } |
666 | 666 | |
667 | 667 | $result = $this->company->fetch($id); |
668 | - if( ! $result ) { |
|
668 | + if (!$result) { |
|
669 | 669 | throw new RestException(404, 'Thirdparty not found'); |
670 | 670 | } |
671 | 671 | $category = new Categorie($this->db); |
672 | 672 | $result = $category->fetch($category_id); |
673 | - if( ! $result ) { |
|
673 | + if (!$result) { |
|
674 | 674 | throw new RestException(404, 'category not found'); |
675 | 675 | } |
676 | 676 | |
677 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
677 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
678 | 678 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
679 | 679 | } |
680 | - if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) { |
|
680 | + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { |
|
681 | 681 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
682 | 682 | } |
683 | 683 | |
684 | - $category->add_type($this->company,'supplier'); |
|
684 | + $category->add_type($this->company, 'supplier'); |
|
685 | 685 | |
686 | 686 | return $this->_cleanObjectDatas($this->company); |
687 | 687 | } |
@@ -698,28 +698,28 @@ discard block |
||
698 | 698 | */ |
699 | 699 | function deleteSupplierCategory($id, $category_id) |
700 | 700 | { |
701 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
701 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
702 | 702 | throw new RestException(401); |
703 | 703 | } |
704 | 704 | |
705 | 705 | $result = $this->company->fetch($id); |
706 | - if( ! $result ) { |
|
706 | + if (!$result) { |
|
707 | 707 | throw new RestException(404, 'Thirdparty not found'); |
708 | 708 | } |
709 | 709 | $category = new Categorie($this->db); |
710 | 710 | $result = $category->fetch($category_id); |
711 | - if( ! $result ) { |
|
711 | + if (!$result) { |
|
712 | 712 | throw new RestException(404, 'category not found'); |
713 | 713 | } |
714 | 714 | |
715 | - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { |
|
715 | + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { |
|
716 | 716 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
717 | 717 | } |
718 | - if( ! DolibarrApi::_checkAccessToResource('category',$category->id)) { |
|
718 | + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { |
|
719 | 719 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
720 | 720 | } |
721 | 721 | |
722 | - $category->del_type($this->company,'supplier'); |
|
722 | + $category->del_type($this->company, 'supplier'); |
|
723 | 723 | |
724 | 724 | return $this->_cleanObjectDatas($this->company); |
725 | 725 | } |
@@ -739,24 +739,24 @@ discard block |
||
739 | 739 | * @throws 401 |
740 | 740 | * @throws 404 |
741 | 741 | */ |
742 | - function getOutStandingProposals($id, $mode='customer') |
|
742 | + function getOutStandingProposals($id, $mode = 'customer') |
|
743 | 743 | { |
744 | 744 | $obj_ret = array(); |
745 | 745 | |
746 | - if(! DolibarrApiAccess::$user->rights->societe->lire) { |
|
746 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
747 | 747 | throw new RestException(401); |
748 | 748 | } |
749 | 749 | |
750 | - if(empty($id)) { |
|
750 | + if (empty($id)) { |
|
751 | 751 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
752 | 752 | } |
753 | 753 | |
754 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
754 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
755 | 755 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
756 | 756 | } |
757 | 757 | |
758 | 758 | $result = $this->company->fetch($id); |
759 | - if( ! $result ) { |
|
759 | + if (!$result) { |
|
760 | 760 | throw new RestException(404, 'Thirdparty not found'); |
761 | 761 | } |
762 | 762 | |
@@ -783,24 +783,24 @@ discard block |
||
783 | 783 | * @throws 401 |
784 | 784 | * @throws 404 |
785 | 785 | */ |
786 | - function getOutStandingOrder($id, $mode='customer') |
|
786 | + function getOutStandingOrder($id, $mode = 'customer') |
|
787 | 787 | { |
788 | 788 | $obj_ret = array(); |
789 | 789 | |
790 | - if(! DolibarrApiAccess::$user->rights->societe->lire) { |
|
790 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
791 | 791 | throw new RestException(401); |
792 | 792 | } |
793 | 793 | |
794 | - if(empty($id)) { |
|
794 | + if (empty($id)) { |
|
795 | 795 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
796 | 796 | } |
797 | 797 | |
798 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
798 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
799 | 799 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
800 | 800 | } |
801 | 801 | |
802 | 802 | $result = $this->company->fetch($id); |
803 | - if( ! $result ) { |
|
803 | + if (!$result) { |
|
804 | 804 | throw new RestException(404, 'Thirdparty not found'); |
805 | 805 | } |
806 | 806 | |
@@ -826,24 +826,24 @@ discard block |
||
826 | 826 | * @throws 401 |
827 | 827 | * @throws 404 |
828 | 828 | */ |
829 | - function getOutStandingInvoices($id, $mode='customer') |
|
829 | + function getOutStandingInvoices($id, $mode = 'customer') |
|
830 | 830 | { |
831 | 831 | $obj_ret = array(); |
832 | 832 | |
833 | - if(! DolibarrApiAccess::$user->rights->societe->lire) { |
|
833 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
834 | 834 | throw new RestException(401); |
835 | 835 | } |
836 | 836 | |
837 | - if(empty($id)) { |
|
837 | + if (empty($id)) { |
|
838 | 838 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
839 | 839 | } |
840 | 840 | |
841 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
841 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
842 | 842 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
843 | 843 | } |
844 | 844 | |
845 | 845 | $result = $this->company->fetch($id); |
846 | - if( ! $result ) { |
|
846 | + if (!$result) { |
|
847 | 847 | throw new RestException(404, 'Thirdparty not found'); |
848 | 848 | } |
849 | 849 | |
@@ -872,24 +872,24 @@ discard block |
||
872 | 872 | * @throws 404 |
873 | 873 | * @throws 503 |
874 | 874 | */ |
875 | - function getFixedAmountDiscounts($id, $filter="none", $sortfield = "f.type", $sortorder = 'ASC') |
|
875 | + function getFixedAmountDiscounts($id, $filter = "none", $sortfield = "f.type", $sortorder = 'ASC') |
|
876 | 876 | { |
877 | 877 | $obj_ret = array(); |
878 | 878 | |
879 | - if(! DolibarrApiAccess::$user->rights->societe->lire) { |
|
879 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
880 | 880 | throw new RestException(401); |
881 | 881 | } |
882 | 882 | |
883 | - if(empty($id)) { |
|
883 | + if (empty($id)) { |
|
884 | 884 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
885 | 885 | } |
886 | 886 | |
887 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
887 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
888 | 888 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
889 | 889 | } |
890 | 890 | |
891 | 891 | $result = $this->company->fetch($id); |
892 | - if( ! $result ) { |
|
892 | + if (!$result) { |
|
893 | 893 | throw new RestException(404, 'Thirdparty not found'); |
894 | 894 | } |
895 | 895 | |
@@ -900,14 +900,14 @@ discard block |
||
900 | 900 | if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; |
901 | 901 | if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; |
902 | 902 | |
903 | - $sql.= $this->db->order($sortfield, $sortorder); |
|
903 | + $sql .= $this->db->order($sortfield, $sortorder); |
|
904 | 904 | |
905 | 905 | $result = $this->db->query($sql); |
906 | - if( ! $result ) { |
|
906 | + if (!$result) { |
|
907 | 907 | throw new RestException(503, $this->db->lasterror()); |
908 | 908 | } else { |
909 | 909 | $num = $this->db->num_rows($result); |
910 | - while ( $obj = $this->db->fetch_object($result) ) { |
|
910 | + while ($obj = $this->db->fetch_object($result)) { |
|
911 | 911 | $obj_ret[] = $obj; |
912 | 912 | } |
913 | 913 | } |
@@ -932,14 +932,14 @@ discard block |
||
932 | 932 | */ |
933 | 933 | function getInvoicesQualifiedForReplacement($id) |
934 | 934 | { |
935 | - if(! DolibarrApiAccess::$user->rights->facture->lire) { |
|
935 | + if (!DolibarrApiAccess::$user->rights->facture->lire) { |
|
936 | 936 | throw new RestException(401); |
937 | 937 | } |
938 | - if(empty($id)) { |
|
938 | + if (empty($id)) { |
|
939 | 939 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
940 | 940 | } |
941 | 941 | |
942 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
942 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
943 | 943 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
944 | 944 | } |
945 | 945 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | |
951 | 951 | $invoice = new Facture($this->db); |
952 | 952 | $result = $invoice->list_replacable_invoices($id); |
953 | - if( $result < 0) { |
|
953 | + if ($result < 0) { |
|
954 | 954 | throw new RestException(405, $this->thirdparty->error); |
955 | 955 | } |
956 | 956 | |
@@ -974,14 +974,14 @@ discard block |
||
974 | 974 | */ |
975 | 975 | function getInvoicesQualifiedForCreditNote($id) |
976 | 976 | { |
977 | - if(! DolibarrApiAccess::$user->rights->facture->lire) { |
|
977 | + if (!DolibarrApiAccess::$user->rights->facture->lire) { |
|
978 | 978 | throw new RestException(401); |
979 | 979 | } |
980 | - if(empty($id)) { |
|
980 | + if (empty($id)) { |
|
981 | 981 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
982 | 982 | } |
983 | 983 | |
984 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
984 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
985 | 985 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
986 | 986 | } |
987 | 987 | |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | |
993 | 993 | $invoice = new Facture($this->db); |
994 | 994 | $result = $invoice->list_qualified_avoir_invoices($id); |
995 | - if( $result < 0) { |
|
995 | + if ($result < 0) { |
|
996 | 996 | throw new RestException(405, $this->thirdparty->error); |
997 | 997 | } |
998 | 998 | |
@@ -1012,14 +1012,14 @@ discard block |
||
1012 | 1012 | { |
1013 | 1013 | global $db, $conf; |
1014 | 1014 | |
1015 | - if(! DolibarrApiAccess::$user->rights->facture->lire) { |
|
1015 | + if (!DolibarrApiAccess::$user->rights->facture->lire) { |
|
1016 | 1016 | throw new RestException(401); |
1017 | 1017 | } |
1018 | - if(empty($id)) { |
|
1018 | + if (empty($id)) { |
|
1019 | 1019 | throw new RestException(400, 'Thirdparty ID is mandatory'); |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - if( ! DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
1022 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
1023 | 1023 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1028,20 +1028,20 @@ discard block |
||
1028 | 1028 | */ |
1029 | 1029 | |
1030 | 1030 | $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; |
1031 | - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; |
|
1032 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; |
|
1033 | - if ($id) $sql.= " WHERE fk_soc = ".$id." "; |
|
1031 | + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; |
|
1032 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; |
|
1033 | + if ($id) $sql .= " WHERE fk_soc = ".$id." "; |
|
1034 | 1034 | |
1035 | 1035 | |
1036 | 1036 | $result = $db->query($sql); |
1037 | 1037 | |
1038 | - if($result->num_rows == 0 ){ |
|
1038 | + if ($result->num_rows == 0) { |
|
1039 | 1039 | throw new RestException(404, 'Account not found'); |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - $i=0; |
|
1042 | + $i = 0; |
|
1043 | 1043 | |
1044 | - $accounts =[]; |
|
1044 | + $accounts = []; |
|
1045 | 1045 | |
1046 | 1046 | if ($result) |
1047 | 1047 | { |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | { |
1051 | 1051 | $obj = $db->fetch_object($result); |
1052 | 1052 | $account = new CompanyBankAccount($db); |
1053 | - if($account->fetch($obj->rowid)) { |
|
1053 | + if ($account->fetch($obj->rowid)) { |
|
1054 | 1054 | $accounts[] = $account; |
1055 | 1055 | } |
1056 | 1056 | $i++; |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | - else{ |
|
1059 | + else { |
|
1060 | 1060 | throw new RestException(404, 'Account not found'); |
1061 | 1061 | } |
1062 | 1062 | |
@@ -1065,10 +1065,10 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | $returnAccounts = []; |
1067 | 1067 | |
1068 | - foreach($accounts as $account){ |
|
1069 | - $object= []; |
|
1070 | - foreach($account as $key => $value) |
|
1071 | - if(in_array($key, $fields)){ |
|
1068 | + foreach ($accounts as $account) { |
|
1069 | + $object = []; |
|
1070 | + foreach ($account as $key => $value) |
|
1071 | + if (in_array($key, $fields)) { |
|
1072 | 1072 | $object[$key] = $value; |
1073 | 1073 | } |
1074 | 1074 | $returnAccounts[] = $object; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | function createCompanyBankAccount($id, $request_data = null) |
1090 | 1090 | { |
1091 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1091 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1092 | 1092 | throw new RestException(401); |
1093 | 1093 | } |
1094 | 1094 | |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | |
1097 | 1097 | $account->socid = $id; |
1098 | 1098 | |
1099 | - foreach($request_data as $field => $value) { |
|
1099 | + foreach ($request_data as $field => $value) { |
|
1100 | 1100 | $account->$field = $value; |
1101 | 1101 | } |
1102 | 1102 | |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | */ |
1124 | 1124 | function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null) |
1125 | 1125 | { |
1126 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1126 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1127 | 1127 | throw new RestException(401); |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1131,12 +1131,12 @@ discard block |
||
1131 | 1131 | |
1132 | 1132 | $account->fetch($bankaccount_id, $id, -1, ''); |
1133 | 1133 | |
1134 | - if($account->socid != $id){ |
|
1134 | + if ($account->socid != $id) { |
|
1135 | 1135 | throw new RestException(401); |
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | |
1139 | - foreach($request_data as $field => $value) { |
|
1139 | + foreach ($request_data as $field => $value) { |
|
1140 | 1140 | $account->$field = $value; |
1141 | 1141 | } |
1142 | 1142 | |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | */ |
1159 | 1159 | function deleteCompanyBankAccount($id, $bankaccount_id) |
1160 | 1160 | { |
1161 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1161 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1162 | 1162 | throw new RestException(401); |
1163 | 1163 | } |
1164 | 1164 | |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | |
1167 | 1167 | $account->fetch($bankaccount_id); |
1168 | 1168 | |
1169 | - if(!$account->socid == $id) |
|
1169 | + if (!$account->socid == $id) |
|
1170 | 1170 | throw new RestException(401); |
1171 | 1171 | |
1172 | 1172 | return $account->delete(DolibarrApiAccess::$user); |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | { |
1187 | 1187 | global $conf; |
1188 | 1188 | |
1189 | - $this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals")); |
|
1189 | + $this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals")); |
|
1190 | 1190 | |
1191 | 1191 | $this->company->fetch($id); |
1192 | 1192 | |
1193 | 1193 | $action = 'builddoc'; |
1194 | - if(! DolibarrApiAccess::$user->rights->societe->creer) |
|
1194 | + if (!DolibarrApiAccess::$user->rights->societe->creer) |
|
1195 | 1195 | throw new RestException(401); |
1196 | 1196 | |
1197 | 1197 | $this->company->setDocModel(DolibarrApiAccess::$user, $model); |
@@ -1199,32 +1199,32 @@ discard block |
||
1199 | 1199 | $this->company->fk_bank = $this->company->fk_account; |
1200 | 1200 | |
1201 | 1201 | $outputlangs = $this->langs; |
1202 | - $newlang=''; |
|
1202 | + $newlang = ''; |
|
1203 | 1203 | |
1204 | - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); |
|
1205 | - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
1206 | - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty |
|
1207 | - if (! empty($newlang)) { |
|
1208 | - $outputlangs = new Translate("",$conf); |
|
1204 | + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
1205 | + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ... |
|
1206 | + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty |
|
1207 | + if (!empty($newlang)) { |
|
1208 | + $outputlangs = new Translate("", $conf); |
|
1209 | 1209 | $outputlangs->setDefaultLang($newlang); |
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | // To be sure vars is defined |
1213 | 1213 | $hidedetails = $hidedesc = $hideref = 0; |
1214 | - $moreparams=null; |
|
1215 | - if (empty($hidedetails)) $hidedetails=0; |
|
1216 | - if (empty($hidedesc)) $hidedesc=0; |
|
1217 | - if (empty($hideref)) $hideref=0; |
|
1218 | - if (empty($moreparams)) $moreparams=null; |
|
1214 | + $moreparams = null; |
|
1215 | + if (empty($hidedetails)) $hidedetails = 0; |
|
1216 | + if (empty($hidedesc)) $hidedesc = 0; |
|
1217 | + if (empty($hideref)) $hideref = 0; |
|
1218 | + if (empty($moreparams)) $moreparams = null; |
|
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | $sql = "SELECT rowid"; |
1222 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; |
|
1223 | - if ($id) $sql.= " WHERE fk_soc = ".$id." "; |
|
1224 | - if ($companybankid) $sql.= " AND id = ".$companybankid.""; |
|
1222 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; |
|
1223 | + if ($id) $sql .= " WHERE fk_soc = ".$id." "; |
|
1224 | + if ($companybankid) $sql .= " AND id = ".$companybankid.""; |
|
1225 | 1225 | |
1226 | - $i=0; |
|
1227 | - $accounts=array(); |
|
1226 | + $i = 0; |
|
1227 | + $accounts = array(); |
|
1228 | 1228 | |
1229 | 1229 | $result = $this->db->query($sql); |
1230 | 1230 | if ($result) |
@@ -1281,15 +1281,15 @@ discard block |
||
1281 | 1281 | * |
1282 | 1282 | * @url GET {id}/gateways/ |
1283 | 1283 | */ |
1284 | - function getSocieteAccounts($id, $site=null) |
|
1284 | + function getSocieteAccounts($id, $site = null) |
|
1285 | 1285 | { |
1286 | 1286 | global $db, $conf; |
1287 | 1287 | |
1288 | - if(!DolibarrApiAccess::$user->rights->societe->lire) { |
|
1288 | + if (!DolibarrApiAccess::$user->rights->societe->lire) { |
|
1289 | 1289 | throw new RestException(401); |
1290 | 1290 | } |
1291 | 1291 | |
1292 | - if(!DolibarrApi::_checkAccessToResource('societe',$id)) { |
|
1292 | + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { |
|
1293 | 1293 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
1294 | 1294 | } |
1295 | 1295 | |
@@ -1297,18 +1297,18 @@ discard block |
||
1297 | 1297 | * We select all the records that match the socid |
1298 | 1298 | */ |
1299 | 1299 | $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; |
1300 | - $sql.= " WHERE fk_soc = $id"; |
|
1301 | - if($site) $sql .= " AND site ='$site'"; |
|
1300 | + $sql .= " WHERE fk_soc = $id"; |
|
1301 | + if ($site) $sql .= " AND site ='$site'"; |
|
1302 | 1302 | |
1303 | 1303 | $result = $db->query($sql); |
1304 | 1304 | |
1305 | - if($result->num_rows == 0){ |
|
1305 | + if ($result->num_rows == 0) { |
|
1306 | 1306 | throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); |
1307 | 1307 | } |
1308 | 1308 | |
1309 | - $i=0; |
|
1309 | + $i = 0; |
|
1310 | 1310 | |
1311 | - $accounts =[]; |
|
1311 | + $accounts = []; |
|
1312 | 1312 | |
1313 | 1313 | $num = $db->num_rows($result); |
1314 | 1314 | while ($i < $num) |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | $obj = $db->fetch_object($result); |
1317 | 1317 | $account = new SocieteAccount($db); |
1318 | 1318 | |
1319 | - if($account->fetch($obj->rowid)) { |
|
1319 | + if ($account->fetch($obj->rowid)) { |
|
1320 | 1320 | $accounts[] = $account; |
1321 | 1321 | } |
1322 | 1322 | $i++; |
@@ -1326,10 +1326,10 @@ discard block |
||
1326 | 1326 | |
1327 | 1327 | $returnAccounts = []; |
1328 | 1328 | |
1329 | - foreach($accounts as $account){ |
|
1330 | - $object= []; |
|
1331 | - foreach($account as $key => $value) |
|
1332 | - if(in_array($key, $fields)){ |
|
1329 | + foreach ($accounts as $account) { |
|
1330 | + $object = []; |
|
1331 | + foreach ($account as $key => $value) |
|
1332 | + if (in_array($key, $fields)) { |
|
1333 | 1333 | $object[$key] = $value; |
1334 | 1334 | } |
1335 | 1335 | $returnAccounts[] = $object; |
@@ -1361,25 +1361,25 @@ discard block |
||
1361 | 1361 | { |
1362 | 1362 | global $db; |
1363 | 1363 | |
1364 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1364 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1365 | 1365 | throw new RestException(401); |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - if(!isset($request_data['site'])) { |
|
1368 | + if (!isset($request_data['site'])) { |
|
1369 | 1369 | throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); |
1370 | 1370 | } |
1371 | 1371 | |
1372 | - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; |
|
1372 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; |
|
1373 | 1373 | $result = $db->query($sql); |
1374 | 1374 | |
1375 | - if($result->num_rows == 0 ){ |
|
1375 | + if ($result->num_rows == 0) { |
|
1376 | 1376 | $account = new SocieteAccount($this->db); |
1377 | - if(!isset($request_data['login'])) { |
|
1377 | + if (!isset($request_data['login'])) { |
|
1378 | 1378 | $account->login = ""; |
1379 | 1379 | } |
1380 | 1380 | $account->fk_soc = $id; |
1381 | 1381 | |
1382 | - foreach($request_data as $field => $value) { |
|
1382 | + foreach ($request_data as $field => $value) { |
|
1383 | 1383 | $account->$field = $value; |
1384 | 1384 | } |
1385 | 1385 | |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | { |
1421 | 1421 | global $db; |
1422 | 1422 | |
1423 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1423 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1424 | 1424 | throw new RestException(401); |
1425 | 1425 | } |
1426 | 1426 | |
@@ -1428,16 +1428,16 @@ discard block |
||
1428 | 1428 | $result = $db->query($sql); |
1429 | 1429 | |
1430 | 1430 | // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. |
1431 | - if($result->num_rows == 0 ){ |
|
1432 | - if(!isset($request_data['key_account'])) { |
|
1431 | + if ($result->num_rows == 0) { |
|
1432 | + if (!isset($request_data['key_account'])) { |
|
1433 | 1433 | throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); |
1434 | 1434 | } |
1435 | 1435 | $account = new SocieteAccount($this->db); |
1436 | - if(!isset($request_data['login'])) { |
|
1436 | + if (!isset($request_data['login'])) { |
|
1437 | 1437 | $account->login = ""; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - foreach($request_data as $field => $value) { |
|
1440 | + foreach ($request_data as $field => $value) { |
|
1441 | 1441 | $account->$field = $value; |
1442 | 1442 | } |
1443 | 1443 | |
@@ -1449,12 +1449,12 @@ discard block |
||
1449 | 1449 | // We found an existing SocieteAccount entity, we are replacing it |
1450 | 1450 | } else { |
1451 | 1451 | |
1452 | - if(isset($request_data['site']) && $request_data['site'] !== $site) { |
|
1453 | - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; |
|
1452 | + if (isset($request_data['site']) && $request_data['site'] !== $site) { |
|
1453 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; |
|
1454 | 1454 | $result = $db->query($sql); |
1455 | 1455 | |
1456 | - if($result->num_rows !== 0) |
|
1457 | - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key."); |
|
1456 | + if ($result->num_rows !== 0) |
|
1457 | + throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site']." but another SocieteAccount entity already exists with this site key."); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | $obj = $db->fetch_object($result); |
@@ -1463,13 +1463,13 @@ discard block |
||
1463 | 1463 | $account->id = $obj->rowid; |
1464 | 1464 | $account->fk_soc = $id; |
1465 | 1465 | $account->site = $site; |
1466 | - if(!isset($request_data['login'])) { |
|
1466 | + if (!isset($request_data['login'])) { |
|
1467 | 1467 | $account->login = ""; |
1468 | 1468 | } |
1469 | 1469 | $account->fk_user_creat = $obj->fk_user_creat; |
1470 | 1470 | $account->date_creation = $obj->date_creation; |
1471 | 1471 | |
1472 | - foreach($request_data as $field => $value) { |
|
1472 | + foreach ($request_data as $field => $value) { |
|
1473 | 1473 | $account->$field = $value; |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1501,31 +1501,31 @@ discard block |
||
1501 | 1501 | { |
1502 | 1502 | global $db; |
1503 | 1503 | |
1504 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1504 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1505 | 1505 | throw new RestException(401); |
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; |
1509 | 1509 | $result = $db->query($sql); |
1510 | 1510 | |
1511 | - if($result->num_rows == 0 ){ |
|
1511 | + if ($result->num_rows == 0) { |
|
1512 | 1512 | throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); |
1513 | 1513 | } else { |
1514 | 1514 | |
1515 | 1515 | // If the user tries to edit the site member, we check first if |
1516 | - if(isset($request_data['site']) && $request_data['site'] !== $site) { |
|
1517 | - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; |
|
1516 | + if (isset($request_data['site']) && $request_data['site'] !== $site) { |
|
1517 | + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; |
|
1518 | 1518 | $result = $db->query($sql); |
1519 | 1519 | |
1520 | - if($result->num_rows !== 0) |
|
1521 | - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key."); |
|
1520 | + if ($result->num_rows !== 0) |
|
1521 | + throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | $obj = $db->fetch_object($result); |
1525 | 1525 | $account = new SocieteAccount($this->db); |
1526 | 1526 | $account->fetch($obj->rowid); |
1527 | 1527 | |
1528 | - foreach($request_data as $field => $value) { |
|
1528 | + foreach ($request_data as $field => $value) { |
|
1529 | 1529 | $account->$field = $value; |
1530 | 1530 | } |
1531 | 1531 | |
@@ -1556,21 +1556,21 @@ discard block |
||
1556 | 1556 | global /** @var Database $db */ |
1557 | 1557 | $db; |
1558 | 1558 | |
1559 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1559 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1560 | 1560 | throw new RestException(401); |
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; |
1564 | 1564 | $result = $db->query($sql); |
1565 | 1565 | |
1566 | - if($result->num_rows == 0 ){ |
|
1566 | + if ($result->num_rows == 0) { |
|
1567 | 1567 | throw new RestException(404); |
1568 | 1568 | } else { |
1569 | 1569 | $obj = $db->fetch_object($result); |
1570 | 1570 | $account = new SocieteAccount($this->db); |
1571 | 1571 | $account->fetch($obj->rowid); |
1572 | 1572 | |
1573 | - if($account->delete(DolibarrApiAccess::$user) < 0) { |
|
1573 | + if ($account->delete(DolibarrApiAccess::$user) < 0) { |
|
1574 | 1574 | throw new RestException(500, "Error while deleting $site gateway attached to this third party"); |
1575 | 1575 | } |
1576 | 1576 | } |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | global /** @var Database $db */ |
1594 | 1594 | $db; |
1595 | 1595 | |
1596 | - if(! DolibarrApiAccess::$user->rights->societe->creer) { |
|
1596 | + if (!DolibarrApiAccess::$user->rights->societe->creer) { |
|
1597 | 1597 | throw new RestException(401); |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1602,14 +1602,14 @@ discard block |
||
1602 | 1602 | */ |
1603 | 1603 | |
1604 | 1604 | $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; |
1605 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; |
|
1605 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; |
|
1606 | 1606 | |
1607 | 1607 | $result = $db->query($sql); |
1608 | 1608 | |
1609 | - if($result->num_rows == 0 ){ |
|
1609 | + if ($result->num_rows == 0) { |
|
1610 | 1610 | throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); |
1611 | 1611 | } else { |
1612 | - $i=0; |
|
1612 | + $i = 0; |
|
1613 | 1613 | |
1614 | 1614 | $num = $db->num_rows($result); |
1615 | 1615 | while ($i < $num) |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | $account = new SocieteAccount($db); |
1619 | 1619 | $account->fetch($obj->rowid); |
1620 | 1620 | |
1621 | - if($account->delete(DolibarrApiAccess::$user) < 0) { |
|
1621 | + if ($account->delete(DolibarrApiAccess::$user) < 0) { |
|
1622 | 1622 | throw new RestException(500, 'Error while deleting gateways attached to this third party'); |
1623 | 1623 | } |
1624 | 1624 | $i++; |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | { |
1637 | 1637 | $object = parent::_cleanObjectDatas($object); |
1638 | 1638 | |
1639 | - unset($object->nom); // ->name already defined and nom deprecated |
|
1639 | + unset($object->nom); // ->name already defined and nom deprecated |
|
1640 | 1640 | |
1641 | 1641 | unset($object->total_ht); |
1642 | 1642 | unset($object->total_tva); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Protection to avoid direct call of template |
19 | -if (empty($conf) || ! is_object($conf)) |
|
19 | +if (empty($conf) || !is_object($conf)) |
|
20 | 20 | { |
21 | 21 | print "Error, template page can't be called as URL"; |
22 | 22 | exit; |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | print '</td>'; |
29 | 29 | print '<td>'; |
30 | 30 | |
31 | -$listsalesrepresentatives=$object->getSalesRepresentatives($user); |
|
32 | -$nbofsalesrepresentative=count($listsalesrepresentatives); |
|
31 | +$listsalesrepresentatives = $object->getSalesRepresentatives($user); |
|
32 | +$nbofsalesrepresentative = count($listsalesrepresentatives); |
|
33 | 33 | if ($nbofsalesrepresentative > 0) |
34 | 34 | { |
35 | - $userstatic=new User($db); |
|
36 | - foreach($listsalesrepresentatives as $val) |
|
35 | + $userstatic = new User($db); |
|
36 | + foreach ($listsalesrepresentatives as $val) |
|
37 | 37 | { |
38 | - $userstatic->id=$val['id']; |
|
39 | - $userstatic->login=$val['login']; |
|
40 | - $userstatic->lastname=$val['lastname']; |
|
41 | - $userstatic->firstname=$val['firstname']; |
|
42 | - $userstatic->statut=$val['statut']; |
|
43 | - $userstatic->photo=$val['photo']; |
|
44 | - $userstatic->email=$val['email']; |
|
45 | - $userstatic->entity=$val['entity']; |
|
38 | + $userstatic->id = $val['id']; |
|
39 | + $userstatic->login = $val['login']; |
|
40 | + $userstatic->lastname = $val['lastname']; |
|
41 | + $userstatic->firstname = $val['firstname']; |
|
42 | + $userstatic->statut = $val['statut']; |
|
43 | + $userstatic->photo = $val['photo']; |
|
44 | + $userstatic->email = $val['email']; |
|
45 | + $userstatic->entity = $val['entity']; |
|
46 | 46 | print $userstatic->getNomUrl(-1); |
47 | 47 | print ' '; |
48 | 48 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | |
19 | 19 | // Protection to avoid direct call of template |
20 | -if (empty($conf) || ! is_object($conf)) |
|
20 | +if (empty($conf) || !is_object($conf)) |
|
21 | 21 | { |
22 | 22 | print "Error, template page can't be called as URL"; |
23 | 23 | exit; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | <tr> |
61 | 61 | <td><span class="fieldrequired"><?php echo $langs->trans('ThirdPartyName'); ?></span></td> |
62 | 62 | <td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td> |
63 | - <?php if (! empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
63 | + <?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
64 | 64 | <td><?php echo $langs->trans('Prefix'); ?></td> |
65 | 65 | <td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td> |
66 | 66 | <?php } ?> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </tr> |
104 | 104 | <?php } }?> |
105 | 105 | |
106 | -<?php if (! empty($conf->barcode->enabled)) { ?> |
|
106 | +<?php if (!empty($conf->barcode->enabled)) { ?> |
|
107 | 107 | <tr> |
108 | 108 | <td><?php echo $langs->trans('Gencod'); ?></td> |
109 | 109 | <td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | </tr> |
141 | 141 | |
142 | 142 | <tr> |
143 | - <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?></td> |
|
143 | + <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?></td> |
|
144 | 144 | <td><input type="text" name="email" size="32" value="<?php echo $this->control->tpl['email']; ?>"></td> |
145 | 145 | <td><?php echo $langs->trans('Web'); ?></td> |
146 | 146 | <td><input type="text" name="url" size="32" value="<?php echo $this->control->tpl['url']; ?>"></td> |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | </tr> |
153 | 153 | |
154 | 154 | <?php |
155 | -for ($i=1; $i<=4; $i++) { |
|
156 | - if ($this->control->tpl['langprofid'.$i]!='-') { |
|
157 | - if ($i==1 || $i==3) echo '<tr>'; |
|
155 | +for ($i = 1; $i <= 4; $i++) { |
|
156 | + if ($this->control->tpl['langprofid'.$i] != '-') { |
|
157 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
158 | 158 | echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; |
159 | 159 | echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>'; |
160 | - if ($i==2 || $i==4) echo '</tr>'; |
|
160 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
161 | 161 | } else { |
162 | - if ($i==1 || $i==3) echo '<tr>'; |
|
162 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
163 | 163 | echo '<td> </td>'; |
164 | 164 | echo '<td> </td>'; |
165 | - if ($i==2 || $i==4) echo '</tr>'; |
|
165 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | ?> |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | <td><?php echo $this->control->tpl['select_workforce']; echo $this->control->tpl['info_admin']; ?></td> |
180 | 180 | </tr> |
181 | 181 | |
182 | -<?php if (! empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
182 | +<?php if (!empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
183 | 183 | <tr> |
184 | 184 | <td><?php echo $langs->trans("DefaultLang"); ?></td> |
185 | 185 | <td colspan="3"><?php echo $this->control->tpl['select_lang']; ?></td> |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | <td class="nowrap"><?php echo $this->control->tpl['tva_intra']; ?></td> |
194 | 194 | </tr> |
195 | 195 | |
196 | -<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
196 | +<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
197 | 197 | |
198 | 198 | <?php if ($user->rights->societe->client->voir) { ?> |
199 | 199 | <tr> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Protection to avoid direct call of template |
19 | -if (empty($conf) || ! is_object($conf)) |
|
19 | +if (empty($conf) || !is_object($conf)) |
|
20 | 20 | { |
21 | 21 | print "Error, template page can't be called as URL"; |
22 | 22 | exit; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $head = societe_prepare_head($soc); |
34 | 34 | |
35 | -dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); |
|
35 | +dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); |
|
36 | 36 | |
37 | 37 | ?> |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | <td colspan="3"><?php echo $this->control->tpl['showrefnav']; ?></td> |
48 | 48 | </tr> |
49 | 49 | |
50 | -<?php if (! empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
50 | +<?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
51 | 51 | <tr> |
52 | 52 | <td><?php echo $langs->trans('Prefix'); ?></td> |
53 | 53 | <td colspan="3"><?php echo $this->control->tpl['prefix_comm']; ?></td> |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | </tr> |
77 | 77 | <?php } ?> |
78 | 78 | |
79 | -<?php if (! empty($conf->barcode->enabled)) { ?> |
|
79 | +<?php if (!empty($conf->barcode->enabled)) { ?> |
|
80 | 80 | <tr> |
81 | 81 | <td><?php echo $langs->trans('Gencod'); ?></td> |
82 | 82 | <td colspan="3"><?php echo $this->control->tpl['barcode']; ?></td> |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | </tr> |
121 | 121 | |
122 | 122 | <?php |
123 | -for ($i=1; $i<=4; $i++) { |
|
124 | - if ($this->control->tpl['langprofid'.$i]!='-') { |
|
125 | - if ($i==1 || $i==3) echo '<tr>'; |
|
123 | +for ($i = 1; $i <= 4; $i++) { |
|
124 | + if ($this->control->tpl['langprofid'.$i] != '-') { |
|
125 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
126 | 126 | echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; |
127 | 127 | echo '<td>'.$this->control->tpl['profid'.$i]; |
128 | 128 | if ($this->control->tpl['profid'.$i]) { |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | else echo ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; |
131 | 131 | } |
132 | 132 | echo '</td>'; |
133 | - if ($i==2 || $i==4) echo '</tr>'; |
|
133 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
134 | 134 | } else { |
135 | - if ($i==1 || $i==3) echo '<tr>'; |
|
135 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
136 | 136 | echo '<td> </td>'; |
137 | 137 | echo '<td> </td>'; |
138 | - if ($i==2 || $i==4) echo '</tr>'; |
|
138 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | ?> |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | <td><?php echo $this->control->tpl['tva_intra']; ?></td> |
148 | 148 | </tr> |
149 | 149 | |
150 | -<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
150 | +<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
151 | 151 | |
152 | 152 | <tr> |
153 | 153 | <td><?php echo $langs->trans('Capital'); ?></td> |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | <td><?php echo $this->control->tpl['effectif']; ?></td> |
172 | 172 | </tr> |
173 | 173 | |
174 | -<?php if (! empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
174 | +<?php if (!empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
175 | 175 | <tr> |
176 | 176 | <td><?php echo $langs->trans("DefaultLang"); ?></td> |
177 | 177 | <td colspan="3"><?php echo $this->control->tpl['default_lang']; ?></td> |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | </tr> |
226 | 226 | </table> |
227 | 227 | </td> |
228 | - <td colspan="3"><?php echo $this->control->tpl['sales_representatives']; ?></td> |
|
228 | + <td colspan="3"><?php echo $this->control->tpl['sales_representatives']; ?></td> |
|
229 | 229 | </tr> |
230 | 230 | |
231 | -<?php if (! empty($conf->adherent->enabled)) { ?> |
|
231 | +<?php if (!empty($conf->adherent->enabled)) { ?> |
|
232 | 232 | <tr> |
233 | 233 | <td width="25%" valign="top"><?php echo $langs->trans("LinkedToDolibarrMember"); ?></td> |
234 | 234 | <td colspan="3"><?php echo $this->control->tpl['linked_member']; ?></td> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | <?php if ($user->rights->societe->supprimer) { ?> |
248 | 248 | <?php if ($conf->use_javascript_ajax) { ?> |
249 | 249 | <span id="action-delete" class="butActionDelete"><?php echo $langs->trans('Delete'); ?></span> |
250 | - <?php } else { ?> |
|
250 | + <?php } else { ?> |
|
251 | 251 | <a class="butActionDelete" href="<?php echo $_SERVER["PHP_SELF"].'?socid='.$this->control->tpl['id'].'&action=delete&canvas='.$canvas; ?>"><?php echo $langs->trans('Delete'); ?></a> |
252 | 252 | <?php } ?> |
253 | 253 | <?php } ?> |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | /* |
263 | 263 | * Documents generes |
264 | 264 | */ |
265 | -$filedir=$conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; |
|
266 | -$urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; |
|
267 | -$genallowed=$user->rights->societe->lire; |
|
268 | -$delallowed=$user->rights->societe->creer; |
|
265 | +$filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; |
|
266 | +$urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; |
|
267 | +$genallowed = $user->rights->societe->lire; |
|
268 | +$delallowed = $user->rights->societe->creer; |
|
269 | 269 | |
270 | -print $formfile->showdocuments('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang); |
|
270 | +print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); |
|
271 | 271 | ?> |
272 | 272 | |
273 | 273 | </td> |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | |
280 | 280 | <?php |
281 | 281 | // Subsidiaries list |
282 | -$result=show_subsidiaries($conf,$langs,$db,$soc); |
|
282 | +$result = show_subsidiaries($conf, $langs, $db, $soc); |
|
283 | 283 | |
284 | 284 | // Contacts list |
285 | -$result=show_contacts($conf,$langs,$db,$soc); |
|
285 | +$result = show_contacts($conf, $langs, $db, $soc); |
|
286 | 286 | |
287 | 287 | // Projects list |
288 | -$result=show_projects($conf,$langs,$db,$soc); |
|
288 | +$result = show_projects($conf, $langs, $db, $soc); |
|
289 | 289 | ?> |
290 | 290 | |
291 | 291 | <!-- END PHP TEMPLATE --> |
292 | 292 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | |
19 | 19 | // Protection to avoid direct call of template |
20 | -if (empty($conf) || ! is_object($conf)) |
|
20 | +if (empty($conf) || !is_object($conf)) |
|
21 | 21 | { |
22 | 22 | print "Error, template page can't be called as URL"; |
23 | 23 | exit; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | <td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td> |
54 | 54 | </tr> |
55 | 55 | |
56 | -<?php if (! empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
56 | +<?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
57 | 57 | <tr> |
58 | 58 | <td><?php echo $langs->trans("Prefix"); ?></td> |
59 | 59 | <td colspan="3"> |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | </tr> |
119 | 119 | <?php } }?> |
120 | 120 | |
121 | -<?php if (! empty($conf->barcode->enabled)) { ?> |
|
121 | +<?php if (!empty($conf->barcode->enabled)) { ?> |
|
122 | 122 | <tr> |
123 | 123 | <td><?php echo $langs->trans('Gencod'); ?></td> |
124 | 124 | <td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td> |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | </tr> |
156 | 156 | |
157 | 157 | <tr> |
158 | - <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?></td> |
|
158 | + <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?></td> |
|
159 | 159 | <td><input type="text" name="email" size="32" value="<?php echo $this->control->tpl['email']; ?>"></td> |
160 | 160 | <td><?php echo $langs->trans('Web'); ?></td> |
161 | 161 | <td><input type="text" name="url" size="32" value="<?php echo $this->control->tpl['url']; ?>"></td> |
162 | 162 | </tr> |
163 | 163 | |
164 | 164 | <?php |
165 | -for ($i=1; $i<=4; $i++) { |
|
166 | - if ($this->control->tpl['langprofid'.$i]!='-') { |
|
167 | - if ($i==1 || $i==3) echo '<tr>'; |
|
165 | +for ($i = 1; $i <= 4; $i++) { |
|
166 | + if ($this->control->tpl['langprofid'.$i] != '-') { |
|
167 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
168 | 168 | echo '<td>'.$this->control->tpl['langprofid'.$i].'</td>'; |
169 | 169 | echo '<td>'.$this->control->tpl['showprofid'.$i].'</td>'; |
170 | - if ($i==2 || $i==4) echo '</tr>'; |
|
170 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
171 | 171 | } else { |
172 | - if ($i==1 || $i==3) echo '<tr>'; |
|
172 | + if ($i == 1 || $i == 3) echo '<tr>'; |
|
173 | 173 | echo '<td> </td>'; |
174 | 174 | echo '<td> </td>'; |
175 | - if ($i==2 || $i==4) echo '</tr>'; |
|
175 | + if ($i == 2 || $i == 4) echo '</tr>'; |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | ?> |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | <td><?php echo $this->control->tpl['select_workforce']; echo $this->control->tpl['info_admin']; ?></td> |
202 | 202 | </tr> |
203 | 203 | |
204 | -<?php if (! empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
204 | +<?php if (!empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
205 | 205 | <tr> |
206 | 206 | <td><?php echo $langs->trans("DefaultLang"); ?></td> |
207 | 207 | <td colspan="3"><?php echo $this->control->tpl['select_lang']; ?></td> |
208 | 208 | </tr> |
209 | 209 | <?php } ?> |
210 | 210 | |
211 | -<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
211 | +<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
212 | 212 | |
213 | 213 | </table> |
214 | 214 | <br> |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function __construct($db, $dirmodule, $targetmodule, $canvas, $card) |
42 | 42 | { |
43 | - $this->db = $db; |
|
44 | - $this->dirmodule = $dirmodule; |
|
45 | - $this->targetmodule = $targetmodule; |
|
46 | - $this->canvas = $canvas; |
|
47 | - $this->card = $card; |
|
43 | + $this->db = $db; |
|
44 | + $this->dirmodule = $dirmodule; |
|
45 | + $this->targetmodule = $targetmodule; |
|
46 | + $this->canvas = $canvas; |
|
47 | + $this->card = $card; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | { |
58 | 58 | global $langs; |
59 | 59 | |
60 | - $out=''; |
|
60 | + $out = ''; |
|
61 | 61 | |
62 | - if ($action == 'view') $out.= $langs->trans("ThirdParty"); |
|
63 | - if ($action == 'edit') $out.= $langs->trans("EditCompany"); |
|
64 | - if ($action == 'create') $out.= $langs->trans("NewCompany"); |
|
62 | + if ($action == 'view') $out .= $langs->trans("ThirdParty"); |
|
63 | + if ($action == 'edit') $out .= $langs->trans("EditCompany"); |
|
64 | + if ($action == 'create') $out .= $langs->trans("NewCompany"); |
|
65 | 65 | |
66 | 66 | return $out; |
67 | 67 | } |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | * @param string $ref Ref of object |
77 | 77 | * @return void |
78 | 78 | */ |
79 | - function assign_values(&$action, $id=0, $ref='') |
|
79 | + function assign_values(&$action, $id = 0, $ref = '') |
|
80 | 80 | { |
81 | 81 | // phpcs:enable |
82 | 82 | global $conf, $langs, $user, $mysoc; |
83 | 83 | global $form, $formadmin, $formcompany; |
84 | 84 | |
85 | - $ret = $this->getObject($id,$ref); |
|
85 | + $ret = $this->getObject($id, $ref); |
|
86 | 86 | |
87 | 87 | parent::assign_values($action); |
88 | 88 | |
89 | 89 | $this->tpl['title'] = load_fiche_titre($this->getTitle($action)); |
90 | 90 | |
91 | - $this->tpl['profid1'] = $this->object->idprof1; |
|
91 | + $this->tpl['profid1'] = $this->object->idprof1; |
|
92 | 92 | $this->tpl['profid2'] = $this->object->idprof2; |
93 | 93 | $this->tpl['profid3'] = $this->object->idprof3; |
94 | 94 | $this->tpl['profid4'] = $this->object->idprof4; |
@@ -96,46 +96,46 @@ discard block |
||
96 | 96 | if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLEVATCHECK)) |
97 | 97 | { |
98 | 98 | $js = "\n"; |
99 | - $js.= '<script language="JavaScript" type="text/javascript">'; |
|
100 | - $js.= "function CheckVAT(a) {\n"; |
|
101 | - $js.= "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n"; |
|
102 | - $js.= "}\n"; |
|
103 | - $js.= '</script>'; |
|
104 | - $js.= "\n"; |
|
99 | + $js .= '<script language="JavaScript" type="text/javascript">'; |
|
100 | + $js .= "function CheckVAT(a) {\n"; |
|
101 | + $js .= "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,230);\n"; |
|
102 | + $js .= "}\n"; |
|
103 | + $js .= '</script>'; |
|
104 | + $js .= "\n"; |
|
105 | 105 | $this->tpl['js_checkVatPopup'] = $js; |
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($action == 'create' || $action == 'edit') |
109 | 109 | { |
110 | - for ($i=1; $i<=4; $i++) |
|
110 | + for ($i = 1; $i <= 4; $i++) |
|
111 | 111 | { |
112 | - $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->country_code); |
|
113 | - $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i,'idprof'.$i,$this->tpl['profid'.$i],$this->object->country_code); |
|
112 | + $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code); |
|
113 | + $this->tpl['showprofid'.$i] = $formcompany->get_input_id_prof($i, 'idprof'.$i, $this->tpl['profid'.$i], $this->object->country_code); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Type |
117 | - $this->tpl['select_companytype'] = $form->selectarray("typent_id",$formcompany->typent_array(0), $this->object->typent_id); |
|
117 | + $this->tpl['select_companytype'] = $form->selectarray("typent_id", $formcompany->typent_array(0), $this->object->typent_id); |
|
118 | 118 | |
119 | 119 | // Juridical Status |
120 | - $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code,$this->object->country_code); |
|
120 | + $this->tpl['select_juridicalstatus'] = $formcompany->select_juridicalstatus($this->object->forme_juridique_code, $this->object->country_code); |
|
121 | 121 | |
122 | 122 | // Workforce |
123 | - $this->tpl['select_workforce'] = $form->selectarray("effectif_id",$formcompany->effectif_array(0), $this->object->effectif_id); |
|
123 | + $this->tpl['select_workforce'] = $form->selectarray("effectif_id", $formcompany->effectif_array(0), $this->object->effectif_id); |
|
124 | 124 | |
125 | 125 | // VAT intra |
126 | - $s='<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; |
|
126 | + $s = '<input type="text" class="flat" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; |
|
127 | 127 | if (empty($conf->global->MAIN_DISABLEVATCHECK)) |
128 | 128 | { |
129 | - $s.=' '; |
|
129 | + $s .= ' '; |
|
130 | 130 | |
131 | 131 | if ($conf->use_javascript_ajax) |
132 | 132 | { |
133 | - $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
|
134 | - $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); |
|
133 | + $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
|
134 | + $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->trans("VATIntraCheck")), 1); |
|
135 | 135 | } |
136 | 136 | else |
137 | 137 | { |
138 | - $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; |
|
138 | + $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>'; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | else |
@@ -148,33 +148,33 @@ discard block |
||
148 | 148 | // Confirm delete third party |
149 | 149 | if ($action == 'delete') |
150 | 150 | { |
151 | - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,"1,action-delete"); |
|
151 | + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "1,action-delete"); |
|
152 | 152 | } |
153 | 153 | |
154 | - for ($i=1; $i<=4; $i++) |
|
154 | + for ($i = 1; $i <= 4; $i++) |
|
155 | 155 | { |
156 | - $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i,$this->object->country_code); |
|
157 | - $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i,$this->object); |
|
158 | - $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i,$this->object); |
|
156 | + $this->tpl['langprofid'.$i] = $langs->transcountry('ProfId'.$i, $this->object->country_code); |
|
157 | + $this->tpl['checkprofid'.$i] = $this->object->id_prof_check($i, $this->object); |
|
158 | + $this->tpl['urlprofid'.$i] = $this->object->id_prof_url($i, $this->object); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // TVA intra |
162 | 162 | if ($this->object->tva_intra) |
163 | 163 | { |
164 | - $s=$this->object->tva_intra; |
|
165 | - $s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; |
|
164 | + $s = $this->object->tva_intra; |
|
165 | + $s .= '<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$this->object->tva_intra.'">'; |
|
166 | 166 | if (empty($conf->global->MAIN_DISABLEVATCHECK)) |
167 | 167 | { |
168 | - $s.=' '; |
|
168 | + $s .= ' '; |
|
169 | 169 | |
170 | 170 | if ($conf->use_javascript_ajax) |
171 | 171 | { |
172 | - $s.='<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
|
173 | - $this->tpl['tva_intra'] = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); |
|
172 | + $s .= '<a href="#" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
|
173 | + $this->tpl['tva_intra'] = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->trans("VATIntraCheck")), 1); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL",$this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; |
|
177 | + $this->tpl['tva_intra'] = $s.'<a href="'.$langs->transcountry("VATIntraCheckURL", $this->object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>'; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | else |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | { |
193 | 193 | $socm = new Societe($this->db); |
194 | 194 | $socm->fetch($this->object->parent); |
195 | - $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); |
|
196 | - $this->tpl['parent_company'].= ($socm->town ? ' - ' . $socm->town : ''); |
|
195 | + $this->tpl['parent_company'] = $socm->getNomUrl(1).' '.($socm->code_client ? "(".$socm->code_client.")" : ""); |
|
196 | + $this->tpl['parent_company'] .= ($socm->town ? ' - '.$socm->town : ''); |
|
197 | 197 | } |
198 | 198 | else |
199 | 199 | { |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $dbt_select Field name for select if not rowid. (optional) |
216 | 216 | * @return int 1 |
217 | 217 | */ |
218 | - function restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') |
|
218 | + function restrictedArea($user, $features = 'societe', $objectid = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') |
|
219 | 219 | { |
220 | - return restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); |
|
220 | + return restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); |
|
221 | 221 | } |
222 | 222 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @var string Error code (or message) |
47 | 47 | */ |
48 | - public $error=''; |
|
48 | + public $error = ''; |
|
49 | 49 | |
50 | 50 | |
51 | 51 | /** |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * @param ref $ref Object ref |
62 | 62 | * @return object Object loaded |
63 | 63 | */ |
64 | - protected function getObject($id,$ref='') |
|
64 | + protected function getObject($id, $ref = '') |
|
65 | 65 | { |
66 | 66 | //$ret = $this->getInstanceDao(); |
67 | 67 | |
68 | 68 | $object = new Societe($this->db); |
69 | - if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref); |
|
69 | + if (!empty($id) || !empty($ref)) $object->fetch($id, $ref); |
|
70 | 70 | $this->object = $object; |
71 | 71 | } |
72 | 72 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $ref Ref of object |
80 | 80 | * @return void |
81 | 81 | */ |
82 | - function assign_values(&$action, $id=0, $ref='') |
|
82 | + function assign_values(&$action, $id = 0, $ref = '') |
|
83 | 83 | { |
84 | 84 | // phpcs:enable |
85 | 85 | global $conf, $langs, $user, $mysoc, $canvas; |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | |
88 | 88 | if ($action == 'add' || $action == 'update') $this->assign_post($action); |
89 | 89 | |
90 | - if ($_GET["type"]=='f') { $this->object->fournisseur=1; } |
|
91 | - if ($_GET["type"]=='c') { $this->object->client=1; } |
|
92 | - if ($_GET["type"]=='p') { $this->object->client=2; } |
|
93 | - if ($_GET["type"]=='cp') { $this->object->client=3; } |
|
94 | - if ($_REQUEST["private"]==1) { $this->object->particulier=1; } |
|
90 | + if ($_GET["type"] == 'f') { $this->object->fournisseur = 1; } |
|
91 | + if ($_GET["type"] == 'c') { $this->object->client = 1; } |
|
92 | + if ($_GET["type"] == 'p') { $this->object->client = 2; } |
|
93 | + if ($_GET["type"] == 'cp') { $this->object->client = 3; } |
|
94 | + if ($_REQUEST["private"] == 1) { $this->object->particulier = 1; } |
|
95 | 95 | |
96 | - foreach($this->object as $key => $value) |
|
96 | + foreach ($this->object as $key => $value) |
|
97 | 97 | { |
98 | 98 | $this->tpl[$key] = $value; |
99 | 99 | } |
100 | 100 | |
101 | - $this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors); |
|
102 | - if (is_array($GLOBALS['errors'])) $this->tpl['error'] = get_htmloutput_mesg('',$GLOBALS['errors'],'error'); |
|
101 | + $this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors); |
|
102 | + if (is_array($GLOBALS['errors'])) $this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error'); |
|
103 | 103 | |
104 | 104 | if ($action == 'create') |
105 | 105 | { |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | // Load object modCodeClient |
143 | - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); |
|
143 | + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); |
|
144 | 144 | if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') |
145 | 145 | { |
146 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
146 | + $module = substr($module, 0, dol_strlen($module) - 4); |
|
147 | 147 | } |
148 | - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); |
|
148 | + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); |
|
149 | 149 | foreach ($dirsociete as $dirroot) |
150 | 150 | { |
151 | - $res=dol_include_once($dirroot.$module.'.php'); |
|
151 | + $res = dol_include_once($dirroot.$module.'.php'); |
|
152 | 152 | if ($res) break; |
153 | 153 | } |
154 | 154 | $modCodeClient = new $module($db); |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | |
167 | 167 | // Customer |
168 | 168 | $this->tpl['customercode'] = $this->object->code_client; |
169 | - if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0); |
|
169 | + if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0); |
|
170 | 170 | $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable(); |
171 | - $s=$modCodeClient->getToolTip($langs,$this->object,0); |
|
172 | - $this->tpl['help_customercode'] = $form->textwithpicto('',$s,1); |
|
171 | + $s = $modCodeClient->getToolTip($langs, $this->object, 0); |
|
172 | + $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1); |
|
173 | 173 | |
174 | - if (! empty($conf->fournisseur->enabled)) |
|
174 | + if (!empty($conf->fournisseur->enabled)) |
|
175 | 175 | { |
176 | 176 | $this->tpl['supplier_enabled'] = 1; |
177 | 177 | |
178 | 178 | // Load object modCodeFournisseur |
179 | - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; |
|
179 | + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; |
|
180 | 180 | if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') |
181 | 181 | { |
182 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
182 | + $module = substr($module, 0, dol_strlen($module) - 4); |
|
183 | 183 | } |
184 | - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); |
|
184 | + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); |
|
185 | 185 | foreach ($dirsociete as $dirroot) |
186 | 186 | { |
187 | - $res=dol_include_once($dirroot.$module.'.php'); |
|
187 | + $res = dol_include_once($dirroot.$module.'.php'); |
|
188 | 188 | if ($res) break; |
189 | 189 | } |
190 | 190 | $modCodeFournisseur = new $module; |
@@ -193,69 +193,69 @@ discard block |
||
193 | 193 | if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed(); |
194 | 194 | |
195 | 195 | // Supplier |
196 | - $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1); |
|
196 | + $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1); |
|
197 | 197 | $this->tpl['suppliercode'] = $this->object->code_fournisseur; |
198 | - if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1); |
|
198 | + if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1); |
|
199 | 199 | $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable(); |
200 | - $s=$modCodeFournisseur->getToolTip($langs,$this->object,1); |
|
201 | - $this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1); |
|
200 | + $s = $modCodeFournisseur->getToolTip($langs, $this->object, 1); |
|
201 | + $this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1); |
|
202 | 202 | |
203 | 203 | $this->object->LoadSupplierCateg(); |
204 | 204 | $this->tpl['suppliercategory'] = $this->object->SupplierCategories; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // Zip |
208 | - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip,'zipcode',array('town','selectcountry_id','state_id'),6); |
|
208 | + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); |
|
209 | 209 | |
210 | 210 | // Town |
211 | - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town,'town',array('zipcode','selectcountry_id','state_id')); |
|
211 | + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); |
|
212 | 212 | |
213 | 213 | // Country |
214 | 214 | $this->object->country_id = ($this->object->country_id ? $this->object->country_id : $mysoc->country_id); |
215 | 215 | $this->object->country_code = ($this->object->country_code ? $this->object->country_code : $mysoc->country_code); |
216 | - $this->tpl['select_country'] = $form->select_country($this->object->country_id,'country_id'); |
|
216 | + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); |
|
217 | 217 | $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; |
218 | 218 | |
219 | - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
219 | + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
220 | 220 | |
221 | 221 | // State |
222 | - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id,$this->object->country_code); |
|
222 | + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); |
|
223 | 223 | else $this->tpl['select_state'] = $countrynotdefined; |
224 | 224 | |
225 | 225 | // Language |
226 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); |
|
226 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT), 'default_lang', 0, 0, 1); |
|
227 | 227 | |
228 | 228 | // VAT |
229 | - $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation |
|
229 | + $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1); // Assujeti par defaut en creation |
|
230 | 230 | |
231 | 231 | // Select users |
232 | 232 | $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); |
233 | 233 | |
234 | 234 | // Local Tax |
235 | 235 | // TODO mettre dans une classe propre au pays |
236 | - if($mysoc->country_code=='ES') |
|
236 | + if ($mysoc->country_code == 'ES') |
|
237 | 237 | { |
238 | 238 | $this->tpl['localtax'] = ''; |
239 | 239 | |
240 | - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") |
|
240 | + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") |
|
241 | 241 | { |
242 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>'; |
|
243 | - $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1); |
|
244 | - $this->tpl['localtax'].= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>'; |
|
245 | - $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1); |
|
246 | - $this->tpl['localtax'].= '</td></tr>'; |
|
242 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>'; |
|
243 | + $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1); |
|
244 | + $this->tpl['localtax'] .= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>'; |
|
245 | + $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1); |
|
246 | + $this->tpl['localtax'] .= '</td></tr>'; |
|
247 | 247 | } |
248 | - elseif($mysoc->localtax1_assuj=="1") |
|
248 | + elseif ($mysoc->localtax1_assuj == "1") |
|
249 | 249 | { |
250 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">'; |
|
251 | - $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1); |
|
252 | - $this->tpl['localtax'].= '</td><tr>'; |
|
250 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">'; |
|
251 | + $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1); |
|
252 | + $this->tpl['localtax'] .= '</td><tr>'; |
|
253 | 253 | } |
254 | - elseif($mysoc->localtax2_assuj=="1") |
|
254 | + elseif ($mysoc->localtax2_assuj == "1") |
|
255 | 255 | { |
256 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">'; |
|
257 | - $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1); |
|
258 | - $this->tpl['localtax'].= '</td><tr>'; |
|
256 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">'; |
|
257 | + $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1); |
|
258 | + $this->tpl['localtax'] .= '</td><tr>'; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
@@ -263,78 +263,78 @@ discard block |
||
263 | 263 | { |
264 | 264 | $head = societe_prepare_head($this->object); |
265 | 265 | |
266 | - $this->tpl['showhead']=dol_get_fiche_head($head, 'card', '', 0, 'company'); |
|
267 | - $this->tpl['showend']=dol_get_fiche_end(); |
|
266 | + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', '', 0, 'company'); |
|
267 | + $this->tpl['showend'] = dol_get_fiche_end(); |
|
268 | 268 | |
269 | - $this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom'); |
|
269 | + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
270 | 270 | |
271 | 271 | $this->tpl['checkcustomercode'] = $this->object->check_codeclient(); |
272 | 272 | $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur(); |
273 | - $this->tpl['address'] = dol_nl2br($this->object->address); |
|
273 | + $this->tpl['address'] = dol_nl2br($this->object->address); |
|
274 | 274 | |
275 | - $img=picto_from_langcode($this->object->country_code); |
|
276 | - if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->country,$langs->trans("CountryIsInEEC"),1,0); |
|
277 | - $this->tpl['country'] = ($img?$img.' ':'').$this->object->country; |
|
275 | + $img = picto_from_langcode($this->object->country_code); |
|
276 | + if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img ? $img.' ' : '').$this->object->country, $langs->trans("CountryIsInEEC"), 1, 0); |
|
277 | + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; |
|
278 | 278 | |
279 | - $this->tpl['phone'] = dol_print_phone($this->object->phone,$this->object->country_code,0,$this->object->id,'AC_TEL'); |
|
280 | - $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->country_code,0,$this->object->id,'AC_FAX'); |
|
281 | - $this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL'); |
|
279 | + $this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); |
|
280 | + $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); |
|
281 | + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); |
|
282 | 282 | $this->tpl['url'] = dol_print_url($this->object->url); |
283 | 283 | |
284 | - $this->tpl['tva_assuj'] = yn($this->object->tva_assuj); |
|
284 | + $this->tpl['tva_assuj'] = yn($this->object->tva_assuj); |
|
285 | 285 | |
286 | 286 | // Third party type |
287 | 287 | $arr = $formcompany->typent_array(1); |
288 | 288 | $this->tpl['typent'] = $arr[$this->object->typent_code]; |
289 | 289 | |
290 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
290 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
291 | 291 | { |
292 | 292 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
293 | 293 | //$s=picto_from_langcode($this->default_lang); |
294 | 294 | //print ($s?$s.' ':''); |
295 | 295 | $langs->load("languages"); |
296 | - $this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):''); |
|
296 | + $this->tpl['default_lang'] = ($this->default_lang ? $langs->trans('Language_'.$this->object->default_lang) : ''); |
|
297 | 297 | } |
298 | 298 | |
299 | - $this->tpl['image_edit'] = img_edit(); |
|
299 | + $this->tpl['image_edit'] = img_edit(); |
|
300 | 300 | |
301 | - $this->tpl['display_rib'] = $this->object->display_rib(); |
|
301 | + $this->tpl['display_rib'] = $this->object->display_rib(); |
|
302 | 302 | |
303 | 303 | // Sales representatives |
304 | 304 | $this->tpl['sales_representatives'] = ''; |
305 | - $listsalesrepresentatives=$this->object->getSalesRepresentatives($user); |
|
306 | - $nbofsalesrepresentative=count($listsalesrepresentatives); |
|
305 | + $listsalesrepresentatives = $this->object->getSalesRepresentatives($user); |
|
306 | + $nbofsalesrepresentative = count($listsalesrepresentatives); |
|
307 | 307 | if ($nbofsalesrepresentative > 3) // We print only number |
308 | 308 | { |
309 | - $this->tpl['sales_representatives'].= '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->id.'">'; |
|
310 | - $this->tpl['sales_representatives'].= $nbofsalesrepresentative; |
|
311 | - $this->tpl['sales_representatives'].= '</a>'; |
|
309 | + $this->tpl['sales_representatives'] .= '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$this->object->id.'">'; |
|
310 | + $this->tpl['sales_representatives'] .= $nbofsalesrepresentative; |
|
311 | + $this->tpl['sales_representatives'] .= '</a>'; |
|
312 | 312 | } |
313 | 313 | else if ($nbofsalesrepresentative > 0) |
314 | 314 | { |
315 | - $userstatic=new User($this->db); |
|
316 | - $i=0; |
|
317 | - foreach($listsalesrepresentatives as $val) |
|
315 | + $userstatic = new User($this->db); |
|
316 | + $i = 0; |
|
317 | + foreach ($listsalesrepresentatives as $val) |
|
318 | 318 | { |
319 | - $userstatic->id=$val['id']; |
|
320 | - $userstatic->lastname=$val['name']; |
|
321 | - $userstatic->firstname=$val['firstname']; |
|
322 | - $this->tpl['sales_representatives'].= $userstatic->getNomUrl(1); |
|
319 | + $userstatic->id = $val['id']; |
|
320 | + $userstatic->lastname = $val['name']; |
|
321 | + $userstatic->firstname = $val['firstname']; |
|
322 | + $this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1); |
|
323 | 323 | $i++; |
324 | - if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'].= ', '; |
|
324 | + if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'] .= ', '; |
|
325 | 325 | } |
326 | 326 | } |
327 | - else $this->tpl['sales_representatives'].= $langs->trans("NoSalesRepresentativeAffected"); |
|
327 | + else $this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected"); |
|
328 | 328 | |
329 | 329 | // Linked member |
330 | - if (! empty($conf->adherent->enabled)) |
|
330 | + if (!empty($conf->adherent->enabled)) |
|
331 | 331 | { |
332 | 332 | $langs->load("members"); |
333 | - $adh=new Adherent($this->db); |
|
334 | - $result=$adh->fetch('','',$this->object->id); |
|
333 | + $adh = new Adherent($this->db); |
|
334 | + $result = $adh->fetch('', '', $this->object->id); |
|
335 | 335 | if ($result > 0) |
336 | 336 | { |
337 | - $adh->ref=$adh->getFullName($langs); |
|
337 | + $adh->ref = $adh->getFullName($langs); |
|
338 | 338 | $this->tpl['linked_member'] = $adh->getNomUrl(1); |
339 | 339 | } |
340 | 340 | else |
@@ -345,26 +345,26 @@ discard block |
||
345 | 345 | |
346 | 346 | // Local Tax |
347 | 347 | // TODO mettre dans une classe propre au pays |
348 | - if($mysoc->country_code=='ES') |
|
348 | + if ($mysoc->country_code == 'ES') |
|
349 | 349 | { |
350 | 350 | $this->tpl['localtax'] = ''; |
351 | 351 | |
352 | - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") |
|
352 | + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") |
|
353 | 353 | { |
354 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; |
|
355 | - $this->tpl['localtax'].= '<td>'.yn($this->object->localtax1_assuj).'</td>'; |
|
356 | - $this->tpl['localtax'].= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; |
|
357 | - $this->tpl['localtax'].= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>'; |
|
354 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; |
|
355 | + $this->tpl['localtax'] .= '<td>'.yn($this->object->localtax1_assuj).'</td>'; |
|
356 | + $this->tpl['localtax'] .= '<td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; |
|
357 | + $this->tpl['localtax'] .= '<td>'.yn($this->object->localtax2_assuj).'</td></tr>'; |
|
358 | 358 | } |
359 | - elseif($mysoc->localtax1_assuj=="1") |
|
359 | + elseif ($mysoc->localtax1_assuj == "1") |
|
360 | 360 | { |
361 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; |
|
362 | - $this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>'; |
|
361 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td>'; |
|
362 | + $this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax1_assuj).'</td></tr>'; |
|
363 | 363 | } |
364 | - elseif($mysoc->localtax2_assuj=="1") |
|
364 | + elseif ($mysoc->localtax2_assuj == "1") |
|
365 | 365 | { |
366 | - $this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; |
|
367 | - $this->tpl['localtax'].= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>'; |
|
366 | + $this->tpl['localtax'] .= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td>'; |
|
367 | + $this->tpl['localtax'] .= '<td colspan="3">'.yn($this->object->localtax2_assuj).'</td></tr>'; |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
@@ -382,47 +382,47 @@ discard block |
||
382 | 382 | // phpcs:enable |
383 | 383 | global $langs, $mysoc; |
384 | 384 | |
385 | - $this->object->id = $_POST["socid"]; |
|
386 | - $this->object->name = $_POST["nom"]; |
|
387 | - $this->object->prefix_comm = $_POST["prefix_comm"]; |
|
388 | - $this->object->client = $_POST["client"]; |
|
389 | - $this->object->code_client = $_POST["code_client"]; |
|
390 | - $this->object->fournisseur = $_POST["fournisseur"]; |
|
391 | - $this->object->code_fournisseur = $_POST["code_fournisseur"]; |
|
392 | - $this->object->address = $_POST["adresse"]; |
|
393 | - $this->object->zip = $_POST["zipcode"]; |
|
394 | - $this->object->town = $_POST["town"]; |
|
395 | - $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; |
|
396 | - $this->object->state_id = $_POST["state_id"]; |
|
397 | - $this->object->phone = $_POST["tel"]; |
|
398 | - $this->object->fax = $_POST["fax"]; |
|
399 | - $this->object->email = $_POST["email"]; |
|
400 | - $this->object->url = $_POST["url"]; |
|
401 | - $this->object->capital = $_POST["capital"]; |
|
402 | - $this->object->idprof1 = $_POST["idprof1"]; |
|
403 | - $this->object->idprof2 = $_POST["idprof2"]; |
|
404 | - $this->object->idprof3 = $_POST["idprof3"]; |
|
405 | - $this->object->idprof4 = $_POST["idprof4"]; |
|
406 | - $this->object->typent_id = $_POST["typent_id"]; |
|
407 | - $this->object->effectif_id = $_POST["effectif_id"]; |
|
408 | - $this->object->barcode = $_POST["barcode"]; |
|
409 | - $this->object->forme_juridique_code = $_POST["forme_juridique_code"]; |
|
410 | - $this->object->default_lang = $_POST["default_lang"]; |
|
411 | - $this->object->commercial_id = $_POST["commercial_id"]; |
|
412 | - |
|
413 | - $this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1; |
|
414 | - $this->object->tva_intra = $_POST["tva_intra"]; |
|
385 | + $this->object->id = $_POST["socid"]; |
|
386 | + $this->object->name = $_POST["nom"]; |
|
387 | + $this->object->prefix_comm = $_POST["prefix_comm"]; |
|
388 | + $this->object->client = $_POST["client"]; |
|
389 | + $this->object->code_client = $_POST["code_client"]; |
|
390 | + $this->object->fournisseur = $_POST["fournisseur"]; |
|
391 | + $this->object->code_fournisseur = $_POST["code_fournisseur"]; |
|
392 | + $this->object->address = $_POST["adresse"]; |
|
393 | + $this->object->zip = $_POST["zipcode"]; |
|
394 | + $this->object->town = $_POST["town"]; |
|
395 | + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; |
|
396 | + $this->object->state_id = $_POST["state_id"]; |
|
397 | + $this->object->phone = $_POST["tel"]; |
|
398 | + $this->object->fax = $_POST["fax"]; |
|
399 | + $this->object->email = $_POST["email"]; |
|
400 | + $this->object->url = $_POST["url"]; |
|
401 | + $this->object->capital = $_POST["capital"]; |
|
402 | + $this->object->idprof1 = $_POST["idprof1"]; |
|
403 | + $this->object->idprof2 = $_POST["idprof2"]; |
|
404 | + $this->object->idprof3 = $_POST["idprof3"]; |
|
405 | + $this->object->idprof4 = $_POST["idprof4"]; |
|
406 | + $this->object->typent_id = $_POST["typent_id"]; |
|
407 | + $this->object->effectif_id = $_POST["effectif_id"]; |
|
408 | + $this->object->barcode = $_POST["barcode"]; |
|
409 | + $this->object->forme_juridique_code = $_POST["forme_juridique_code"]; |
|
410 | + $this->object->default_lang = $_POST["default_lang"]; |
|
411 | + $this->object->commercial_id = $_POST["commercial_id"]; |
|
412 | + |
|
413 | + $this->object->tva_assuj = $_POST["assujtva_value"] ? $_POST["assujtva_value"] : 1; |
|
414 | + $this->object->tva_intra = $_POST["tva_intra"]; |
|
415 | 415 | |
416 | 416 | //Local Taxes |
417 | - $this->object->localtax1_assuj = $_POST["localtax1assuj_value"]; |
|
418 | - $this->object->localtax2_assuj = $_POST["localtax2assuj_value"]; |
|
417 | + $this->object->localtax1_assuj = $_POST["localtax1assuj_value"]; |
|
418 | + $this->object->localtax2_assuj = $_POST["localtax2assuj_value"]; |
|
419 | 419 | |
420 | 420 | // We set country_id, and country_code label of the chosen country |
421 | 421 | if ($this->object->country_id) |
422 | 422 | { |
423 | - $tmparray=getCountry($this->object->country_id,'all',$this->db,$langs,0); |
|
424 | - $this->object->country_code = $tmparray['code']; |
|
425 | - $this->object->country_label= $tmparray['label']; |
|
423 | + $tmparray = getCountry($this->object->country_id, 'all', $this->db, $langs, 0); |
|
424 | + $this->object->country_code = $tmparray['code']; |
|
425 | + $this->object->country_label = $tmparray['label']; |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | |
19 | 19 | // Protection to avoid direct call of template |
20 | -if (empty($conf) || ! is_object($conf)) |
|
20 | +if (empty($conf) || !is_object($conf)) |
|
21 | 21 | { |
22 | 22 | print "Error, template page can't be called as URL"; |
23 | 23 | exit; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | <tr> |
59 | 59 | <td><span class="fieldrequired"><?php echo $langs->trans('LastName'); ?></span></td> |
60 | 60 | <td><input type="text" size="30" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td> |
61 | - <?php if (! empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
61 | + <?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?> |
|
62 | 62 | <td><?php echo $langs->trans('Prefix'); ?></td> |
63 | 63 | <td><input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>"></td> |
64 | 64 | <?php } ?> |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | </tr> |
114 | 114 | <?php } }?> |
115 | 115 | |
116 | -<?php if (! empty($conf->barcode->enabled)) { ?> |
|
116 | +<?php if (!empty($conf->barcode->enabled)) { ?> |
|
117 | 117 | <tr> |
118 | 118 | <td><?php echo $langs->trans('Gencod'); ?></td> |
119 | 119 | <td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td> |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | </tr> |
151 | 151 | |
152 | 152 | <tr> |
153 | - <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?></td> |
|
153 | + <td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?></td> |
|
154 | 154 | <td><input type="text" name="email" size="32" value="<?php echo $this->control->tpl['email']; ?>"></td> |
155 | 155 | <td><?php echo $langs->trans('Web'); ?></td> |
156 | 156 | <td><input type="text" name="url" size="32" value="<?php echo $this->control->tpl['url']; ?>"></td> |
157 | 157 | </tr> |
158 | 158 | |
159 | -<?php if (! empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
159 | +<?php if (!empty($conf->global->MAIN_MULTILANGS)) { ?> |
|
160 | 160 | <tr> |
161 | 161 | <td><?php echo $langs->trans("DefaultLang"); ?></td> |
162 | 162 | <td colspan="3"><?php echo $this->control->tpl['select_lang']; ?></td> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | <td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td> |
169 | 169 | </tr> |
170 | 170 | |
171 | -<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
171 | +<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> |
|
172 | 172 | |
173 | 173 | <?php if ($user->rights->societe->client->voir) { ?> |
174 | 174 | <tr> |