can add box on member index page

This commit is contained in:
Frédéric FRANCE 2021-01-02 20:04:40 +01:00
parent 46a5fa52da
commit 6fad38db57
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 191 additions and 125 deletions

View File

@ -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.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.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.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$hookmanager = new HookManager($db); $hookmanager = new HookManager($db);
@ -40,7 +41,24 @@ $langs->loadLangs(array("companies", "members"));
// Security check // Security check
$result = restrictedArea($user, 'adherent'); $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 * View
@ -52,7 +70,7 @@ $staticmember = new Adherent($db);
$statictype = new AdherentType($db); $statictype = new AdherentType($db);
$subscriptionstatic = new Subscription($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(); $Adherents = array();
$AdherentsAValider = array(); $AdherentsAValider = array();
@ -85,9 +103,15 @@ if ($result) {
$adhtype->label = $objp->label; $adhtype->label = $objp->label;
$AdherentType[$objp->rowid] = $adhtype; $AdherentType[$objp->rowid] = $adhtype;
if ($objp->statut == -1) { $MemberToValidate[$objp->rowid] = $objp->somme; } if ($objp->statut == -1) {
if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; } $MemberToValidate[$objp->rowid] = $objp->somme;
if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; } }
if ($objp->statut == 1) {
$MembersValidated[$objp->rowid] = $objp->somme;
}
if ($objp->statut == 0) {
$MembersResiliated[$objp->rowid] = $objp->somme;
}
$i++; $i++;
} }
@ -136,10 +160,14 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
$i = 0; $i = 0;
foreach ($listofsearchfields as $key => $value) { foreach ($listofsearchfields as $key => $value) {
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; if ($i == 0) {
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; if ($i == 0) {
print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
}
print '</tr>'; print '</tr>';
$i++; $i++;
} }
@ -449,6 +477,42 @@ print "</div>";
print '</div></div></div>'; print '</div></div></div>';
// boxes
print '<div class="clearboth"></div>';
print '<div class="fichecenter fichecenterbis">';
/*
* Show widgets (boxes)
*/
$boxlist .= '<div class="twocolumns">';
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
if (!empty($nbworkboardcount)) {
$boxlist .= $boxwork;
}
$boxlist .= $resultboxes['boxlista'];
$boxlist .= '</div>';
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
$boxlist .= $boxstat;
$boxlist .= $resultboxes['boxlistb'];
$boxlist .= '</div>';
$boxlist .= "\n";
$boxlist .= '</div>';
print $boxlist;
print '</div>';
$parameters = array('user' => $user); $parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook

View File

@ -37,10 +37,10 @@ class InfoBox
{ {
global $conf; 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( return array(
0 => 'Home', 0 => 'Home',
2 => 'membersindex',
27 => 'AccountancyHome' 27 => 'AccountancyHome'
); );
} else { } else {
@ -95,16 +95,20 @@ class InfoBox
$boxes = array(); $boxes = array();
$confuserzone = 'MAIN_BOXES_'.$zone; $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 = "SELECT b.rowid, b.position, b.box_order, b.fk_user,";
$sql .= " d.rowid as box_id, d.file, d.note, d.tms"; $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 .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
$sql .= " WHERE b.box_id = d.rowid"; $sql .= " WHERE b.box_id = d.rowid";
$sql .= " AND b.entity IN (0,".$conf->entity.")"; $sql .= " AND b.entity IN (0,".$conf->entity.")";
if ($zone >= 0) $sql .= " AND b.position = ".$zone; if ($zone >= 0) {
if (is_object($user)) $sql .= " AND b.fk_user IN (0,".$user->id.")"; $sql .= " AND b.position = ".$zone;
else $sql .= " AND b.fk_user = 0"; }
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"; $sql .= " ORDER BY b.box_order";
} else // available } 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); dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$j = 0; $j = 0;
while ($j < $num) while ($j < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (!in_array($obj->box_id, $excludelist)) if (!in_array($obj->box_id, $excludelist)) {
{
$regs = array(); $regs = array();
if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) {
{
$boxname = preg_replace('/\.php$/i', '', $regs[1]); $boxname = preg_replace('/\.php$/i', '', $regs[1]);
$module = $regs[2]; $module = $regs[2];
$relsourcefile = "/".$module."/core/boxes/".$boxname.".php"; $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. // 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. // Goal is to avoid making a "new" done for each boxes returned by select.
dol_include_once($relsourcefile); 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 $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params.
//$box=new stdClass(); //$box=new stdClass();
@ -156,12 +155,13 @@ class InfoBox
$box->sourcefile = $relsourcefile; $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 ($mode == 'activated' && !is_object($user)) { // List of activated box was not yet personalized into database
{ if (is_numeric($box->box_order)) {
if (is_numeric($box->box_order)) if ($box->box_order % 2 == 1) {
{ $box->box_order = 'A'.$box->box_order;
if ($box->box_order % 2 == 1) $box->box_order = 'A'.$box->box_order; } elseif ($box->box_order % 2 == 0) {
elseif ($box->box_order % 2 == 0) $box->box_order = 'B'.$box->box_order; $box->box_order = 'B'.$box->box_order;
}
} }
} }
// box_def properties // box_def properties
@ -171,20 +171,18 @@ class InfoBox
// Filter on box->enabled (used for example by box_comptes) // Filter on box->enabled (used for example by box_comptes)
// Filter also on box->depends. Example: array("product|service") or array("contrat", "service") // Filter also on box->depends. Example: array("product|service") or array("contrat", "service")
$enabled = $box->enabled; $enabled = $box->enabled;
if (isset($box->depends) && count($box->depends) > 0) if (isset($box->depends) && count($box->depends) > 0) {
{ foreach ($box->depends as $moduleelem) {
foreach ($box->depends as $moduleelem)
{
$arrayelem = explode('|', $moduleelem); $arrayelem = explode('|', $moduleelem);
$tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR)
foreach ($arrayelem as $module) foreach ($arrayelem as $module) {
{
$tmpmodule = preg_replace('/@[^@]+/', '', $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).'<br>'; //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
} }
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; $enabled = 0;
break; break;
} }
@ -193,8 +191,11 @@ class InfoBox
//print '=>'.$boxname.'-enabled='.$enabled.'<br>'; //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
//print 'xx module='.$module.' enabled='.$enabled; //print 'xx module='.$module.' enabled='.$enabled;
if ($enabled && ($includehidden || empty($box->hidden))) $boxes[] = $box; if ($enabled && ($includehidden || empty($box->hidden))) {
else unset($box); $boxes[] = $box;
} else {
unset($box);
}
} else { } else {
dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); 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); 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 = new User($db);
$user->id = $userid; $user->id = $userid;
@ -240,8 +243,7 @@ class InfoBox
$tab = array(); $tab = array();
$confuserzone = 'MAIN_BOXES_'.$zone; $confuserzone = 'MAIN_BOXES_'.$zone;
$tab[$confuserzone] = 1; $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(); $error = $db->lasterror();
$db->rollback(); $db->rollback();
return -3; return -3;
@ -255,11 +257,9 @@ class InfoBox
dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); dol_syslog(get_class()."::saveboxorder", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$colonnes = explode('-', $boxorder); $colonnes = explode('-', $boxorder);
foreach ($colonnes as $collist) foreach ($colonnes as $collist) {
{
$part = explode(':', $collist); $part = explode(':', $collist);
$colonne = $part[0]; $colonne = $part[0];
$list = $part[1]; $list = $part[1];
@ -267,10 +267,8 @@ class InfoBox
$i = 0; $i = 0;
$listarray = explode(',', $list); $listarray = explode(',', $list);
foreach ($listarray as $id) foreach ($listarray as $id) {
{ if (is_numeric($id)) {
if (is_numeric($id))
{
//dol_syslog("aaaaa".count($listarray)); //dol_syslog("aaaaa".count($listarray));
$i++; $i++;
$ii = sprintf('%02d', $i); $ii = sprintf('%02d', $i);
@ -287,8 +285,7 @@ class InfoBox
dol_syslog(get_class()."::saveboxorder", LOG_DEBUG); dol_syslog(get_class()."::saveboxorder", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
break; break;
} }
@ -299,8 +296,7 @@ class InfoBox
$error++; $error++;
} }
if ($error) if ($error) {
{
$db->rollback(); $db->rollback();
return -2; return -2;
} else { } else {

View File

@ -41,18 +41,15 @@ $hookmanager->initHooks(array('index'));
*/ */
// Check if company name is defined (first install) // 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"); header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
exit; 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"); header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
exit; 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'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone = GETPOST('areacode', 'aZ09'); $zone = GETPOST('areacode', 'aZ09');
$userid = GETPOST('userid', 'int'); $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'); $boxorder .= GETPOST('boxcombo', 'aZ09');
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); $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 * View
*/ */
if (!isset($form) || !is_object($form)) $form = new Form($db); if (!isset($form) || !is_object($form)) {
$form = new Form($db);
}
// Title // Title
$title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; $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); llxHeader('', $title);
@ -82,11 +85,9 @@ $resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (select
print load_fiche_titre('&nbsp;', $resultboxes['selectboxlist'], '', 0, '', 'titleforhome'); print load_fiche_titre('&nbsp;', $resultboxes['selectboxlist'], '', 0, '', 'titleforhome');
if (!empty($conf->global->MAIN_MOTD)) if (!empty($conf->global->MAIN_MOTD)) {
{
$conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD); $conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD);
if (!empty($conf->global->MAIN_MOTD)) if (!empty($conf->global->MAIN_MOTD)) {
{
$substitutionarray = getCommonSubstitutionArray($langs); $substitutionarray = getCommonSubstitutionArray($langs);
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
$texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs);
@ -113,16 +114,14 @@ $boxstatFromHook = '';
$langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts')); $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts'));
// Load global statistics of objects // 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(); $object = new stdClass();
$parameters = array(); $parameters = array();
$action = ''; $action = '';
$reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$boxstatFromHook = $hookmanager->resPrint; $boxstatFromHook = $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook)) {
{
// Cle array returned by the method load_state_board for each line // Cle array returned by the method load_state_board for each line
$keys = array( $keys = array(
'users', 'users',
@ -285,18 +284,17 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
// Loop and displays each line of table // Loop and displays each line of table
$boardloaded = array(); $boardloaded = array();
foreach ($keys as $val) foreach ($keys as $val) {
{ if ($conditions[$val]) {
if ($conditions[$val])
{
$boxstatItem = ''; $boxstatItem = '';
$class = $classes[$val]; $class = $classes[$val];
// Search in cache if load_state_board is already realized // Search in cache if load_state_board is already realized
$classkeyforcache = $class; $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 include_once $includes[$val]; // Loading a class cost around 1Mb
$board = new $class($db); $board = new $class($db);
@ -471,8 +469,12 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$object = new stdClass(); $object = new stdClass();
$parameters = array(); $parameters = array();
$action = ''; $action = '';
$reshook = $hookmanager->executeHooks('addOpenElementsDashboardLine', $parameters, $object, $reshook = $hookmanager->executeHooks(
$action); // Note that $action and $object may have been modified by some hooks 'addOpenElementsDashboardLine',
$parameters,
$object,
$action
); // Note that $action and $object may have been modified by some hooks
if ($reshook == 0) { if ($reshook == 0) {
$dashboardlines = array_merge($dashboardlines, $hookmanager->resArray); $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray);
} }
@ -627,8 +629,10 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>'; $boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>';
if ($showweather) { if ($showweather) {
if ($totallate > 0) { if ($totallate > 0) {
$text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; "NActionsLate",
$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
).')';
} else { } else {
$text = $langs->transnoentitiesnoconv("NoItemLate"); $text = $langs->transnoentitiesnoconv("NoItemLate");
} }
@ -670,17 +674,17 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$globalStatsKey = $groupElement['globalStatsKey']; $globalStatsKey = $groupElement['globalStatsKey'];
$groupElement['globalStats'] = array(); $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 // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
$keyIndex = array_search($globalStatsKey, $keys); $keyIndex = array_search($globalStatsKey, $keys);
$classe = $classes[$keyIndex]; $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; $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0;
$nbTotal = doubleval($groupElement['globalStats']['total']); $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']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')';
$groupElement['globalStats']['total'] = $nbTotal; $groupElement['globalStats']['total'] = $nbTotal;
$groupElement['globalStats']['link'] = $links[$keyIndex]; $groupElement['globalStats']['link'] = $links[$keyIndex];
@ -767,8 +771,10 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$text = ''; $text = '';
if ($totallate > 0) { if ($totallate > 0) {
$text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; "NActionsLate",
$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
).')';
} else { } else {
$text = $langs->transnoentitiesnoconv("NoItemLate"); $text = $langs->transnoentitiesnoconv("NoItemLate");
} }
@ -783,16 +789,24 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n"; $weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n";
if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
$weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate", $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
price($totallatePercentage).'%').'</span>'."\n"; "NActionsLate",
$weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate', price($totallatePercentage).'%'
$totalLateNumber).'</span>'."\n"; ).'</span>'."\n";
$weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
'NActionsLate',
$totalLateNumber
).'</span>'."\n";
} else { } else {
$weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate", $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
$totalLateNumber).'</span>'."\n"; "NActionsLate",
$totalLateNumber
).'</span>'."\n";
if ($totallatePercentage > 0) { if ($totallatePercentage > 0) {
$weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate', $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
price($totallatePercentage).'%').'</span>'."\n"; 'NActionsLate',
price($totallatePercentage).'%'
).'</span>'."\n";
} }
} }
@ -840,8 +854,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$boxwork .= '<div class="dashboardlinelatecoin nowrap">'; $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
$boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">'; $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
//$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').''; //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
$boxwork .= img_picto($textlate, "warning_white", $boxwork .= img_picto(
'class="inline-block hideonsmartphone valigntextbottom"').''; $textlate,
"warning_white",
'class="inline-block hideonsmartphone valigntextbottom"'
).'';
$boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">'; $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
$boxwork .= $board->nbtodolate; $boxwork .= $board->nbtodolate;
$boxwork .= '</span>'; $boxwork .= '</span>';
@ -892,8 +909,7 @@ print '<div class="fichecenter fichecenterbis">';
$boxlist .= '<div class="twocolumns">'; $boxlist .= '<div class="twocolumns">';
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">'; $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
if (!empty($nbworkboardcount)) if (!empty($nbworkboardcount)) {
{
$boxlist .= $boxwork; $boxlist .= $boxwork;
} }
@ -902,8 +918,7 @@ $boxlist .= $resultboxes['boxlista'];
$boxlist .= '</div>'; $boxlist .= '</div>';
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 // 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) { if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) {
foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) { foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) {
@ -926,8 +941,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
$boxstat .= $boxstatFromHook; $boxstat .= $boxstatFromHook;
if (is_array($boxstatItems) && count($boxstatItems) > 0) if (is_array($boxstatItems) && count($boxstatItems) > 0) {
{
$boxstat .= implode('', $boxstatItems); $boxstat .= implode('', $boxstatItems);
} }
@ -967,30 +981,26 @@ print '</div>';
*/ */
// Security warning repertoire install existe (si utilisateur admin) // 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 = ''; $message = '';
// Check if install lock file is present // Check if install lock file is present
$lockfile = DOL_DATA_ROOT.'/install.lock'; $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"); $langs->load("errors");
//if (! empty($message)) $message.='<br>'; //if (! empty($message)) $message.='<br>';
$message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); $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 // Conf files must be in read only mode
if (is_writable($conffile)) if (is_writable($conffile)) {
{
$langs->load("errors"); $langs->load("errors");
//$langs->load("other"); //$langs->load("other");
//if (! empty($message)) $message.='<br>'; //if (! empty($message)) $message.='<br>';
$message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
} }
if ($message) if ($message) {
{
print $message; print $message;
//$message.='<br>'; //$message.='<br>';
//print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
@ -1063,20 +1073,16 @@ function getWeatherStatus($totallate)
if ($totallate <= $level0) { if ($totallate <= $level0) {
$weather->picto = 'weather-clear.png'; $weather->picto = 'weather-clear.png';
$weather->level = 0; $weather->level = 0;
} } elseif ($totallate <= $level1) {
elseif ($totallate <= $level1) {
$weather->picto = 'weather-few-clouds.png'; $weather->picto = 'weather-few-clouds.png';
$weather->level = 1; $weather->level = 1;
} } elseif ($totallate <= $level2) {
elseif ($totallate <= $level2) {
$weather->picto = 'weather-clouds.png'; $weather->picto = 'weather-clouds.png';
$weather->level = 2; $weather->level = 2;
} } elseif ($totallate <= $level3) {
elseif ($totallate <= $level3) {
$weather->picto = 'weather-many-clouds.png'; $weather->picto = 'weather-many-clouds.png';
$weather->level = 3; $weather->level = 3;
} } else {
else {
$weather->picto = 'weather-storm.png'; $weather->picto = 'weather-storm.png';
$weather->level = 4; $weather->level = 4;
} }