2
0
forked from Wavyzz/dolibarr

New: More option to define default filter setting of agenda views.

This commit is contained in:
Laurent Destailleur
2014-06-29 23:35:00 +02:00
parent 5c9edcd6a3
commit 31c27b8f7c
7 changed files with 133 additions and 71 deletions

View File

@@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
if (!$user->admin)
accessforbidden();
@@ -70,11 +71,20 @@ if (preg_match('/del_(.*)/',$action,$reg))
}
}
if ($action == 'set')
{
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
}
/**
* View
*/
$formactions=new FormActions($db);
llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@@ -86,43 +96,71 @@ $head=agenda_prepare_head();
dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action');
print_titre($langs->trans("OtherOptions"));
//print_titre($langs->trans("OtherOptions"));
$var=true;
print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
print '<input type="hidden" name="action" value="set">';
print '<table class="noborder allwidth">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print '<td align="center" width="20">&nbsp;</td>'."\n";
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'.$langs->trans("Value").'</td>'."\n";
print '</tr>'."\n";
// Manual or automatic
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
print '<td align="center" width="20">&nbsp;</td>'."\n";
print '<td align="center" width="100">'."\n";
if ($conf->use_javascript_ajax)
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print ajax_constantonoff('AGENDA_USE_EVENT_TYPE');
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
else
{
if($conf->global->AGENDA_USE_EVENT_TYPE == 0)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
else if($conf->global->BUSINESS_VISIBLE_TO_ALL_BY_DEFAULT == 1)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
}
print '</td></tr>'."\n";
// AGENDA_DEFAULT_FILTER_TYPE
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right" class="nowrap">'."\n";
print $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), 1);
print '</td></tr>'."\n";
// AGENDA_DEFAULT_FILTER_STATUS
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
$formactions->form_select_status_action('agenda',$conf->global->AGENDA_DEFAULT_FILTER_STATUS,1,'AGENDA_DEFAULT_FILTER_STATUS',1,2);
print '</td></tr>'."\n";
// AGENDA_DEFAULT_VIEW
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_VIEW").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
$tmplist=array('show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_list'=>$langs->trans("ViewList"), 'show_peruser'=>$langs->trans("ViewPerUser"));
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n";
print '</table>';
print '<center><input class="button" type="submit" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></center>';
print '</form>';
dol_fiche_end();
print "<br>";

View File

@@ -81,7 +81,11 @@ $pid=GETPOST("projectid","int",3);
$status=GETPOST("status");
$type=GETPOST("type");
$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':''));
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':'');
if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($status == '') $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action)) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week') {
$action='show_month'; $day='';
@@ -93,11 +97,6 @@ if (GETPOST('viewday') || $action == 'show_day') {
$action='show_day'; $day=($day?$day:date("d"));
} // View by day
if (empty($action))
{
if (empty($conf->global->AGENDA_DEFAULT_VIEW)) $action='show_month';
else $action=$conf->global->AGENDA_DEFAULT_VIEW;
}
$langs->load("agenda");
$langs->load("other");
@@ -110,7 +109,8 @@ $hookmanager->initHooks(array('agenda'));
/*
* Actions
*/
if (GETPOST("viewlist"))
if (GETPOST("viewlist") || $action == 'show_list')
{
$param='';
foreach($_POST as $key => $val)
@@ -123,6 +123,19 @@ if (GETPOST("viewlist"))
exit;
}
if (GETPOST("viewperuser") || $action == 'show_peruser')
{
$param='';
foreach($_POST as $key => $val)
{
if ($key=='token') continue;
$param.='&'.$key.'='.urlencode($val);
}
//print $param;
header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
exit;
}
if ($action=='delete_action')
{
$event = new ActionComm($db);

View File

@@ -44,11 +44,9 @@ $status=GETPOST("status",'alpha');
$type=GETPOST('type');
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':''));
if (empty($action))
{
if (empty($conf->global->AGENDA_DEFAULT_VIEW)) $action='show_list';
else $action=$conf->global->AGENDA_DEFAULT_VIEW;
}
if ($actioncode == '') $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($status == '') $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action)) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_list':$conf->global->AGENDA_DEFAULT_VIEW);
$filter=GETPOST("filter",'',3);
$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3);
@@ -214,6 +212,7 @@ if ($resql)
if ($action == 'show_week') $tabactive='cardweek';
if ($action == 'show_day') $tabactive='cardday';
if ($action == 'show_list') $tabactive='cardlist';
if ($action == 'show_peruser') $tabactive='cardperuser';
$head = calendars_prepare_head($param);

View File

@@ -120,7 +120,7 @@ class FormActions
{
//var_dump($selected);
if ($selected == 'done') $selected='100';
print '<select '.($canedit?'':'disabled="disabled" ').'name="status" id="select'.$htmlname.'" class="flat">';
print '<select '.($canedit?'':'disabled="disabled" ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat">';
if ($showempty) print '<option value=""'.($selected == ''?' selected="selected"':'').'></option>';
foreach($listofstatus as $key => $val)
{
@@ -230,9 +230,10 @@ class FormActions
* @param string $htmlname Nom champ formulaire
* @param string $excludetype Type to exclude
* @param string $onlyautoornot Group list by auto events or not: We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)
* @param int $hideinfohelp 1=Do not show info help
* @return void
*/
function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0)
function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0, $hideinfohelp=0)
{
global $langs,$user,$form;
@@ -251,7 +252,7 @@ class FormActions
if ($selected == 'auto') $selected='AC_OTH_AUTO';
print $form->selectarray($htmlname, $arraylist, $selected);
if ($user->admin && empty($onlyautoornot)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
if ($user->admin && empty($onlyautoornot) && empty($hideinfohelp)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
}

View File

@@ -359,6 +359,11 @@ function agenda_prepare_head()
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_other.php";
$head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'other';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/agenda.php";
$head[$h][1] = $langs->trans("AutoActions");
$head[$h][2] = 'autoactions';
@@ -374,11 +379,6 @@ function agenda_prepare_head()
$head[$h][2] = 'extsites';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_other.php";
$head[$h][1] = $langs->trans("Other");
$head[$h][2] = 'other';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin');
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php";

View File

@@ -399,6 +399,13 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0)
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
else
{
$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
<script type="text/javascript">
$(document).ready(function() {
@@ -437,6 +444,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0)
$out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.($revertonoff?img_picto($langs->trans("Enabled"),'switch_on'):img_picto($langs->trans("Disabled"),'switch_off')).'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.($revertonoff?img_picto($langs->trans("Disabled"),'switch_off'):img_picto($langs->trans("Enabled"),'switch_on')).'</span>';
$out.="\n";
}
return $out;
}

View File

@@ -1453,6 +1453,9 @@ AgendaSetup=Events and agenda module setup
PasswordTogetVCalExport=Key to authorize export link
PastDelayVCalExport=Do not export event older than
AGENDA_USE_EVENT_TYPE=Use events types (managed into menu Setup -> Dictionary -> Type of agenda events)
AGENDA_DEFAULT_FILTER_TYPE=Set automatically this type of event into search filter of agenda view
AGENDA_DEFAULT_FILTER_STATUS=Set automatically this status for events into search filter of agenda view
AGENDA_DEFAULT_VIEW=Which tab do you want to open by default when selecting menu Agenda
##### ClickToDial #####
ClickToDialDesc=This module allows to add an icon after phone numbers. A click on this icon will call a server with a particular URL you define below. This can be used to call a call center system from Dolibarr that can call the phone number on a SIP system for example.
##### Point Of Sales (CashDesk) #####