29 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $table_element =
'adherent_type';
45 public $element =
'adherent_type';
50 public $picto =
'members';
56 public $ismultientitymanaged = 1;
80 public $duration_value;
100 public $caneditamount;
118 public $mail_subscription =
'';
121 public $mail_resiliate =
'';
124 public $mail_exclude =
'';
127 public $members = array();
130 public $other = array();
132 public $multilangs = array();
155 $current_lang = $langs->getDefaultLang();
157 $sql =
"SELECT lang, label, description, email";
158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type_lang";
159 $sql .=
" WHERE fk_type = ".((int) $this->
id);
161 $result = $this->
db->query($sql);
163 while ($obj = $this->
db->fetch_object($result)) {
165 if ($obj->lang == $current_lang) {
166 $this->label = $obj->label;
168 $this->email = $obj->email;
170 $this->multilangs[
"$obj->lang"][
"label"] = $obj->label;
171 $this->multilangs[
"$obj->lang"][
"description"] = $obj->description;
172 $this->multilangs[
"$obj->lang"][
"email"] = $obj->email;
176 $this->error =
"Error: ".$this->db->lasterror().
" - ".$sql;
189 global $conf, $langs;
191 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
192 $current_lang = $langs->getDefaultLang();
194 foreach ($langs_available as $key => $value) {
195 if ($key == $current_lang) {
196 $sql =
"SELECT rowid";
197 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type_lang";
198 $sql .=
" WHERE fk_type = ".((int) $this->
id);
199 $sql .=
" AND lang = '".$this->db->escape($key).
"'";
201 $result = $this->
db->query($sql);
203 if ($this->
db->num_rows($result)) {
204 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"adherent_type_lang";
206 $sql2 .=
" label = '".$this->db->escape($this->label).
"',";
207 $sql2 .=
" description = '".$this->db->escape($this->
description).
"'";
208 $sql2 .=
" WHERE fk_type = ".((int) $this->
id).
" AND lang='".$this->
db->escape($key).
"'";
210 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent_type_lang (fk_type, lang, label, description";
212 $sql2 .=
" VALUES(".((int) $this->
id).
",'".$this->
db->escape($key).
"','".$this->
db->escape($this->label).
"',";
213 $sql2 .=
" '".$this->db->escape($this->
description).
"'";
216 dol_syslog(get_class($this).
'::setMultiLangs key = current_lang = '.$key);
217 if (!$this->
db->query($sql2)) {
218 $this->error = $this->
db->lasterror();
221 } elseif (isset($this->multilangs[$key])) {
222 $sql =
"SELECT rowid";
223 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type_lang";
224 $sql .=
" WHERE fk_type = ".((int) $this->
id);
225 $sql .=
" AND lang = '".$this->db->escape($key).
"'";
227 $result = $this->
db->query($sql);
229 if ($this->
db->num_rows($result)) {
230 $sql2 =
"UPDATE ".MAIN_DB_PREFIX.
"adherent_type_lang";
232 $sql2 .=
" label = '".$this->db->escape($this->multilangs[
"$key"][
"label"]).
"',";
233 $sql2 .=
" description = '".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"'";
234 $sql2 .=
" WHERE fk_type = ".((int) $this->
id).
" AND lang='".$this->
db->escape($key).
"'";
236 $sql2 =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent_type_lang (fk_type, lang, label, description";
238 $sql2 .=
" VALUES(".$this->id.
",'".$this->
db->escape($key).
"','".$this->
db->escape($this->multilangs[
"$key"][
"label"]).
"',";
239 $sql2 .=
" '".$this->db->escape($this->multilangs[
"$key"][
"description"]).
"'";
244 if ($this->multilangs[
"$key"][
"label"] || $this->multilangs[
"$key"][
"description"]) {
245 if (!$this->
db->query($sql2)) {
246 $this->error = $this->
db->lasterror();
256 $result = $this->
call_trigger(
'MEMBER_TYPE_SET_MULTILANGS', $user);
258 $this->error = $this->
db->lasterror();
275 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent_type_lang";
276 $sql .=
" WHERE fk_type = ".((int) $this->
id).
" AND lang = '".$this->
db->escape($langtodelete).
"'";
278 dol_syslog(get_class($this).
'::delMultiLangs', LOG_DEBUG);
279 $result = $this->
db->query($sql);
282 $result = $this->
call_trigger(
'MEMBER_TYPE_DEL_MULTILANGS', $user);
284 $this->error = $this->
db->lasterror();
285 dol_syslog(get_class($this).
'::delMultiLangs error='.$this->error, LOG_ERR);
291 $this->error = $this->
db->lasterror();
292 dol_syslog(get_class($this).
'::delMultiLangs error='.$this->error, LOG_ERR);
304 public function create($user, $notrigger = 0)
306 global $langs, $conf;
310 $this->status = (int) $this->status;
311 $this->label = trim($this->label);
315 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent_type (";
319 $sql .=
") VALUES (";
320 $sql .=
"'".$this->db->escape($this->morphy).
"'";
321 $sql .=
", '".$this->db->escape($this->label).
"'";
322 $sql .=
", ".((int) $conf->entity);
325 dol_syslog(
"Adherent_type::create", LOG_DEBUG);
326 $result = $this->
db->query($sql);
328 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"adherent_type");
330 $result = $this->
update($user, 1);
332 $this->
db->rollback();
338 $result = $this->
call_trigger(
'MEMBER_TYPE_CREATE', $user);
349 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
350 $this->
db->rollback();
354 $this->error = $this->
db->lasterror();
355 $this->
db->rollback();
367 public function update($user, $notrigger = 0)
369 global $langs, $conf, $hookmanager;
373 $this->label = trim($this->label);
375 if (empty($this->note_public) && !empty($this->note)) {
376 $this->note_public = $this->note;
381 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent_type ";
383 $sql .=
"statut = ".((int) $this->status).
",";
384 $sql .=
"libelle = '".$this->db->escape($this->label).
"',";
385 $sql .=
"morphy = '".$this->db->escape($this->morphy).
"',";
386 $sql .=
"subscription = '".$this->db->escape($this->subscription).
"',";
387 $sql .=
"amount = ".((empty($this->amount) && $this->amount ==
'') ?
'null' : ((
float) $this->amount)).
",";
388 $sql .=
"caneditamount = ".((int) $this->caneditamount).
",";
389 $sql .=
"duration = '".$this->db->escape($this->duration_value.$this->duration_unit).
"',";
390 $sql .=
"note = '".$this->db->escape($this->note_public).
"',";
391 $sql .=
"vote = ".(integer) $this->
db->escape($this->vote).
",";
392 $sql .=
"mail_valid = '".$this->db->escape($this->mail_valid).
"'";
393 $sql .=
" WHERE rowid =".((int) $this->
id);
395 $result = $this->
db->query($sql);
402 $this->error = $langs->trans(
"Error").
" : ".$this->
db->error().
" - ".$sql;
417 if (!$error && !$notrigger) {
419 $result = $this->
call_trigger(
'MEMBER_TYPE_MODIFY', $user);
430 $this->
db->rollback();
431 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
435 $this->error = $this->
db->lasterror();
436 $this->
db->rollback();
447 public function delete()
453 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent_type";
454 $sql .=
" WHERE rowid = ".((int) $this->
id);
459 $result = $this->
call_trigger(
'MEMBER_TYPE_DELETE', $user);
461 $error++; $this->
db->rollback();
return -2;
468 $this->
db->rollback();
469 $this->error = $this->
db->lasterror();
482 global $langs, $conf;
484 $sql =
"SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.caneditamount, d.mail_valid, d.note as note_public, d.vote";
485 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as d";
486 $sql .=
" WHERE d.rowid = ".(int) $rowid;
488 dol_syslog(
"Adherent_type::fetch", LOG_DEBUG);
493 $obj = $this->
db->fetch_object(
$resql);
495 $this->
id = $obj->rowid;
496 $this->
ref = $obj->rowid;
497 $this->label = $obj->label;
498 $this->morphy = $obj->morphy;
499 $this->status = $obj->status;
500 $this->duration = $obj->duration;
501 $this->duration_value = substr($obj->duration, 0,
dol_strlen($obj->duration) - 1);
502 $this->duration_unit = substr($obj->duration, -1);
503 $this->subscription = $obj->subscription;
504 $this->amount = $obj->amount;
505 $this->caneditamount = $obj->caneditamount;
506 $this->mail_valid = $obj->mail_valid;
507 $this->note = $obj->note_public;
508 $this->note_public = $obj->note_public;
509 $this->vote = $obj->vote;
522 $this->error = $this->
db->lasterror();
537 global $conf, $langs;
539 $adherenttypes = array();
541 $sql =
"SELECT rowid, libelle as label";
542 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
543 $sql .=
" WHERE entity IN (".getEntity(
'member_type').
")";
545 $sql .=
" AND statut = ".((int) $status);
550 $nump = $this->
db->num_rows(
$resql);
555 $obj = $this->
db->fetch_object(
$resql);
557 $adherenttypes[$obj->rowid] = $langs->trans($obj->label);
562 print $this->
db->error();
564 return $adherenttypes;
575 global $conf, $langs;
577 $amountbytype = array();
579 $sql =
"SELECT rowid, amount";
580 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
581 $sql .=
" WHERE entity IN (".getEntity(
'member_type').
")";
582 if ($status !==
null) {
583 $sql .=
" AND statut = ".((int) $status);
588 $nump = $this->
db->num_rows(
$resql);
593 $obj = $this->
db->fetch_object(
$resql);
595 $amountbytype[$obj->rowid] = $obj->amount;
600 print $this->
db->error();
603 return $amountbytype;
621 $sql =
"SELECT a.rowid";
622 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
623 $sql .=
" WHERE a.entity IN (".getEntity(
'member').
")";
624 $sql .=
" AND a.fk_adherent_type = ".((int) $this->
id);
625 if (!empty($excludefilter)) {
626 $sql .=
' AND ('.$excludefilter.
')';
629 dol_syslog(get_class($this).
"::listUsersForGroup", LOG_DEBUG);
632 while ($obj = $this->
db->fetch_object(
$resql)) {
633 if (!array_key_exists($obj->rowid, $ret)) {
637 $memberstatic->fetch($obj->rowid,
'',
'',
'',
false,
false);
639 $memberstatic->fetch($obj->rowid);
641 $ret[$obj->rowid] = $memberstatic;
643 $ret[$obj->rowid] = $obj->rowid;
650 $this->members = $ret;
654 $this->error = $this->
db->lasterror();
668 if ($morphy ==
'phy') {
669 return $langs->trans(
"Physical");
670 } elseif ($morphy ==
'mor') {
671 return $langs->trans(
"Moral");
673 return $langs->trans(
"MorAndPhy");
688 public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
694 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"MemberType").
'</u>';
695 $label .=
' '.$this->getLibStatut(4);
696 $label .=
'<br>'.$langs->trans(
"Label").
': '.$this->label;
697 if (isset($this->subscription)) {
698 $label .=
'<br>'.$langs->trans(
"SubscriptionRequired").
': '.
yn($this->subscription);
703 $url = DOL_URL_ROOT.
'/adherents/type.php?rowid='.((int) $this->
id);
705 if ($option !=
'nolink') {
707 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
708 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
709 $add_save_lastsearch_values = 1;
711 if ($add_save_lastsearch_values) {
712 $url .=
'&save_lastsearch_values=1';
716 $linkstart =
'<a href="'.$url.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
719 $result .= $linkstart;
721 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
723 if ($withpicto != 2) {
724 $result .= ($maxlen ?
dol_trunc($this->label, $maxlen) : $this->label);
740 return $this->
LibStatut($this->status, $mode);
754 $langs->load(
'companies');
756 $statusType =
'status4';
758 $statusType =
'status5';
761 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
762 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
"ActivityCeased");
763 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
"InActivity");
764 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
"ActivityCeased");
765 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
"InActivity");
768 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
788 $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES.
"=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].
",".$conf->global->LDAP_MEMBER_TYPE_DN;
791 $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
794 $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES.
"=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
810 global $conf, $langs;
815 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
817 if (empty($this->note_public) && !empty($this->note)) {
818 $this->note_public = $this->note;
822 if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) {
823 $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
825 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) {
826 $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_public, 0,
'UTF-8', 1);
828 if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) {
829 $valueofldapfield = array();
830 foreach ($this->members as $key => $val) {
832 $member->fetch($val->id,
'',
'',
'',
false,
false);
833 $info2 = $member->_load_ldap_info();
834 $valueofldapfield[] = $member->_load_ldap_dn($info2);
836 $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield :
'');
854 $this->
ref =
'MTSPEC';
857 $this->label =
'MEMBERS TYPE SPECIMEN';
858 $this->note_public =
'This is a public note';
859 $this->mail_valid =
'This is welcome email';
860 $this->subscription = 1;
861 $this->caneditamount = 0;
867 $this->members = array(
880 return $this->mail_valid;
895 return $this->mail_subscription;
910 return $this->mail_resiliate;
925 return $this->mail_exclude;
941 $return =
'<div class="box-flex-item box-flex-grow-zero">';
942 $return .=
'<div class="info-box info-box-sm">';
943 $return .=
'<span class="info-box-icon bg-infobox-action">';
945 $return .=
'</span>';
946 $return .=
'<div class="info-box-content">';
947 $return .=
'<span class="info-box-ref">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
948 if ($user->rights->adherent->configurer) {
949 $return .=
'<span class="right paddingleft"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&rowid='.$this->
ref.
'">'.
img_edit().
'</a></span>';
951 $return .=
'<span class="right"> </span>';
953 if (property_exists($this,
'vote')) {
954 $return .=
'<br><span class="info-box-label opacitymedium">'.$langs->trans(
"VoteAllowed").
' : '.
yn($this->vote).
'</span>';
956 if (property_exists($this,
'amount')) {
957 if (is_null($this->amount) || $this->amount ===
'') {
960 $return .=
'<br><span class="info-box-label opacitymedium">'.$langs->trans(
"Amount").
'</span>';
961 $return .=
'<span class="amount"> : '.price($this->amount).
'</span>';
964 if (method_exists($this,
'getLibStatut')) {
965 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).
'</div>';
Class to manage members of a foundation.
Class to manage members type.
amountByType($status=null)
Return the array of all amounts per membership type id.
__construct($db)
Constructor.
update($user, $notrigger=0)
Updating the type in the database.
$duration_unit
Expiration unit.
getMailOnExclude()
getMailOnExclude
fetch($rowid)
Function that retrieves the properties of a membership type.
getKanbanView($option='')
Return clicable link of object (with eventually picto)
getNomUrl($withpicto=0, $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
create($user, $notrigger=0)
Function to create the member type.
setMultiLangs($user)
Update or add a translation for this member type.
getMailOnValid()
getMailOnValid
getMailOnSubscription()
getMailOnSubscription
initAsSpecimen()
Initialise an instance with random values.
liste_array($status=-1)
Return list of members' type.
getLibStatut($mode=0)
Return label of status (activity, closed)
delMultiLangs($langtodelete, $user)
Delete a language for this member type.
_load_ldap_info()
Initialize the info array (array of LDAP values) that will be used to call LDAP functions.
getmorphylib($morphy='')
Return translated label by the nature of a adherent (physical or moral)
getMultiLangs()
Load array this->multilangs.
getMailOnResiliate()
getMailOnResiliate
LibStatut($status, $mode=0)
Return the label of a given status.
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
listMembersForMemberType($excludefilter='', $mode=0)
Return array of Member objects for member type this->id (or all if this->id not defined)
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.