Beautify for of member module

This commit is contained in:
Laurent Destailleur 2020-08-18 11:52:00 +02:00
parent 2ca0d67072
commit e65e4a6d47
6 changed files with 54 additions and 36 deletions

View File

@ -25,7 +25,7 @@
/**
* \file htdocs/adherents/card.php
* \ingroup member
* \brief Page of member
* \brief Page of a member
*/
require '../main.inc.php';
@ -850,9 +850,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
$listetype = $adht->liste_array();
$listetype = $adht->liste_array(1);
if (count($listetype)) {
print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int') ?GETPOST('typeid', 'int') : $typeid, count($listetype) > 1 ? 1 : 0);
print $form->selectarray("typeid", $listetype, (GETPOST('typeid', 'int') ? GETPOST('typeid', 'int') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', '', 1);
} else {
print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
}
@ -862,7 +862,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy, 1);
print $form->selectarray("morphy", $morphys, (GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy), 1, 0, 0, '', 0, 0, 0, '', '', 1);
print "</td>\n";
// Company
@ -870,7 +870,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $formcompany->select_civility(GETPOST('civility_id', 'int') ?GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id').'</td>';
print $formcompany->select_civility(GETPOST('civility_id', 'int') ? GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id', 'maxwidth150', 1).'</td>';
print '</tr>';
// Lastname
@ -885,7 +885,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Gender").'</td>';
print '<td>';
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1);
print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1);
print '</td></tr>';
// EMail
@ -1074,13 +1074,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy));
print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1);
print "</td></tr>";
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
if ($user->rights->adherent->creer) {
print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid));
print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', '', 1);
} else {
print $adht->getNomUrl(1);
print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
@ -1092,7 +1092,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id)."\n";
print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id, 'civility_id', 'maxwidth150', 1);
print '</td>';
print '</tr>';
@ -1108,7 +1108,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Gender").'</td>';
print '<td>';
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1);
print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1, 0, 0, '', 0, 0, 0, '', '', 1);
print '</td></tr>';
// Photo
@ -1164,7 +1164,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<td>'.img_picto('', 'object_phoning').' <input type="text" name="phone_perso" value="'.(GETPOSTISSET("phone_perso") ? GETPOST("phone_perso") : $object->phone_perso).'"></td></tr>';
// Mobile phone
print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td>';
print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>';
if (!empty($conf->socialnetworks->enabled)) {

View File

@ -112,7 +112,7 @@ class AdherentType extends CommonObject
public function __construct($db)
{
$this->db = $db;
$this->statut = 1;
$this->status = 1;
}
/**
@ -280,7 +280,7 @@ class AdherentType extends CommonObject
$error = 0;
$this->statut = (int) $this->statut;
$this->status = (int) $this->status;
$this->label = trim($this->label);
$this->db->begin();
@ -347,7 +347,7 @@ class AdherentType extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql .= "SET ";
$sql .= "statut = ".$this->statut.",";
$sql .= "statut = ".$this->status.",";
$sql .= "libelle = '".$this->db->escape($this->label)."',";
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
@ -456,7 +456,6 @@ class AdherentType extends CommonObject
$this->ref = $obj->rowid;
$this->label = $obj->label;
$this->morphy = $obj->morphy;
$this->statut = $obj->status; // deprecated
$this->status = $obj->status;
$this->duration = $obj->duration;
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
@ -483,9 +482,10 @@ class AdherentType extends CommonObject
/**
* Return list of members' type
*
* @return array List of types of members
* @param int $status Filter on status of type
* @return array List of types of members
*/
public function liste_array()
public function liste_array($status = -1)
{
// phpcs:enable
global $conf, $langs;
@ -495,6 +495,7 @@ class AdherentType extends CommonObject
$sql = "SELECT rowid, libelle as label";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql .= " WHERE entity IN (".getEntity('member_type').")";
if ($status >= 0) $sql .= " AND statut = ".((int) $status);
$resql = $this->db->query($sql);
if ($resql) {
@ -719,7 +720,7 @@ class AdherentType extends CommonObject
$this->subscription = 1;
$this->vote = 0;
$this->statut = 1;
$this->status = 1;
// Members of this member type is just me
$this->members = array(

View File

@ -121,7 +121,7 @@ $arrayfields = array(
'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0),
'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1),
'd.morphy'=>array('label'=>$langs->trans("MemberNature"), 'checked'=>1),
't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
@ -707,9 +707,20 @@ while ($i < min($num, $limit)) {
print "<td>".$obj->login."</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Moral/Physique
// Nature (Moral/Physical)
if (!empty($arrayfields['d.morphy']['checked'])) {
print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n";
print '<td class="center">';
$s = '';
if ($obj->morphy == 'phy')
{
$s .= '<span class="customer-back" title="'.$langs->trans("Physical").'">'.dol_substr($langs->trans("Physical"), 0, 1).'</span>';
}
if ($obj->morphy == 'mor')
{
$s .= '<span class="vendor-back" title="'.$langs->trans("Moral").'">'.dol_substr($langs->trans("Moral"), 0, 1).'</span>';
}
print $s;
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Type label

View File

@ -61,7 +61,7 @@ if (!$sortfield) { $sortfield = "d.lastname"; }
$label = GETPOST("label", "alpha");
$morphy = GETPOST("morphy", "alpha");
$statut = GETPOST("statut", "int");
$status = GETPOST("status", "int");
$subscription = GETPOST("subscription", "int");
$duration_value = GETPOST('duration_value', 'int');
$duration_unit = GETPOST('duration_unit', 'alpha');
@ -108,7 +108,7 @@ if ($cancel) {
if ($action == 'add' && $user->rights->adherent->configurer) {
$object->label = trim($label);
$object->morphy = trim($morphy);
$object->statut = (int) $statut;
$object->status = (int) $status;
$object->subscription = (int) $subscription;
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
@ -157,7 +157,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
$object->label = trim($label);
$object->morphy = trim($morphy);
$object->statut = (int) $statut;
$object->status = (int) $status;
$object->subscription = (int) $subscription;
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
@ -205,7 +205,6 @@ $formproduct = new FormProduct($db);
llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
// List of members type
if (!$rowid && $action != 'create' && $action != 'edit') {
//dol_fiche_head('');
@ -317,7 +316,7 @@ if ($action == 'create') {
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print '</td></tr>';
// Morphy
@ -448,7 +447,7 @@ if ($rowid > 0) {
}
// Add
if ($user->rights->adherent->configurer && !empty($object->statut)) {
if ($user->rights->adherent->configurer && !empty($object->status)) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
@ -470,7 +469,7 @@ if ($rowid > 0) {
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,";
$sql .= " d.datefin,";
$sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut as status,";
$sql .= " t.libelle as type, t.subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE d.fk_adherent_type = t.rowid ";
@ -643,13 +642,13 @@ if ($rowid > 0) {
// Statut
print '<td class="nowrap">';
print $adh->LibStatut($objp->statut, $objp->subscription, $datefin, 2);
print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
print "</td>";
// Date end subscription
if ($datefin) {
print '<td class="nowrap center">';
if ($datefin < dol_now() && $objp->statut > 0) {
if ($datefin < dol_now() && $objp->status > 0) {
print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
} else {
print dol_print_date($datefin, 'day');
@ -659,7 +658,7 @@ if ($rowid > 0) {
print '<td class="nowrap left">';
if ($objp->subscription == 'yes') {
print $langs->trans("SubscriptionNotReceived");
if ($objp->statut > 0) print " ".img_warning();
if ($objp->status > 0) print " ".img_warning();
} else {
print '&nbsp;';
}
@ -720,7 +719,7 @@ if ($rowid > 0) {
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut);
print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
print '</td></tr>';
// Morphy
@ -741,7 +740,7 @@ if ($rowid > 0) {
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> ';
print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1);
print $formproduct->selectMeasuringUnits("duration_unit", "time", ($object->duration_unit === '' ? 'y' : $object->duration_unit), 0, 1);
print '</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';

View File

@ -419,9 +419,10 @@ class FormCompany extends Form
* @param string $selected Civility/Title code preselected
* @param string $htmlname Name of HTML select combo field
* @param string $morecss Add more css on SELECT element
* @param int $addjscombo Add js combo
* @return string String with HTML select
*/
public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100')
public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0)
{
// phpcs:enable
global $conf, $langs, $user;
@ -451,7 +452,7 @@ class FormCompany extends Form
} else {
$out .= '<option value="'.$obj->code.'">';
}
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
// If translation exists, we use it, otherwise, we use tha had coded label
$out .= ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
$out .= '</option>';
$i++;
@ -459,6 +460,12 @@ class FormCompany extends Form
}
$out .= '</select>';
if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($addjscombo) {
// Enhance with select2
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
}
} else {
dol_print_error($this->db);
}

View File

@ -81,7 +81,7 @@ DeleteType=Delete
VoteAllowed=Vote allowed
Physical=Physical
Moral=Moral
MorPhy=Moral/Physical
MorPhy=Nature
Reenable=Reenable
ResiliateMember=Terminate a member
ConfirmResiliateMember=Are you sure you want to terminate this member?