From 6fad38db574e3ddb4409f01c925fd3ebdf120e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 20:04:40 +0100 Subject: [PATCH 01/14] can add box on member index page --- htdocs/adherents/index.php | 78 +++++++++++++-- htdocs/core/class/infobox.class.php | 96 +++++++++---------- htdocs/index.php | 142 +++++++++++++++------------- 3 files changed, 191 insertions(+), 125 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index b2ef8e8854b..b32b630af0b 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $hookmanager = new HookManager($db); @@ -40,7 +41,24 @@ $langs->loadLangs(array("companies", "members")); // Security check $result = restrictedArea($user, 'adherent'); +if (!isset($form) || !is_object($form)) { + $form = new Form($db); +} +// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$resultboxes = FormOther::getBoxesArea($user, "2"); +if (GETPOST('addbox')) { + // Add box (when submit is done from a form when ajax disabled) + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) { + setEventMessages($langs->trans("BoxAdded"), null); + } +} /* * View @@ -52,7 +70,7 @@ $staticmember = new Adherent($db); $statictype = new AdherentType($db); $subscriptionstatic = new Subscription($db); -print load_fiche_titre($langs->trans("MembersArea"), '', 'members'); +print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); $Adherents = array(); $AdherentsAValider = array(); @@ -85,9 +103,15 @@ if ($result) { $adhtype->label = $objp->label; $AdherentType[$objp->rowid] = $adhtype; - if ($objp->statut == -1) { $MemberToValidate[$objp->rowid] = $objp->somme; } - if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; } - if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; } + if ($objp->statut == -1) { + $MemberToValidate[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 1) { + $MembersValidated[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 0) { + $MembersResiliated[$objp->rowid] = $objp->somme; + } $i++; } @@ -136,10 +160,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel print ''; $i = 0; foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; print ''; - if ($i == 0) print ''; + if ($i == 0) { + print ''; + } print ''; $i++; } @@ -247,7 +275,7 @@ print "\n"; krsort($Total); $i = 0; -foreach ($Total as $key=>$value) { +foreach ($Total as $key => $value) { if ($i >= 8) { print ''; print ""; @@ -449,6 +477,42 @@ print ""; print ''; +// boxes +print '
'; + +print '
'; + + +/* + * Show widgets (boxes) + */ + +$boxlist .= '
'; + +$boxlist .= '
'; +if (!empty($nbworkboardcount)) { + $boxlist .= $boxwork; +} + +$boxlist .= $resultboxes['boxlista']; + +$boxlist .= '
'; + +$boxlist .= '
'; + +$boxlist .= $boxstat; +$boxlist .= $resultboxes['boxlistb']; + +$boxlist .= '
'; +$boxlist .= "\n"; + +$boxlist .= '
'; + + +print $boxlist; + +print '
'; + $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index a4cb7a603dd..cd8cb3fece3 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -37,10 +37,10 @@ class InfoBox { global $conf; - if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) - { + if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) { return array( 0 => 'Home', + 2 => 'membersindex', 27 => 'AccountancyHome' ); } else { @@ -95,16 +95,20 @@ class InfoBox $boxes = array(); $confuserzone = 'MAIN_BOXES_'.$zone; - if ($mode == 'activated') // activated - { + if ($mode == 'activated') { // activated $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql .= " WHERE b.box_id = d.rowid"; $sql .= " AND b.entity IN (0,".$conf->entity.")"; - if ($zone >= 0) $sql .= " AND b.position = ".$zone; - if (is_object($user)) $sql .= " AND b.fk_user IN (0,".$user->id.")"; - else $sql .= " AND b.fk_user = 0"; + if ($zone >= 0) { + $sql .= " AND b.position = ".$zone; + } + if (is_object($user)) { + $sql .= " AND b.fk_user IN (0,".$user->id.")"; + } else { + $sql .= " AND b.fk_user = 0"; + } $sql .= " ORDER BY b.box_order"; } else // available { @@ -115,19 +119,15 @@ class InfoBox dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $j = 0; - while ($j < $num) - { + while ($j < $num) { $obj = $db->fetch_object($resql); - if (!in_array($obj->box_id, $excludelist)) - { + if (!in_array($obj->box_id, $excludelist)) { $regs = array(); - if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) - { + if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { $boxname = preg_replace('/\.php$/i', '', $regs[1]); $module = $regs[2]; $relsourcefile = "/".$module."/core/boxes/".$boxname.".php"; @@ -142,8 +142,7 @@ class InfoBox // the "enabled" condition for modules forbidden for external users and the depends condition can be done. // Goal is to avoid making a "new" done for each boxes returned by select. dol_include_once($relsourcefile); - if (class_exists($boxname)) - { + if (class_exists($boxname)) { $box = new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); @@ -154,14 +153,15 @@ class InfoBox $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile = $relsourcefile; - $box->class = $boxname; + $box->class = $boxname; - if ($mode == 'activated' && !is_object($user)) // List of activated box was not yet personalized into database - { - if (is_numeric($box->box_order)) - { - if ($box->box_order % 2 == 1) $box->box_order = 'A'.$box->box_order; - elseif ($box->box_order % 2 == 0) $box->box_order = 'B'.$box->box_order; + if ($mode == 'activated' && !is_object($user)) { // List of activated box was not yet personalized into database + if (is_numeric($box->box_order)) { + if ($box->box_order % 2 == 1) { + $box->box_order = 'A'.$box->box_order; + } elseif ($box->box_order % 2 == 0) { + $box->box_order = 'B'.$box->box_order; + } } } // box_def properties @@ -171,20 +171,18 @@ class InfoBox // Filter on box->enabled (used for example by box_comptes) // Filter also on box->depends. Example: array("product|service") or array("contrat", "service") $enabled = $box->enabled; - if (isset($box->depends) && count($box->depends) > 0) - { - foreach ($box->depends as $moduleelem) - { + if (isset($box->depends) && count($box->depends) > 0) { + foreach ($box->depends as $moduleelem) { $arrayelem = explode('|', $moduleelem); $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) - foreach ($arrayelem as $module) - { + foreach ($arrayelem as $module) { $tmpmodule = preg_replace('/@[^@]+/', '', $module); - if (!empty($conf->$tmpmodule->enabled)) $tmpenabled = 1; + if (!empty($conf->$tmpmodule->enabled)) { + $tmpenabled = 1; + } //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; } - if (empty($tmpenabled)) // We found at least one module required that is disabled - { + if (empty($tmpenabled)) { // We found at least one module required that is disabled $enabled = 0; break; } @@ -193,8 +191,11 @@ class InfoBox //print '=>'.$boxname.'-enabled='.$enabled.'
'; //print 'xx module='.$module.' enabled='.$enabled; - if ($enabled && ($includehidden || empty($box->hidden))) $boxes[] = $box; - else unset($box); + if ($enabled && ($includehidden || empty($box->hidden))) { + $boxes[] = $box; + } else { + unset($box); + } } else { dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); } @@ -229,7 +230,9 @@ class InfoBox dol_syslog(get_class()."::saveboxorder zone=".$zone." userid=".$userid); - if (!$userid || $userid == 0) return 0; + if (!$userid || $userid == 0) { + return 0; + } $user = new User($db); $user->id = $userid; @@ -240,8 +243,7 @@ class InfoBox $tab = array(); $confuserzone = 'MAIN_BOXES_'.$zone; $tab[$confuserzone] = 1; - if (dol_set_user_param($db, $conf, $user, $tab) < 0) - { + if (dol_set_user_param($db, $conf, $user, $tab) < 0) { $error = $db->lasterror(); $db->rollback(); return -3; @@ -255,11 +257,9 @@ class InfoBox dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $colonnes = explode('-', $boxorder); - foreach ($colonnes as $collist) - { + foreach ($colonnes as $collist) { $part = explode(':', $collist); $colonne = $part[0]; $list = $part[1]; @@ -267,10 +267,8 @@ class InfoBox $i = 0; $listarray = explode(',', $list); - foreach ($listarray as $id) - { - if (is_numeric($id)) - { + foreach ($listarray as $id) { + if (is_numeric($id)) { //dol_syslog("aaaaa".count($listarray)); $i++; $ii = sprintf('%02d', $i); @@ -287,8 +285,7 @@ class InfoBox dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); $result = $db->query($sql); - if ($result < 0) - { + if ($result < 0) { $error++; break; } @@ -299,8 +296,7 @@ class InfoBox $error++; } - if ($error) - { + if ($error) { $db->rollback(); return -2; } else { diff --git a/htdocs/index.php b/htdocs/index.php index a4060278c50..1269191e221 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -30,7 +30,7 @@ require 'main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // If not defined, we select menu "home" -$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ?GETPOST('mainmenu', 'aZ09') : 'home'; +$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home'; $action = GETPOST('action', 'aZ09'); $hookmanager->initHooks(array('index')); @@ -41,18 +41,15 @@ $hookmanager->initHooks(array('index')); */ // Check if company name is defined (first install) -if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) -{ +if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) { header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled -{ +if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } -if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) -{ +if (GETPOST('addbox')) { // Add box (when submit is done from a form when ajax disabled) require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $zone = GETPOST('areacode', 'aZ09'); $userid = GETPOST('userid', 'int'); @@ -60,7 +57,9 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis $boxorder .= GETPOST('boxcombo', 'aZ09'); $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); - if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); + if ($result > 0) { + setEventMessages($langs->trans("BoxAdded"), null); + } } @@ -68,11 +67,15 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis * View */ -if (!isset($form) || !is_object($form)) $form = new Form($db); +if (!isset($form) || !is_object($form)) { + $form = new Form($db); +} // Title $title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; +} llxHeader('', $title); @@ -82,11 +85,9 @@ $resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (select print load_fiche_titre(' ', $resultboxes['selectboxlist'], '', 0, '', 'titleforhome'); -if (!empty($conf->global->MAIN_MOTD)) -{ +if (!empty($conf->global->MAIN_MOTD)) { $conf->global->MAIN_MOTD = preg_replace('//i', '
', $conf->global->MAIN_MOTD); - if (!empty($conf->global->MAIN_MOTD)) - { + if (!empty($conf->global->MAIN_MOTD)) { $substitutionarray = getCommonSubstitutionArray($langs); complete_substitutions_array($substitutionarray, $langs); $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); @@ -113,16 +114,14 @@ $boxstatFromHook = ''; $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts')); // Load global statistics of objects -if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) -{ +if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $object = new stdClass(); $parameters = array(); $action = ''; $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $boxstatFromHook = $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { // Cle array returned by the method load_state_board for each line $keys = array( 'users', @@ -285,18 +284,17 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) // Loop and displays each line of table $boardloaded = array(); - foreach ($keys as $val) - { - if ($conditions[$val]) - { + foreach ($keys as $val) { + if ($conditions[$val]) { $boxstatItem = ''; $class = $classes[$val]; // Search in cache if load_state_board is already realized $classkeyforcache = $class; - if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product + if ($classkeyforcache == 'ProductService') { + $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product + } - if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) - { + if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) { include_once $includes[$val]; // Loading a class cost around 1Mb $board = new $class($db); @@ -471,8 +469,12 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $object = new stdClass(); $parameters = array(); $action = ''; - $reshook = $hookmanager->executeHooks('addOpenElementsDashboardLine', $parameters, $object, - $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks( + 'addOpenElementsDashboardLine', + $parameters, + $object, + $action + ); // Note that $action and $object may have been modified by some hooks if ($reshook == 0) { $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray); } @@ -627,8 +629,10 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $boxwork .= '
'; // Search Group -if ($canreadperms) -{ +if ($canreadperms) { print ''; } @@ -115,13 +132,14 @@ if ($reshook > 0) { } else { $sql .= " WHERE u.entity IN (".getEntity('user').")"; } -if (!empty($socid)) $sql .= " AND u.fk_soc = ".$socid; +if (!empty($socid)) { + $sql .= " AND u.fk_soc = ".$socid; +} $sql .= $db->order("u.datec", "DESC"); $sql .= $db->plimit($max); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); print '
'; @@ -131,8 +149,7 @@ if ($resql) print ''; $i = 0; - while ($i < $num && $i < $max) - { + while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); $fuserstatic->id = $obj->rowid; @@ -153,34 +170,28 @@ if ($resql) print '
'; print '"; print ''; print "'; print '"; - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
:
...
'.$langs->trans("DolibarrWorkBoard").'
'; if ($showweather) { if ($totallate > 0) { - $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", - $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; + $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv( + "NActionsLate", + $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '') + ).')'; } else { $text = $langs->transnoentitiesnoconv("NoItemLate"); } @@ -670,17 +674,17 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $globalStatsKey = $groupElement['globalStatsKey']; $groupElement['globalStats'] = array(); - if (is_array($keys) && in_array($globalStatsKey, $keys)) - { + if (is_array($keys) && in_array($globalStatsKey, $keys)) { // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links $keyIndex = array_search($globalStatsKey, $keys); $classe = $classes[$keyIndex]; - if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) - { + if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) { $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0; $nbTotal = doubleval($groupElement['globalStats']['total']); - if ($nbTotal >= 10000) { $nbTotal = round($nbTotal / 1000, 2).'k'; } + if ($nbTotal >= 10000) { + $nbTotal = round($nbTotal / 1000, 2).'k'; + } $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; $groupElement['globalStats']['total'] = $nbTotal; $groupElement['globalStats']['link'] = $links[$keyIndex]; @@ -767,8 +771,10 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $text = ''; if ($totallate > 0) { - $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", - $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; + $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv( + "NActionsLate", + $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '') + ).')'; } else { $text = $langs->transnoentitiesnoconv("NoItemLate"); } @@ -783,16 +789,24 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $weatherDashBoard .= '
'.$langs->trans('GlobalOpenedElemView').'
'."\n"; if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv("NActionsLate", - price($totallatePercentage).'%').''."\n"; - $weatherDashBoard .= ' '.$langs->trans('NActionsLate', - $totalLateNumber).''."\n"; + $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv( + "NActionsLate", + price($totallatePercentage).'%' + ).''."\n"; + $weatherDashBoard .= ' '.$langs->trans( + 'NActionsLate', + $totalLateNumber + ).''."\n"; } else { - $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv("NActionsLate", - $totalLateNumber).''."\n"; + $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv( + "NActionsLate", + $totalLateNumber + ).''."\n"; if ($totallatePercentage > 0) { - $weatherDashBoard .= ' '.$langs->trans('NActionsLate', - price($totallatePercentage).'%').''."\n"; + $weatherDashBoard .= ' '.$langs->trans( + 'NActionsLate', + price($totallatePercentage).'%' + ).''."\n"; } } @@ -840,8 +854,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $boxwork .= '
'; $boxwork .= ''; //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; - $boxwork .= img_picto($textlate, "warning_white", - 'class="inline-block hideonsmartphone valigntextbottom"').''; + $boxwork .= img_picto( + $textlate, + "warning_white", + 'class="inline-block hideonsmartphone valigntextbottom"' + ).''; $boxwork .= ''; $boxwork .= $board->nbtodolate; $boxwork .= ''; @@ -892,8 +909,7 @@ print '
'; $boxlist .= '
'; $boxlist .= '
'; -if (!empty($nbworkboardcount)) -{ +if (!empty($nbworkboardcount)) { $boxlist .= $boxwork; } @@ -902,8 +918,7 @@ $boxlist .= $resultboxes['boxlista']; $boxlist .= '
'; -if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) -{ +if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { // Remove allready present info in new dash board if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) { foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { @@ -926,8 +941,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) $boxstat .= $boxstatFromHook; - if (is_array($boxstatItems) && count($boxstatItems) > 0) - { + if (is_array($boxstatItems) && count($boxstatItems) > 0) { $boxstat .= implode('', $boxstatItems); } @@ -967,30 +981,26 @@ print '
'; */ // Security warning repertoire install existe (si utilisateur admin) -if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) -{ +if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { $message = ''; // Check if install lock file is present $lockfile = DOL_DATA_ROOT.'/install.lock'; - if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) - { + if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) { $langs->load("errors"); //if (! empty($message)) $message.='
'; $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); } // Conf files must be in read only mode - if (is_writable($conffile)) - { + if (is_writable($conffile)) { $langs->load("errors"); //$langs->load("other"); //if (! empty($message)) $message.='
'; $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); } - if ($message) - { + if ($message) { print $message; //$message.='
'; //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); @@ -1063,20 +1073,16 @@ function getWeatherStatus($totallate) if ($totallate <= $level0) { $weather->picto = 'weather-clear.png'; $weather->level = 0; - } - elseif ($totallate <= $level1) { + } elseif ($totallate <= $level1) { $weather->picto = 'weather-few-clouds.png'; $weather->level = 1; - } - elseif ($totallate <= $level2) { + } elseif ($totallate <= $level2) { $weather->picto = 'weather-clouds.png'; $weather->level = 2; - } - elseif ($totallate <= $level3) { + } elseif ($totallate <= $level3) { $weather->picto = 'weather-many-clouds.png'; $weather->level = 3; - } - else { + } else { $weather->picto = 'weather-storm.png'; $weather->level = 4; } From bd874a136e9d8727b849560819659fdc893cb9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 20:10:29 +0100 Subject: [PATCH 02/14] can add box on member index page --- htdocs/adherents/index.php | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index b32b630af0b..f02fb224a2a 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -479,35 +479,19 @@ print '
'; // boxes print '
'; - print '
'; - -/* - * Show widgets (boxes) - */ - -$boxlist .= '
'; +$boxlist = '
'; $boxlist .= '
'; -if (!empty($nbworkboardcount)) { - $boxlist .= $boxwork; -} - $boxlist .= $resultboxes['boxlista']; - -$boxlist .= '
'; +$boxlist .= '
'."\n"; $boxlist .= '
'; - -$boxlist .= $boxstat; $boxlist .= $resultboxes['boxlistb']; +$boxlist .= '
'."\n"; $boxlist .= '
'; -$boxlist .= "\n"; - -$boxlist .= '
'; - print $boxlist; From 5dd0b3b1c61185ed1493d4e6e392175ab81183a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 20:20:22 +0100 Subject: [PATCH 03/14] can add box on user home page --- htdocs/core/class/infobox.class.php | 1 + htdocs/user/home.php | 103 ++++++++++++++++++---------- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index cd8cb3fece3..f3e392b849b 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -40,6 +40,7 @@ class InfoBox if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) { return array( 0 => 'Home', + 1 => 'userhome', 2 => 'membersindex', 27 => 'AccountancyHome' ); diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 4d215685f53..816242f41fc 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -24,11 +24,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search -if (!$user->rights->user->user->lire && !$user->admin) -{ +if (!$user->rights->user->user->lire && !$user->admin) { // Redirection vers la page de l'utilisateur header("Location: card.php?id=".$user->id); exit; @@ -38,21 +38,39 @@ if (!$user->rights->user->user->lire && !$user->admin) $langs->load("users"); $canreadperms = true; -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) -{ +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $canreadperms = ($user->admin || $user->rights->user->group_advance->read); } // Security check (for external users) $socid = 0; -if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + $socid = $user->socid; +} $companystatic = new Societe($db); $fuserstatic = new User($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('userhome')); +if (!isset($form) || !is_object($form)) { + $form = new Form($db); +} +// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$resultboxes = FormOther::getBoxesArea($user, "1"); +if (GETPOST('addbox')) { + // Add box (when submit is done from a form when ajax disabled) + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) { + setEventMessages($langs->trans("BoxAdded"), null); + } +} /* * View @@ -61,7 +79,7 @@ $hookmanager->initHooks(array('userhome')); llxHeader(); -print load_fiche_titre($langs->trans("MenuUsersAndGroups"), '', 'user'); +print load_fiche_titre($langs->trans("MenuUsersAndGroups"), $resultboxes['selectboxlist'], 'user'); print '
'; @@ -77,8 +95,7 @@ print '
'; print $langs->trans("User").':
'; print $langs->trans("Group").':
'; print $fuserstatic->getNomUrl(-1); - if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) - { + if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { print img_picto($langs->trans("SuperAdministrator"), 'redstar'); - } elseif ($obj->admin) - { + } elseif ($obj->admin) { print img_picto($langs->trans("Administrator"), 'star'); } print "'.$obj->login.'"; - if ($obj->fk_soc) - { + if ($obj->fk_soc) { print $companystatic->getNomUrl(1); } else { print $langs->trans("InternalUser"); } - if ($obj->ldap_sid) - { + if ($obj->ldap_sid) { print ' ('.$langs->trans("DomainUser").')'; } $entity = $obj->entity; $entitystring = ''; // TODO Set of entitystring should be done with a hook - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($entity)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { + if (empty($entity)) { $entitystring = $langs->trans("AllEntities"); } else { $mc->getInfo($entity); @@ -210,14 +221,12 @@ if ($resql) /* * Last groups created */ -if ($canreadperms) -{ +if ($canreadperms) { $max = 5; $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) - { + if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && !$user->entity))) { $sql .= " WHERE g.entity IS NOT NULL"; } else { $sql .= " WHERE g.entity IN (0,".$conf->entity.")"; @@ -226,10 +235,11 @@ if ($canreadperms) $sql .= $db->plimit($max); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $colspan = 1; - if (!empty($conf->multicompany->enabled)) $colspan++; + if (!empty($conf->multicompany->enabled)) { + $colspan++; + } $num = $db->num_rows($resql); print '
'; @@ -241,8 +251,7 @@ if ($canreadperms) $grouptemp = new UserGroup($db); - while ($i < $num && (!$max || $i < $max)) - { + while ($i < $num && (!$max || $i < $max)) { $obj = $db->fetch_object($resql); $grouptemp->id = $obj->rowid; @@ -252,13 +261,11 @@ if ($canreadperms) print '
'; print $grouptemp->getNomUrl(1); - if (!$obj->entity) - { + if (!$obj->entity) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print "'; print $mc->label; @@ -280,6 +287,26 @@ if ($canreadperms) //print '
'; print ''; +// boxes +print '
'; +print '
'; + +$boxlist = '
'; + +$boxlist .= '
'; +$boxlist .= $resultboxes['boxlista']; +$boxlist .= '
'."\n"; + +$boxlist .= '
'; +$boxlist .= $resultboxes['boxlistb']; +$boxlist .= '
'."\n"; + +$boxlist .= '
'; + +print $boxlist; + +print '
'; + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardUsersGroups', $parameters, $object); // Note that $action and $object may have been modified by hook From 96fbee5eaf7a166521cde008afda2d9fcef53875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 21:01:47 +0100 Subject: [PATCH 04/14] transform into box --- htdocs/core/modules/modAdherent.class.php | 39 +++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 1db3e2b7d50..8fd6aa75682 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -193,7 +193,8 @@ class modAdherent extends DolibarrModules //------- $this->boxes = array( 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home') + 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), + 3=>array('file'=>'box_last_modified_members', 'enabledbydefaulton'=>'membersindex'), ); // Permissions @@ -341,10 +342,8 @@ class modAdherent extends DolibarrModules // Add extra fields $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { // This can fail when class is used on old database (during migration for example) + while ($obj = $this->db->fetch_object($resql)) { $fieldname = 'extra.'.$obj->name; $fieldlabel = ucfirst($obj->label); $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); @@ -399,24 +398,22 @@ class modAdherent extends DolibarrModules // Permissions $this->remove($options); - //ODT template + // ODT template /* - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; - $dest=$dirodt.'/template_order.odt'; + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; + $dest=$dirodt.'/template_order.odt'; - if (file_exists($src) && ! file_exists($dest)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_mkdir($dirodt); - $result=dol_copy($src,$dest,0,0); - if ($result < 0) - { - $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); - return 0; - } - }*/ + if (file_exists($src) && ! file_exists($dest)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + }*/ $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".$conf->entity, From 8f3e6df3e18430aa7c94692ea0b1ca87c9bda854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 21:03:04 +0100 Subject: [PATCH 05/14] transform into box --- .../core/boxes/box_last_modified_members.php | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 htdocs/core/boxes/box_last_modified_members.php diff --git a/htdocs/core/boxes/box_last_modified_members.php b/htdocs/core/boxes/box_last_modified_members.php new file mode 100644 index 00000000000..ce2868a9b43 --- /dev/null +++ b/htdocs/core/boxes/box_last_modified_members.php @@ -0,0 +1,191 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_modified_members.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_last_modified_members extends ModeleBoxes +{ + public $boxcode = "box_last_modified_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastModifiedMembers"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $memberstatic = new Adherent($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); + + if ($user->rights->adherent->lire) { + $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; + $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= ' a.photo, a.email, a.gender, a.morphy,'; + $sql .= " t.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = t.rowid"; + $sql .= " ORDER BY a.tms DESC"; + $sql .= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + + $memberstatic->lastname = $objp->lastname; + $memberstatic->firstname = $objp->firstname; + $memberstatic->id = $objp->rowid; + $memberstatic->ref = $objp->rowid; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; + $memberstatic->company = $objp->company; + $memberstatic->statut = $objp->status; + + if (!empty($objp->fk_soc)) { + $memberstatic->socid = $objp->fk_soc; + $memberstatic->fetch_thirdparty(); + $memberstatic->name = $memberstatic->thirdparty->name; + } else { + $memberstatic->name = $objp->company; + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->getNomUrl(-1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->company, + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} From bd762bc58f11181155cba04a1849636fe8bd387e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 21:50:58 +0100 Subject: [PATCH 06/14] boxes --- htdocs/adherents/index.php | 7 ++++--- .../core/boxes/box_last_modified_members.php | 18 ++++++++++++------ htdocs/core/boxes/box_members.php | 12 ++++++++---- htdocs/langs/en_US/boxes.lang | 5 +++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index f02fb224a2a..37db10c5321 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -310,9 +310,10 @@ print '
'; /* * Latest modified members */ +/* $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql = "SELECT a.rowid, a.ref, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.gender, a.email, a.photo, a.morphy,"; $sql .= " a.tms as datem, a.datefin as date_end_subscription,"; $sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription"; @@ -336,7 +337,7 @@ if ($resql) { $obj = $db->fetch_object($resql); $staticmember->id = $obj->rowid; - $staticmember->ref = $obj->rowid; + $staticmember->ref = $obj->ref; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; $staticmember->gender = $obj->gender; @@ -372,7 +373,7 @@ if ($resql) { } else { dol_print_error($db); } - +*/ /* * Last modified subscriptions diff --git a/htdocs/core/boxes/box_last_modified_members.php b/htdocs/core/boxes/box_last_modified_members.php index ce2868a9b43..e96858cb292 100644 --- a/htdocs/core/boxes/box_last_modified_members.php +++ b/htdocs/core/boxes/box_last_modified_members.php @@ -84,15 +84,17 @@ class box_last_modified_members extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $memberstatic = new Adherent($this->db); + $statictype = new AdherentType($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); if ($user->rights->adherent->lire) { - $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; + $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; - $sql .= " t.subscription"; + $sql .= " t.rowid as typeid, t.subscription, t.libelle as label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; $sql .= " AND a.fk_adherent_type = t.rowid"; @@ -112,14 +114,15 @@ class box_last_modified_members extends ModeleBoxes $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; + $memberstatic->ref = $objp->ref; $memberstatic->photo = $objp->photo; $memberstatic->gender = $objp->gender; $memberstatic->email = $objp->email; $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; $memberstatic->statut = $objp->status; - + $memberstatic->need_subscription = $objp->subscription; + $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; $memberstatic->fetch_thirdparty(); @@ -127,6 +130,9 @@ class box_last_modified_members extends ModeleBoxes } else { $memberstatic->name = $objp->company; } + $statictype->id = $objp->typeid; + $statictype->label = $objp->label; + $statictype->subscription = $objp->subscription; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', @@ -136,8 +142,8 @@ class box_last_modified_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->company, - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + 'text' => $statictype->getNomUrl(1, 32), + 'asis' => 1, ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2d0ad45a266..13e00aafcaf 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -63,7 +63,9 @@ class box_members extends ModeleBoxes // disable module for such cases $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } $this->hidden = !($user->rights->adherent->lire); } @@ -90,7 +92,7 @@ class box_members extends ModeleBoxes $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; - $sql .= " t.subscription"; + $sql .= " t.subscription, t.libelle as label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; $sql .= " AND a.fk_adherent_type = t.rowid"; @@ -117,7 +119,8 @@ class box_members extends ModeleBoxes $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; $memberstatic->statut = $objp->status; - + $memberstatic->need_subscription = $objp->subscription; + $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; $memberstatic->fetch_thirdparty(); @@ -151,11 +154,12 @@ class box_members extends ModeleBoxes $line++; } - if ($num == 0) + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"), ); + } $this->db->free($result); } else { diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b8ba5073d03..451da31cb5f 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -17,6 +17,7 @@ BoxLastActions=Latest actions BoxLastContracts=Latest contracts BoxLastContacts=Latest contacts/addresses BoxLastMembers=Latest members +BoxLastModifiedMembers=Latest modified members BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) @@ -86,8 +87,8 @@ BoxTitleLatestModifiedSupplierOrders=Vendor Orders: last %s modified BoxTitleLastModifiedCustomerBills=Customer Invoices: last %s modified BoxTitleLastModifiedCustomerOrders=Sales Orders: last %s modified BoxTitleLastModifiedPropals=Latest %s modified proposals -BoxTitleLatestModifiedJobPositions=Latest %s modified jobs -BoxTitleLatestModifiedCandidatures=Latest %s modified candidatures +BoxTitleLatestModifiedJobPositions=Latest %s modified jobs +BoxTitleLatestModifiedCandidatures=Latest %s modified candidatures ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders ForProposals=Proposals From dc6c1b8d3bd3e64280b57bc0a017b3b07cd03ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 22:12:19 +0100 Subject: [PATCH 07/14] boxes --- htdocs/core/boxes/box_members.php | 4 ++-- htdocs/core/modules/DolibarrModules.class.php | 21 ++++++++++++------- htdocs/core/modules/modAdherent.class.php | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 13e00aafcaf..a8744e10a8a 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -89,7 +89,7 @@ class box_members extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); if ($user->rights->adherent->lire) { - $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; + $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; $sql .= " t.subscription, t.libelle as label"; @@ -112,7 +112,7 @@ class box_members extends ModeleBoxes $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; + $memberstatic->ref = $objp->ref; $memberstatic->photo = $objp->photo; $memberstatic->gender = $objp->gender; $memberstatic->email = $objp->email; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 510ec8ef55a..467856a642c 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1157,16 +1157,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $note = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : ''; $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home'; - if (empty($file)) { $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility + if (empty($file)) { + $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : ''; // For backward compatibility } - if (empty($note)) { $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility + if (empty($note)) { + $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : ''; // For backward compatibility } // Search if boxes def already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."boxes_def"; $sql .= " WHERE file = '".$this->db->escape($file)."'"; $sql .= " AND entity = ".$conf->entity; - if ($note) { $sql .= " AND note ='".$this->db->escape($note)."'"; + if ($note) { + $sql .= " AND note ='".$this->db->escape($note)."'"; } $result = $this->db->query($sql); @@ -1192,8 +1195,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it foreach ($pos_name as $key2 => $val2) { - //print 'key2='.$key2.'-val2='.$val2."
\n"; - if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { continue; // Not enabled by default onto this page. + //print 'key2='.$key2.'-val2='.$val2."
\n"; + if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { + continue; // Not enabled by default onto this page. } $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)"; @@ -1201,7 +1205,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $err++; + if (!$resql) { + $err++; } } } @@ -1209,8 +1214,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if (!$err) { $this->db->commit(); } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); + $this->error = $this->db->lasterror(); + $this->db->rollback(); } } // else box already registered into database diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 8fd6aa75682..d38dee47611 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -195,6 +195,7 @@ class modAdherent extends DolibarrModules 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), 3=>array('file'=>'box_last_modified_members', 'enabledbydefaulton'=>'membersindex'), + 4=>array('file'=>'box_last_members_subscriptions', 'enabledbydefaulton'=>'membersindex'), ); // Permissions From 7291bf34f0b888f688b94cd97a3205123d2ea4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 22:29:23 +0100 Subject: [PATCH 08/14] boxes --- htdocs/adherents/index.php | 3 +- .../boxes/box_last_members_subscriptions.php | 202 ++++++++++++++++++ .../core/boxes/box_last_modified_members.php | 2 +- 3 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 htdocs/core/boxes/box_last_members_subscriptions.php diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 37db10c5321..9b7ab88acc0 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -378,6 +378,7 @@ if ($resql) { /* * Last modified subscriptions */ +/* $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; @@ -443,7 +444,7 @@ if ($resql) { } else { dol_print_error($db); } - +*/ // Summary of members by type print '
'; diff --git a/htdocs/core/boxes/box_last_members_subscriptions.php b/htdocs/core/boxes/box_last_members_subscriptions.php new file mode 100644 index 00000000000..0b2cb02d920 --- /dev/null +++ b/htdocs/core/boxes/box_last_members_subscriptions.php @@ -0,0 +1,202 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_members_subscriptions.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_last_members_subscriptions extends ModeleBoxes +{ + public $boxcode = "box_last_members_subscriptions"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembersSubscriptions"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + $staticmember = new Adherent($this->db); + $statictype = new AdherentType($this->db); + $subscriptionstatic = new Subscription($this->db); + + $this->info_box_head = array('text' => $langs->trans("LastSubscriptionsModified", $max)); + + if ($user->rights->adherent->lire) { + $sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; + $sql .= " a.gender, a.email, a.photo, a.morphy,"; + $sql .= " a.datefin as date_end_subscription,"; + $sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,"; + $sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " WHERE a.entity IN (".getEntity('adherent').")"; + $sql .= " AND a.fk_adherent_type = ta.rowid"; + $sql .= " AND c.fk_adherent = a.rowid"; + $sql .= $this->db->order("c.tms", "DESC"); + $sql .= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $obj = $this->db->fetch_object($result); + $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; + $staticmember->statut = $obj->status; + $staticmember->need_subscription = $obj->need_subscription; + $staticmember->datefin = $this->db->jdate($obj->date_end_subscription); + if (!empty($obj->fk_soc)) { + $staticmember->fk_soc = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name = $staticmember->thirdparty->name; + } else { + $staticmember->name = $obj->company; + } + + $subscriptionstatic->id = $obj->cid; + $subscriptionstatic->ref = $obj->cid; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $subscriptionstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $staticmember->getNomUrl(-1, 32, 'subscription'), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => get_date_range($this->db->jdate($obj->date_start), $this->db->jdate($obj->date_end)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => price($obj->subscription), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => dol_print_date($this->db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour'), + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_last_modified_members.php b/htdocs/core/boxes/box_last_modified_members.php index e96858cb292..9ec1bf70558 100644 --- a/htdocs/core/boxes/box_last_modified_members.php +++ b/htdocs/core/boxes/box_last_modified_members.php @@ -86,7 +86,7 @@ class box_last_modified_members extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $memberstatic = new Adherent($this->db); - $statictype = new AdherentType($db); + $statictype = new AdherentType($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); From 742c12f9d684097cf96b9f1903d9fe44f82a00e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 20:58:21 +0100 Subject: [PATCH 09/14] rename new boxes --- ...ast_modified_members.php => box_members_last_modified.php} | 0 ...s_subscriptions.php => box_members_last_subscriptions.php} | 0 htdocs/core/modules/modAdherent.class.php | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename htdocs/core/boxes/{box_last_modified_members.php => box_members_last_modified.php} (100%) rename htdocs/core/boxes/{box_last_members_subscriptions.php => box_members_last_subscriptions.php} (100%) diff --git a/htdocs/core/boxes/box_last_modified_members.php b/htdocs/core/boxes/box_members_last_modified.php similarity index 100% rename from htdocs/core/boxes/box_last_modified_members.php rename to htdocs/core/boxes/box_members_last_modified.php diff --git a/htdocs/core/boxes/box_last_members_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php similarity index 100% rename from htdocs/core/boxes/box_last_members_subscriptions.php rename to htdocs/core/boxes/box_members_last_subscriptions.php diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 9e402ab3b72..1d2601d0430 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -194,8 +194,8 @@ class modAdherent extends DolibarrModules $this->boxes = array( 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_last_modified_members', 'enabledbydefaulton'=>'membersindex'), - 4=>array('file'=>'box_last_members_subscriptions', 'enabledbydefaulton'=>'membersindex'), + 3=>array('file'=>'box_members_last_modified', 'enabledbydefaulton'=>'membersindex'), + 4=>array('file'=>'box_members_last_subscriptions', 'enabledbydefaulton'=>'membersindex'), ); // Permissions From d68de8617b4950b0a84bb09e70ed64e0beae8304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 22:00:09 +0100 Subject: [PATCH 10/14] new box replace --- htdocs/adherents/index.php | 170 ----------- htdocs/core/boxes/box_members_by_type.php | 277 ++++++++++++++++++ .../box_members_subscriptions_by_year.php | 132 +++++++++ htdocs/core/modules/modAdherent.class.php | 10 +- htdocs/langs/en_US/boxes.lang | 1 + 5 files changed, 416 insertions(+), 174 deletions(-) create mode 100644 htdocs/core/boxes/box_members_by_type.php create mode 100644 htdocs/core/boxes/box_members_subscriptions_by_year.php diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 9b7ab88acc0..72113767620 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -307,176 +307,6 @@ print "
\n"; print '
'; -/* - * Latest modified members - */ -/* -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - -$sql = "SELECT a.rowid, a.ref, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " a.gender, a.email, a.photo, a.morphy,"; -$sql .= " a.tms as datem, a.datefin as date_end_subscription,"; -$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; -$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; -$sql .= " AND a.fk_adherent_type = ta.rowid"; -$sql .= $db->order("a.tms", "DESC"); -$sql .= $db->plimit($max, 0); - -$resql = $db->query($sql); -if ($resql) { - print '
'; - print ''; - print ''; - print ''; - - $num = $db->num_rows($resql); - if ($num) { - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $staticmember->id = $obj->rowid; - $staticmember->ref = $obj->ref; - $staticmember->lastname = $obj->lastname; - $staticmember->firstname = $obj->firstname; - $staticmember->gender = $obj->gender; - $staticmember->email = $obj->email; - $staticmember->photo = $obj->photo; - $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; - $staticmember->need_subscription = $obj->need_subscription; - $staticmember->datefin = $db->jdate($obj->date_end_subscription); - if (!empty($obj->fk_soc)) { - $staticmember->fk_soc = $obj->fk_soc; - $staticmember->fetch_thirdparty(); - $staticmember->name = $staticmember->thirdparty->name; - } else { - $staticmember->name = $obj->company; - } - - $statictype->id = $obj->typeid; - $statictype->label = $obj->label; - $statictype->subscription = $obj->need_subscription; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } - print "
'.$langs->trans("LastMembersModified", $max).'
'.$staticmember->getNomUrl(-1, 32).''.$statictype->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmember->getLibStatut(3).'
"; - print "
"; -} else { - dol_print_error($db); -} -*/ - -/* - * Last modified subscriptions - */ -/* -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - -$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " a.gender, a.email, a.photo, a.morphy,"; -$sql .= " a.datefin as date_end_subscription,"; -$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,"; -$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c"; -$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; -$sql .= " AND a.fk_adherent_type = ta.rowid"; -$sql .= " AND c.fk_adherent = a.rowid"; -$sql .= $db->order("c.tms", "DESC"); -$sql .= $db->plimit($max, 0); - -$resql = $db->query($sql); -if ($resql) { - print '
'; - print ''; - print ''; - print ''; - - $num = $db->num_rows($resql); - if ($num) { - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $staticmember->id = $obj->rowid; - $staticmember->ref = $obj->rowid; - $staticmember->lastname = $obj->lastname; - $staticmember->firstname = $obj->firstname; - $staticmember->gender = $obj->gender; - $staticmember->email = $obj->email; - $staticmember->photo = $obj->photo; - $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; - $staticmember->need_subscription = $obj->need_subscription; - $staticmember->datefin = $db->jdate($obj->date_end_subscription); - if (!empty($obj->fk_soc)) { - $staticmember->fk_soc = $obj->fk_soc; - $staticmember->fetch_thirdparty(); - $staticmember->name = $staticmember->thirdparty->name; - } else { - $staticmember->name = $obj->company; - } - - $subscriptionstatic->id = $obj->cid; - $subscriptionstatic->ref = $obj->cid; - - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - $i++; - } - } - print "
'.$langs->trans("LastSubscriptionsModified", $max).'
'.$subscriptionstatic->getNomUrl(1).''.$staticmember->getNomUrl(-1, 32, 'subscription').''.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).''.price($obj->subscription).''.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''.dol_print_date($db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour').'
"; - print "
"; -} else { - dol_print_error($db); -} -*/ - -// Summary of members by type -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -foreach ($AdherentType as $key => $adhtype) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -print "
'.$langs->trans("MembersTypes").''.$langs->trans("MembersStatusToValid").''.$langs->trans("OutOfDate").''.$langs->trans("UpToDate").''.$langs->trans("MembersStatusResiliated").'
'.$adhtype->getNomUrl(1, dol_size(32)).''.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''.(isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''.(isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'
'.$langs->trans("Total").''.$SommeA.' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''.$SommeB.' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''.$SommeC.' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''.$SommeD.' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'
\n"; -print "
"; - print '
'; // boxes diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php new file mode 100644 index 00000000000..5d32f9663d5 --- /dev/null +++ b/htdocs/core/boxes/box_members_by_type.php @@ -0,0 +1,277 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_by_type.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_by_type extends ModeleBoxes +{ + public $boxcode = "box_members_by_type"; + public $boximg = "object_user"; + public $boxlabel = "BoxMembersByType"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; + $staticmember = new Adherent($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); + + if ($user->rights->adherent->lire) { + $MembersToValidate = array(); + $MembersValidated = array(); + $MemberUpToDate = array(); + $MembersResiliated = array(); + + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + + $AdherentType = array(); + + // Type of membership + $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; + $sql .= " d.statut, count(d.rowid) as somme"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent as d"; + $sql .= " ON t.rowid = d.fk_adherent_type"; + $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " WHERE t.entity IN (" . getEntity('member_type') . ")"; + $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + + $adhtype = new AdherentType($this->db); + $adhtype->id = $objp->rowid; + $adhtype->subscription = $objp->subscription; + $adhtype->label = $objp->label; + $AdherentType[$objp->rowid] = $adhtype; + + if ($objp->statut == -1) { + $MembersToValidate[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 1) { + $MembersValidated[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 0) { + $MembersResiliated[$objp->rowid] = $objp->somme; + } + + $i++; + } + $this->db->free($result); + $now = dol_now(); + + // Members up to date list + // current rule: uptodate = the end date is in future whatever is type + // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) + $sql = "SELECT count(*) as somme , d.fk_adherent_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.statut = 1 AND (d.datefin >= '" . $this->db->idate($now) . "' OR t.subscription = 0)"; + $sql .= " AND t.rowid = d.fk_adherent_type"; + $sql .= " GROUP BY d.fk_adherent_type"; + + dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num2 = $this->db->num_rows($result); + $i = 0; + while ($i < $num2) { + $objp = $this->db->fetch_object($result); + $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; + $i++; + } + $this->db->free($result); + } + + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_titre"', + 'text' => $langs->trans("MembersTypes"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusToValid"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("OutOfDate"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("UpToDate"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusResiliated"), + ); + $line++; + foreach ($AdherentType as $key => $adhtype) { + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $adhtype->getNomUrl(1, dol_size(32)), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '') . ' ' . $staticmember->LibStatut(-1, $adhtype->subscription, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(1, $adhtype->subscription, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, $adhtype->subscription, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '') . ' ' . $staticmember->LibStatut(0, $adhtype->subscription, 0, 3), + 'asis' => 1, + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoRecordedMembersByType"), + ); + } else { + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeA.' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeB.' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeC.' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeD.' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php new file mode 100644 index 00000000000..c16933c5d3c --- /dev/null +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -0,0 +1,132 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2021 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_subscriptions_by_year.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_subscriptions_by_year extends ModeleBoxes +{ + public $boxcode = "box_members_subscriptions_by_year"; + public $boximg = "object_user"; + public $boxlabel = "BoxMembersSubscriptionsByYear"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $memberstatic = new Adherent($this->db); + $statictype = new AdherentType($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersSubscriptionsByYear", $max)); + + if ($user->rights->adherent->lire) { + $num = 0; + $line = 0; + if (1) { + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedMembers"), + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 1d2601d0430..74c67d217d6 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -192,10 +192,12 @@ class modAdherent extends DolibarrModules // Boxes //------- $this->boxes = array( - 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), - 3=>array('file'=>'box_members_last_modified', 'enabledbydefaulton'=>'membersindex'), - 4=>array('file'=>'box_members_last_subscriptions', 'enabledbydefaulton'=>'membersindex'), + 0 => array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), + 2 => array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), + 3 => array('file'=>'box_members_last_modified', 'enabledbydefaulton'=>'membersindex'), + 4 => array('file'=>'box_members_last_subscriptions', 'enabledbydefaulton'=>'membersindex'), + 5 => array('file'=>'box_members_subscriptions_by_year', 'enabledbydefaulton'=>'membersindex'), + 6 => array('file'=>'box_members_by_type', 'enabledbydefaulton'=>'membersindex'), ); // Permissions diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index fe992b439d1..b6bdda7100e 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -22,6 +22,7 @@ BoxLastModifiedMembers=Latest modified members BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) +BoxTitleMembersByType=Members by type BoxTitleLastRssInfos=Latest %s news from %s BoxTitleLastProducts=Products/Services: last %s modified BoxTitleProductsAlertStock=Products: stock alert From 22bc3b879b0570933f9e79170e4f43bd6e9bccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 22:21:34 +0100 Subject: [PATCH 11/14] new box replace --- htdocs/adherents/index.php | 68 ---------- .../box_members_subscriptions_by_year.php | 128 ++++++++++++++++-- htdocs/langs/en_US/boxes.lang | 1 + 3 files changed, 120 insertions(+), 77 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 72113767620..4faa9b894b1 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -237,74 +237,6 @@ if ($conf->use_javascript_ajax) { print '
'; -// List of subscription by year -$Total = array(); -$Number = array(); -$tot = 0; -$numb = 0; - -$sql = "SELECT c.subscription, c.dateadh as dateh"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.rowid = c.fk_adherent"; - - -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - $year = dol_print_date($db->jdate($objp->dateh), "%Y"); - $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; - $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; - $tot += $objp->subscription; - $numb += 1; - $i++; - } -} - -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -krsort($Total); -$i = 0; -foreach ($Total as $key => $value) { - if ($i >= 8) { - print ''; - print ""; - print ""; - print ""; - print ""; - print "\n"; - break; - } - print ''; - print ""; - print ""; - print ""; - print ""; - print "\n"; - $i++; -} - -// Total -print ''; -print ''; -print ""; -print '"; -print ""; -print "\n"; -print "
'.$langs->trans("Year").''.$langs->trans("Subscriptions").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
...
$key".$Number[$key]."".price($value)."".price(price2num($value / $Number[$key], 'MT'))."
'.$langs->trans("Total").'".$numb."'.price($tot)."".price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT'))."
"; -print "
\n"; - - print '
'; print '
'; diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index c16933c5d3c..55a11339c0f 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -24,7 +24,7 @@ * \brief Module to show box of members */ -include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; /** @@ -83,8 +83,8 @@ class box_members_subscriptions_by_year extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; $memberstatic = new Adherent($this->db); $statictype = new AdherentType($this->db); @@ -93,20 +93,130 @@ class box_members_subscriptions_by_year extends ModeleBoxes if ($user->rights->adherent->lire) { $num = 0; $line = 0; - if (1) { + // List of subscription by year + $Total = array(); + $Number = array(); + $tot = 0; + $numb = 0; + + $sql = "SELECT c.subscription, c.dateadh as dateh"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "subscription as c"; + $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.rowid = c.fk_adherent"; + + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $year = dol_print_date($this->db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } + + + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_titre"', + 'text' => $langs->trans("Year"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("Subscriptions"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("AmountTotal"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("AmountAverage"), + ); + + $line++; + + krsort($Total); + $i = 0; + foreach ($Total as $key => $value) { + if ($i >= 8) { + // print ''; + // print "..."; + // print ""; + // print ""; + // print ""; + // print "\n"; + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => '...', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $line++; + break; + } + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => ''.$key.'', + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $Number[$key], + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => price($value), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => price(price2num($value / $Number[$key], 'MT')), + ); + $line++; + } + if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedMembers"), + 'text' => $langs->trans("NoRecordedMembers"), + ); + } else { + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $numb, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => price($tot), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')), ); } - - $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql), ); } } else { diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b6bdda7100e..6e70999fd77 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -23,6 +23,7 @@ BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) BoxTitleMembersByType=Members by type +BoxTitleMembersSubscriptionsByYear=Members Subscriptions by year BoxTitleLastRssInfos=Latest %s news from %s BoxTitleLastProducts=Products/Services: last %s modified BoxTitleProductsAlertStock=Products: stock alert From da038cf590eaef377bdd92bb82b3f68d01442b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 22:29:02 +0100 Subject: [PATCH 12/14] new box replace --- htdocs/adherents/index.php | 64 +++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 4faa9b894b1..8c2d64dad39 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -143,10 +143,7 @@ if ($result) { $db->free(); } - -print '
'; - - +$searchbox = ''; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo // Search contact/address if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { @@ -154,27 +151,27 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel } if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print ''; + $searchbox .=''; + $searchbox .=''; + $searchbox .='
'; + $searchbox .='
'; $i = 0; foreach ($listofsearchfields as $key => $value) { if ($i == 0) { - print ''; + $searchbox .=''; } - print ''; - print ''; + $searchbox .=''; + $searchbox .=''; if ($i == 0) { - print ''; + $searchbox .=''; } - print ''; + $searchbox .=''; $i++; } - print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
:
:
'; - print '
'; - print '
'; - print '
'; + $searchbox .=''; + $searchbox .='
'; + $searchbox .=''; + $searchbox .='
'; } } @@ -182,12 +179,12 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel /* * Statistics */ - +$boxgraph = ''; if ($conf->use_javascript_ajax) { - print '
'; - print ''; - print ''; - print ''; + $boxgraph .= ''; + $boxgraph .= '
'.$langs->trans("Statistics").'
'; + $boxgraph .='
'; + $boxgraph .=''; + $boxgraph .=''; + $boxgraph .=''; - print ''; - print '
'.$langs->trans("Statistics").'
'; $SommeA = 0; $SommeB = 0; @@ -225,22 +222,17 @@ if ($conf->use_javascript_ajax) { $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + $boxgraph .=$dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '
'; - print '
'; + $boxgraph .= '
'.$langs->trans("Total").''; + $boxgraph .= $SommeA + $SommeB + $SommeC + $SommeD; + $boxgraph .= '
'; + $boxgraph .= '
'; + $boxgraph .= '
'; } -print '
'; - -print '
'; - -print '
'; - // boxes print '
'; print '
'; @@ -248,6 +240,8 @@ print '
'; $boxlist = '
'; $boxlist .= '
'; +$boxlist .= $searchbox; +$boxlist .= $boxgraph; $boxlist .= $resultboxes['boxlista']; $boxlist .= '
'."\n"; From b0f735350f4c5b2257a6c56b397c335ab64462de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 22:31:55 +0100 Subject: [PATCH 13/14] new box replace --- htdocs/adherents/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 8c2d64dad39..14c3a5c51ec 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 6c30eca11d59a501db9ff925d552de39930e60fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 22:41:20 +0100 Subject: [PATCH 14/14] user home --- htdocs/user/home.php | 119 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 06032349e23..dfb201bc441 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -82,37 +82,32 @@ llxHeader(); print load_fiche_titre($langs->trans("MenuUsersAndGroups"), $resultboxes['selectboxlist'], 'user'); -print '
'; - - // Search User -print '
'; -print ''; +$searchbox = ''; +$searchbox .= ''; -print ''; -print ''; -print ''; +$searchbox .= '
'.$langs->trans("Search").'
'; -print $langs->trans("User").':
'; +$searchbox .= ''; +$searchbox .= ''; // Search Group if ($canreadperms) { - print ''; + $searchbox .= ''; } -print ''; -print "
'.$langs->trans("Search").'
'; +$searchbox .= $langs->trans("User").':
'; - print $langs->trans("Group").':
'; + $searchbox .= $langs->trans("Group").':

\n"; +$searchbox .= ''; +$searchbox .= "
\n"; -print '
'; - -print '
'; +$searchbox .= ''; /* * Latest created users */ $max = 10; - +$lastcreatedbox = ''; $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut"; $sql .= ", u.entity"; $sql .= ", u.ldap_sid"; @@ -142,11 +137,11 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; - print ''."\n"; + $lastcreatedbox .='
'; + $lastcreatedbox .='
'.$langs->trans("LastUsersCreated", min($num, $max)).''.$langs->trans("FullList").'
'; + $lastcreatedbox .=''; + $lastcreatedbox .=''; + $lastcreatedbox .=''."\n"; $i = 0; while ($i < $num && $i < $max) { @@ -167,24 +162,24 @@ if ($resql) { $companystatic->code_client = $obj->code_client; $companystatic->canvas = $obj->canvas; - print ''; - print ''; + $lastcreatedbox .='"; - print ''; - print ""; + $lastcreatedbox .=''; + $lastcreatedbox .="'; - print ''; - print ''; + $lastcreatedbox .=''; + $lastcreatedbox .=''; + $lastcreatedbox .=''; - print ''; + $lastcreatedbox .=''; $i++; } - print "
'.$langs->trans("LastUsersCreated", min($num, $max)).''.$langs->trans("FullList").'
'; - print $fuserstatic->getNomUrl(-1); + $lastcreatedbox .='
'; + $lastcreatedbox .=$fuserstatic->getNomUrl(-1); if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { - print img_picto($langs->trans("SuperAdministrator"), 'redstar'); + $lastcreatedbox .=img_picto($langs->trans("SuperAdministrator"), 'redstar'); } elseif ($obj->admin) { - print img_picto($langs->trans("Administrator"), 'star'); + $lastcreatedbox .=img_picto($langs->trans("Administrator"), 'star'); } - print "'.$obj->login.'"; + $lastcreatedbox .="'.$obj->login.'"; if ($obj->fk_soc) { - print $companystatic->getNomUrl(1); + $lastcreatedbox .=$companystatic->getNomUrl(1); } else { - print $langs->trans("InternalUser"); + $lastcreatedbox .=$langs->trans("InternalUser"); } if ($obj->ldap_sid) { - print ' ('.$langs->trans("DomainUser").')'; + $lastcreatedbox .=' ('.$langs->trans("DomainUser").')'; } $entity = $obj->entity; @@ -198,19 +193,19 @@ if ($resql) { $entitystring = $mc->label; } } - print ($entitystring ? ' ('.$entitystring.')' : ''); + $lastcreatedbox .=($entitystring ? ' ('.$entitystring.')' : ''); - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''; - print $fuserstatic->getLibStatut(3); - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''; + $lastcreatedbox .=$fuserstatic->getLibStatut(3); + $lastcreatedbox .='
"; - print "

"; + $lastcreatedbox .=""; + $lastcreatedbox .="

"; $db->free($resql); } else { @@ -221,6 +216,7 @@ if ($resql) { /* * Last groups created */ +$lastgroupbox = ''; if ($canreadperms) { $max = 5; @@ -242,11 +238,11 @@ if ($canreadperms) { } $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; - print ''; + $lastgroupbox .='
'; + $lastgroupbox .='
'.$langs->trans("LastGroupsCreated", ($num ? $num : $max)).''.$langs->trans("FullList").'
'; + $lastgroupbox .=''; + $lastgroupbox .=''; + $lastgroupbox .=''; $i = 0; $grouptemp = new UserGroup($db); @@ -258,25 +254,25 @@ if ($canreadperms) { $grouptemp->name = $obj->name; $grouptemp->note = $obj->note; - print ''; - print ''; + $lastgroupbox .='"; + $lastgroupbox .=""; if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); - print ''; + $lastgroupbox .=''; } - print ''; - print ""; + $lastgroupbox .=''; + $lastgroupbox .=""; $i++; } - print "
'.$langs->trans("LastGroupsCreated", ($num ? $num : $max)).''.$langs->trans("FullList").'
'; - print $grouptemp->getNomUrl(1); + $lastgroupbox .='
'; + $lastgroupbox .=$grouptemp->getNomUrl(1); if (!$obj->entity) { - print img_picto($langs->trans("GlobalGroup"), 'redstar'); + $lastgroupbox .=img_picto($langs->trans("GlobalGroup"), 'redstar'); } - print "'; - print $mc->label; - print ''; + $lastgroupbox .=$mc->label; + $lastgroupbox .=''.dol_print_date($db->jdate($obj->datec), 'dayhour').'
'.dol_print_date($db->jdate($obj->datec), 'dayhour').'
"; - print "

"; + $lastgroupbox .= ""; + $lastgroupbox .= "

"; $db->free($resql); } else { @@ -284,8 +280,6 @@ if ($canreadperms) { } } -print '
'; - // boxes print '
'; print '
'; @@ -293,10 +287,13 @@ print '
'; $boxlist = '
'; $boxlist .= '
'; +$boxlist .= $searchbox; $boxlist .= $resultboxes['boxlista']; $boxlist .= '
'."\n"; $boxlist .= '
'; +$boxlist .= $lastcreatedbox; +$boxlist .= $lastgroupbox; $boxlist .= $resultboxes['boxlistb']; $boxlist .= '
'."\n";