dolibarr 21.0.0-alpha
api_members.class.php
1<?php
2/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
3 * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2020 Thibault FOUCART<support@ptibogxiv.net>
5 * Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22use Luracast\Restler\RestException;
23
24require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
25require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
26require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
27require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
28require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
29
30
37class Members extends DolibarrApi
38{
42 public static $FIELDS = array(
43 'morphy',
44 'typeid'
45 );
46
50 public function __construct()
51 {
52 global $db;
53 $this->db = $db;
54 }
55
67 public function get($id)
68 {
69 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
70 throw new RestException(403);
71 }
72
73 $member = new Adherent($this->db);
74 if ($id == 0) {
75 $result = $member->initAsSpecimen();
76 } else {
77 $result = $member->fetch($id);
78 }
79 if (!$result) {
80 throw new RestException(404, 'member not found');
81 }
82
83 if (!DolibarrApi::_checkAccessToResource('adherent', $member->id) && $id > 0) {
84 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
85 }
86
87 return $this->_cleanObjectDatas($member);
88 }
89
104 public function getByThirdparty($thirdparty)
105 {
106 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
107 throw new RestException(403);
108 }
109
110 $member = new Adherent($this->db);
111 $result = $member->fetch(0, '', $thirdparty);
112 if (!$result) {
113 throw new RestException(404, 'member not found');
114 }
115
116 if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
117 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
118 }
119
120 return $this->_cleanObjectDatas($member);
121 }
122
135 public function getByThirdpartyAccounts($site, $key_account)
136 {
137 if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
138 throw new RestException(403);
139 }
140
141 $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
142 $sql .= " WHERE site = '".$this->db->escape($site)."' AND key_account = '".$this->db->escape($key_account)."'";
143 $sql .= " AND entity IN (".getEntity('adherent').")";
144
145 $result = $this->db->query($sql);
146
147 if ($result && $this->db->num_rows($result) == 1) {
148 $obj = $this->db->fetch_object($result);
149 $thirdparty = new Societe($this->db);
150 $result = $thirdparty->fetch($obj->fk_soc);
151
152 if ($result <= 0) {
153 throw new RestException(404, 'thirdparty not found');
154 }
155
156 $member = new Adherent($this->db);
157 $result = $member->fetch(0, '', $thirdparty->id);
158 if (!$result) {
159 throw new RestException(404, 'member not found');
160 }
161 } else {
162 throw new RestException(404, 'This account have many thirdparties attached or does not exist.');
163 }
164
165 if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
166 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
167 }
168
169 return $this->_cleanObjectDatas($member);
170 }
171
186 public function getByThirdpartyEmail($email)
187 {
188 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
189 throw new RestException(403);
190 }
191
192 $thirdparty = new Societe($this->db);
193 $result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $email);
194 if (!$result) {
195 throw new RestException(404, 'thirdparty not found');
196 }
197
198 $member = new Adherent($this->db);
199 $result = $member->fetch(0, '', $thirdparty->id);
200 if (!$result) {
201 throw new RestException(404, 'member not found');
202 }
203
204 if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
205 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
206 }
207
208 return $this->_cleanObjectDatas($member);
209 }
210
225 public function getByThirdpartyBarcode($barcode)
226 {
227 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
228 throw new RestException(403);
229 }
230
231 $thirdparty = new Societe($this->db);
232 $result = $thirdparty->fetch(0, '', '', $barcode);
233 if (!$result) {
234 throw new RestException(404, 'thirdparty not found');
235 }
236
237 $member = new Adherent($this->db);
238 $result = $member->fetch(0, '', $thirdparty->id);
239 if (!$result) {
240 throw new RestException(404, 'member not found');
241 }
242
243 if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
244 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
245 }
246
247 return $this->_cleanObjectDatas($member);
248 }
249
274 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '', $properties = '', $pagination_data = false)
275 {
276 $obj_ret = array();
277
278 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
279 throw new RestException(403);
280 }
281
282 $sql = "SELECT t.rowid";
283 $sql .= " FROM ".MAIN_DB_PREFIX."adherent AS t LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call
284 if ($category > 0) {
285 $sql .= ", ".MAIN_DB_PREFIX."categorie_member as c";
286 }
287 $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
288 if (!empty($typeid)) {
289 $sql .= ' AND t.fk_adherent_type='.((int) $typeid);
290 }
291 // Select members of given category
292 if ($category > 0) {
293 $sql .= " AND c.fk_categorie = ".((int) $category);
294 $sql .= " AND c.fk_member = t.rowid";
295 }
296 // Add sql filters
297 if ($sqlfilters) {
298 $errormessage = '';
299 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
300 if ($errormessage) {
301 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
302 }
303 }
304
305 //this query will return total orders with the filters given
306 $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
307
308 $sql .= $this->db->order($sortfield, $sortorder);
309 if ($limit) {
310 if ($page < 0) {
311 $page = 0;
312 }
313 $offset = $limit * $page;
314
315 $sql .= $this->db->plimit($limit + 1, $offset);
316 }
317
318 $result = $this->db->query($sql);
319 if ($result) {
320 $i = 0;
321 $num = $this->db->num_rows($result);
322 $min = min($num, ($limit <= 0 ? $num : $limit));
323 while ($i < $min) {
324 $obj = $this->db->fetch_object($result);
325 $member = new Adherent($this->db);
326 if ($member->fetch($obj->rowid)) {
327 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($member), $properties);
328 }
329 $i++;
330 }
331 } else {
332 throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror());
333 }
334
335 //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
336 if ($pagination_data) {
337 $totalsResult = $this->db->query($sqlTotals);
338 $total = $this->db->fetch_object($totalsResult)->total;
339
340 $tmp = $obj_ret;
341 $obj_ret = [];
342
343 $obj_ret['data'] = $tmp;
344 $obj_ret['pagination'] = [
345 'total' => (int) $total,
346 'page' => $page, //count starts from 0
347 'page_count' => ceil((int) $total / $limit),
348 'limit' => $limit
349 ];
350 }
351
352 return $obj_ret;
353 }
354
364 public function post($request_data = null)
365 {
366 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
367 throw new RestException(403);
368 }
369 // Check mandatory fields
370 $result = $this->_validate($request_data);
371
372 $member = new Adherent($this->db);
373 foreach ($request_data as $field => $value) {
374 if ($field === 'caller') {
375 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
376 $member->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
377 continue;
378 }
379
380 $member->$field = $this->_checkValForAPI($field, $value, $member);
381 }
382 if ($member->create(DolibarrApiAccess::$user) < 0) {
383 throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors));
384 }
385 return $member->id;
386 }
387
401 public function put($id, $request_data = null)
402 {
403 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
404 throw new RestException(403);
405 }
406
407 $member = new Adherent($this->db);
408 $result = $member->fetch($id);
409 if (!$result) {
410 throw new RestException(404, 'member not found');
411 }
412
413 if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
414 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
415 }
416
417 foreach ($request_data as $field => $value) {
418 if ($field == 'id') {
419 continue;
420 }
421 if ($field === 'caller') {
422 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
423 $member->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
424 continue;
425 }
426 if ($field == 'array_options' && is_array($value)) {
427 foreach ($value as $index => $val) {
428 $member->array_options[$index] = $val;
429 }
430 continue;
431 }
432 // Process the status separately because it must be updated using
433 // the validate(), resiliate() and exclude() methods of the class Adherent.
434 if ($field == 'statut') {
435 if ($value == '0') {
436 $result = $member->resiliate(DolibarrApiAccess::$user);
437 if ($result < 0) {
438 throw new RestException(500, 'Error when resiliating member: '.$member->error);
439 }
440 } elseif ($value == '1') {
441 $result = $member->validate(DolibarrApiAccess::$user);
442 if ($result < 0) {
443 throw new RestException(500, 'Error when validating member: '.$member->error);
444 }
445 } elseif ($value == '-2') {
446 $result = $member->exclude(DolibarrApiAccess::$user);
447 if ($result < 0) {
448 throw new RestException(500, 'Error when excluding member: '.$member->error);
449 }
450 }
451 } else {
452 $member->$field = $this->_checkValForAPI($field, $value, $member);
453 }
454 }
455
456 // If there is no error, update() returns the number of affected rows
457 // so if the update is a no op, the return value is zero.
458 if ($member->update(DolibarrApiAccess::$user) >= 0) {
459 return $this->get($id);
460 } else {
461 throw new RestException(500, 'Error when updating member: '.$member->error);
462 }
463 }
464
477 public function delete($id)
478 {
479 if (!DolibarrApiAccess::$user->hasRight('adherent', 'supprimer')) {
480 throw new RestException(403);
481 }
482 $member = new Adherent($this->db);
483 $result = $member->fetch($id);
484 if (!$result) {
485 throw new RestException(404, 'member not found');
486 }
487
488 if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
489 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
490 }
491
492
493 $res = $member->delete(DolibarrApiAccess::$user);
494 if ($res < 0) {
495 throw new RestException(500, "Can't delete, error occurs");
496 }
497
498 return array(
499 'success' => array(
500 'code' => 200,
501 'message' => 'Member deleted'
502 )
503 );
504 }
505
515 private function _validate($data)
516 {
517 $member = array();
518
519 $mandatoryfields = array(
520 'morphy',
521 'typeid'
522 );
523 foreach ($mandatoryfields as $field) {
524 if (!isset($data[$field])) {
525 throw new RestException(400, "$field field missing");
526 }
527 $member[$field] = $data[$field];
528 }
529 return $member;
530 }
531
532 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
539 protected function _cleanObjectDatas($object)
540 {
541 // phpcs:enable
542 $object = parent::_cleanObjectDatas($object);
543
544 // Remove the subscriptions because they are handled as a subresource.
545 if ($object instanceof Adherent) {
546 unset($object->subscriptions);
547 unset($object->fk_incoterms);
548 unset($object->label_incoterms);
549 unset($object->location_incoterms);
550 unset($object->fk_delivery_address);
551 unset($object->shipping_method_id);
552
553 unset($object->total_ht);
554 unset($object->total_ttc);
555 unset($object->total_tva);
556 unset($object->total_localtax1);
557 unset($object->total_localtax2);
558 }
559
560 if ($object instanceof AdherentType) {
561 unset($object->linkedObjectsIds);
562 unset($object->context);
563 unset($object->canvas);
564 unset($object->fk_project);
565 unset($object->contact);
566 unset($object->contact_id);
567 unset($object->thirdparty);
568 unset($object->user);
569 unset($object->origin);
570 unset($object->origin_id);
571 unset($object->ref_ext);
572 unset($object->country);
573 unset($object->country_id);
574 unset($object->country_code);
575 unset($object->barcode_type);
576 unset($object->barcode_type_code);
577 unset($object->barcode_type_label);
578 unset($object->barcode_type_coder);
579 unset($object->mode_reglement_id);
580 unset($object->cond_reglement_id);
581 unset($object->cond_reglement);
582 unset($object->fk_delivery_address);
583 unset($object->shipping_method_id);
584 unset($object->model_pdf);
585 unset($object->fk_account);
586 unset($object->note_public);
587 unset($object->note_private);
588 unset($object->fk_incoterms);
589 unset($object->label_incoterms);
590 unset($object->location_incoterms);
591 unset($object->name);
592 unset($object->lastname);
593 unset($object->firstname);
594 unset($object->civility_id);
595 unset($object->total_ht);
596 unset($object->total_tva);
597 unset($object->total_localtax1);
598 unset($object->total_localtax2);
599 unset($object->total_ttc);
600 }
601
602 return $object;
603 }
604
620 public function getSubscriptions($id)
621 {
622 if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) {
623 throw new RestException(403);
624 }
625
626 $member = new Adherent($this->db);
627 $result = $member->fetch($id);
628 if (!$result) {
629 throw new RestException(404, 'member not found');
630 }
631
632 $obj_ret = array();
633 foreach ($member->subscriptions as $subscription) {
634 $obj_ret[] = $this->_cleanObjectDatas($subscription);
635 }
636 return $obj_ret;
637 }
638
654 public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
655 {
656 if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) {
657 throw new RestException(403);
658 }
659
660 $member = new Adherent($this->db);
661 $result = $member->fetch($id);
662 if (!$result) {
663 throw new RestException(404, 'member not found');
664 }
665
666 return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date);
667 }
668
686 public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
687 {
688 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
689 throw new RestException(403);
690 }
691
692 $categories = new Categorie($this->db);
693
694 $result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page);
695
696 if ($result < 0) {
697 throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
698 }
699
700 return $result;
701 }
702
703
704
705
719 public function getType($id)
720 {
721 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
722 throw new RestException(403);
723 }
724
725 $membertype = new AdherentType($this->db);
726 $result = $membertype->fetch($id);
727 if (!$result) {
728 throw new RestException(404, 'member type not found');
729 }
730
731 if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
732 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
733 }
734
735 return $this->_cleanObjectDatas($membertype);
736 }
737
760 public function indexType($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false)
761 {
762 $obj_ret = array();
763
764 if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
765 throw new RestException(403);
766 }
767
768 $sql = "SELECT t.rowid";
769 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type AS t LEFT JOIN ".MAIN_DB_PREFIX."adherent_type_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
770 $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
771
772 // Add sql filters
773 if ($sqlfilters) {
774 $errormessage = '';
775 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
776 if ($errormessage) {
777 throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
778 }
779 }
780
781 //this query will return total orders with the filters given
782 $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql);
783
784 $sql .= $this->db->order($sortfield, $sortorder);
785 if ($limit) {
786 if ($page < 0) {
787 $page = 0;
788 }
789 $offset = $limit * $page;
790
791 $sql .= $this->db->plimit($limit + 1, $offset);
792 }
793
794 $result = $this->db->query($sql);
795 if ($result) {
796 $i = 0;
797 $num = $this->db->num_rows($result);
798 $min = min($num, ($limit <= 0 ? $num : $limit));
799 while ($i < $min) {
800 $obj = $this->db->fetch_object($result);
801 $membertype = new AdherentType($this->db);
802 if ($membertype->fetch($obj->rowid)) {
803 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($membertype), $properties);
804 }
805 $i++;
806 }
807 } else {
808 throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
809 }
810
811 //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
812 if ($pagination_data) {
813 $totalsResult = $this->db->query($sqlTotals);
814 $total = $this->db->fetch_object($totalsResult)->total;
815
816 $tmp = $obj_ret;
817 $obj_ret = [];
818
819 $obj_ret['data'] = $tmp;
820 $obj_ret['pagination'] = [
821 'total' => (int) $total,
822 'page' => $page, //count starts from 0
823 'page_count' => ceil((int) $total / $limit),
824 'limit' => $limit
825 ];
826 }
827
828 return $obj_ret;
829 }
830
844 public function postType($request_data = null)
845 {
846 if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
847 throw new RestException(403);
848 }
849 // Check mandatory fields
850 $result = $this->_validateType($request_data);
851
852 $membertype = new AdherentType($this->db);
853 foreach ($request_data as $field => $value) {
854 if ($field === 'caller') {
855 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
856 $membertype->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
857 continue;
858 }
859
860 $membertype->$field = $this->_checkValForAPI($field, $value, $membertype);
861 }
862 if ($membertype->create(DolibarrApiAccess::$user) < 0) {
863 throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
864 }
865 return $membertype->id;
866 }
867
883 public function putType($id, $request_data = null)
884 {
885 if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
886 throw new RestException(403);
887 }
888
889 $membertype = new AdherentType($this->db);
890 $result = $membertype->fetch($id);
891 if (!$result) {
892 throw new RestException(404, 'member type not found');
893 }
894
895 if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
896 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
897 }
898
899 foreach ($request_data as $field => $value) {
900 if ($field == 'id') {
901 continue;
902 }
903 if ($field === 'caller') {
904 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
905 $membertype->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
906 continue;
907 }
908 if ($field == 'array_options' && is_array($value)) {
909 foreach ($value as $index => $val) {
910 $membertype->array_options[$index] = $val;
911 }
912 continue;
913 }
914 // Process the status separately because it must be updated using
915 // the validate(), resiliate() and exclude() methods of the class AdherentType.
916 $membertype->$field = $this->_checkValForAPI($field, $value, $membertype);
917 }
918
919 // If there is no error, update() returns the number of affected rows
920 // so if the update is a no op, the return value is zero.
921 if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
922 return $this->get($id);
923 } else {
924 throw new RestException(500, 'Error when updating member type: '.$membertype->error);
925 }
926 }
927
942 public function deleteType($id)
943 {
944 if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
945 throw new RestException(403);
946 }
947 $membertype = new AdherentType($this->db);
948 $result = $membertype->fetch($id);
949 if ($result < 1) {
950 throw new RestException(404, 'member type not found');
951 }
952
953 if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
954 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
955 }
956
957 $res = $membertype->delete(DolibarrApiAccess::$user);
958 if ($res < 0) {
959 throw new RestException(500, "Can't delete, error occurs");
960 }
961
962 return array(
963 'success' => array(
964 'code' => 200,
965 'message' => 'Member type deleted'
966 )
967 );
968 }
969
978 private function _validateType($data)
979 {
980 $membertype = array();
981
982 $mandatoryfields = array('label');
983
984 foreach ($mandatoryfields as $field) {
985 if (!isset($data[$field])) {
986 throw new RestException(400, "$field field missing");
987 }
988 $membertype[$field] = $data[$field];
989 }
990 return $membertype;
991 }
992}
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage members of a foundation.
Class to manage members type.
Class to manage categories.
Class for API REST v1.
Definition api.class.php:30
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition api.class.php:82
put($id, $request_data=null)
Update member.
getType($id)
Get properties of a member type object.
createSubscription($id, $start_date, $end_date, $amount, $label='')
Add a subscription for a member.
indexType($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='', $pagination_data=false)
List members types.
_validate($data)
Validate fields before creating an object.
getByThirdparty($thirdparty)
Get properties of a member object by linked thirdparty.
getByThirdpartyBarcode($barcode)
Get properties of a member object by linked thirdparty barcode.
deleteType($id)
Delete member type.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $typeid='', $category=0, $sqlfilters='', $properties='', $pagination_data=false)
List members.
__construct()
Constructor.
getCategories($id, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
Get categories for a member.
getByThirdpartyEmail($email)
Get properties of a member object by linked thirdparty email.
_cleanObjectDatas($object)
Clean sensible object datas.
_validateType($data)
Validate fields before creating an object.
putType($id, $request_data=null)
Update member type.
getSubscriptions($id)
List subscriptions of a member.
post($request_data=null)
Create member object.
getByThirdpartyAccounts($site, $key_account)
Get properties of a member object by linked thirdparty account.
postType($request_data=null)
Create member type object.
Class to manage third parties objects (customers, suppliers, prospects...)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.