From e65e4a6d47f313a6287b144fe465bbbb0fa7ed24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Aug 2020 11:52:00 +0200 Subject: [PATCH] Beautify for of member module --- htdocs/adherents/card.php | 22 +++++++++--------- .../adherents/class/adherent_type.class.php | 15 ++++++------ htdocs/adherents/list.php | 17 +++++++++++--- htdocs/adherents/type.php | 23 +++++++++---------- htdocs/core/class/html.formcompany.class.php | 11 +++++++-- htdocs/langs/en_US/members.lang | 2 +- 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 50ca013886b..2a177ebade4 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -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 ''.$langs->trans("MemberType").''; - $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 ''.$langs->trans("NoTypeDefinedGoToSetup").''; } @@ -862,7 +862,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans("MemberNature")."\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 "\n"; // Company @@ -870,7 +870,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Civility print ''.$langs->trans("UserTitle").''; - print $formcompany->select_civility(GETPOST('civility_id', 'int') ?GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id').''; + print $formcompany->select_civility(GETPOST('civility_id', 'int') ? GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id', 'maxwidth150', 1).''; print ''; // Lastname @@ -885,7 +885,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("Gender").''; print ''; $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 ''; // EMail @@ -1074,13 +1074,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans("MemberNature").''; - 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 ""; // Type print ''.$langs->trans("Type").''; 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 ''; @@ -1092,7 +1092,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Civility print ''.$langs->trans("UserTitle").''; - 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 ''; print ''; @@ -1108,7 +1108,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("Gender").''; print ''; $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 ''; // Photo @@ -1164,7 +1164,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.img_picto('', 'object_phoning').' phone_perso).'">'; // Mobile phone - print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").''; + print ''.$langs->trans("PhoneMobile").''; print ''.img_picto('', 'object_phoning_mobile').' phone_mobile).'">'; if (!empty($conf->socialnetworks->enabled)) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 25df072fbde..3f8a5ce1b25 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -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( diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9c5c6327747..60e10ba44ea 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -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 "".$obj->login."\n"; if (!$i) $totalarray['nbfield']++; } - // Moral/Physique + // Nature (Moral/Physical) if (!empty($arrayfields['d.morphy']['checked'])) { - print "".$memberstatic->getmorphylib($obj->morphy)."\n"; + print ''; + $s = ''; + if ($obj->morphy == 'phy') + { + $s .= ''.dol_substr($langs->trans("Physical"), 0, 1).''; + } + if ($obj->morphy == 'mor') + { + $s .= ''.dol_substr($langs->trans("Moral"), 0, 1).''; + } + print $s; + print "\n"; if (!$i) $totalarray['nbfield']++; } // Type label diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 524ed0e466a..7d744b599de 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -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érents|ES:Módulo_Miembros'); - // List of members type if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); @@ -317,7 +316,7 @@ if ($action == 'create') { print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; - 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 ''; // 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 '
'.$langs->trans("AddMember").'
'; } else { print '
'.$langs->trans("AddMember").'
'; @@ -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 ''; - print $adh->LibStatut($objp->statut, $objp->subscription, $datefin, 2); + print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); print ""; // Date end subscription if ($datefin) { print ''; - 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 ''; if ($objp->subscription == 'yes') { print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); + if ($objp->status > 0) print " ".img_warning(); } else { print ' '; } @@ -720,7 +719,7 @@ if ($rowid > 0) { print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; - 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 ''; // Morphy @@ -741,7 +740,7 @@ if ($rowid > 0) { print ''.$langs->trans("Duration").''; print ' '; - 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 ''; print ''.$langs->trans("Description").''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 8a4346ab7d8..290bf30b0f7 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -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 .= ''; $i++; @@ -459,6 +460,12 @@ class FormCompany extends Form } $out .= ''; 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); } diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index dd0a5bf49e2..5ef946ddf67 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -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?