Merge pull request #12439 from ptibogxiv/patch-278

Fix adherent type v11
This commit is contained in:
Laurent Destailleur 2019-11-16 00:42:22 +01:00 committed by GitHub
commit b44354af44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 27 deletions

View File

@ -489,7 +489,7 @@ class AdherentType extends CommonObject
{ {
global $langs, $conf; global $langs, $conf;
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".(int) $rowid; $sql .= " WHERE d.rowid = ".(int) $rowid;
@ -506,7 +506,8 @@ class AdherentType extends CommonObject
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->label = $obj->label; $this->label = $obj->label;
$this->morphy = $obj->morphy; $this->morphy = $obj->morphy;
$this->statut = $obj->statut; $this->statut = $obj->status; // deprecated
$this->status = $obj->status;
$this->duration = $obj->duration; $this->duration = $obj->duration;
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1);
$this->duration_unit = substr($obj->duration, -1); $this->duration_unit = substr($obj->duration, -1);
@ -668,14 +669,43 @@ class AdherentType extends CommonObject
return $result; return $result;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* getLibStatut * Return label of status (activity, closed)
* *
* @return string Return status of a type of member * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/ */
public function getLibStatut() public function getLibStatut($mode = 0)
{ {
return ''; return $this->LibStatut($this->status, $mode);
}
/**
* Return the label of a given status
*
* @param int $status Status id
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Status label
*/
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
$langs->load('companies');
$statusType = 'status4';
if ($status == 0) $statusType = 'status5';
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
$this->labelStatus[0] = $langs->trans("ActivityCeased");
$this->labelStatus[1] = $langs->trans("InActivity");
$this->labelStatusShort[0] = $langs->trans("ActivityCeased");
$this->labelStatusShort[1] = $langs->trans("InActivity");
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -226,7 +226,7 @@ if (!$rowid && $action != 'create' && $action != 'edit')
{ {
//dol_fiche_head(''); //dol_fiche_head('');
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy"; $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.entity IN (".getEntity('member_type').")"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
@ -280,6 +280,7 @@ if (!$rowid && $action != 'create' && $action != 'edit')
$membertype->id = $objp->rowid; $membertype->id = $objp->rowid;
$membertype->ref = $objp->rowid; $membertype->ref = $objp->rowid;
$membertype->label = $objp->rowid; $membertype->label = $objp->rowid;
$membertype->status = $objp->status;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
@ -294,13 +295,7 @@ if (!$rowid && $action != 'create' && $action != 'edit')
print '</td>'; print '</td>';
print '<td class="center">'.yn($objp->subscription).'</td>'; print '<td class="center">'.yn($objp->subscription).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>'; print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center">'; print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
if (!empty($objp->statut)) {
print img_picto($langs->trans("InActivity"), 'statut4');
} else {
print img_picto($langs->trans("ActivityCeased"), 'statut5');
}
print '</td>';
if ($user->rights->adherent->configurer) if ($user->rights->adherent->configurer)
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
else else
@ -432,14 +427,6 @@ if ($rowid > 0)
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr><td class="titlefield">'.$langs->trans("Status").'</td><td>';
if (!empty($object->statut)) {
print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity");
} else {
print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased");
}
print '</tr>';
// Morphy // Morphy
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>'; print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
print '</tr>'; print '</tr>';