New: Filter on event status

This commit is contained in:
Laurent Destailleur 2014-06-26 20:24:00 +02:00
parent 012d2c2a9e
commit 2deadea40a
8 changed files with 55 additions and 20 deletions

View File

@ -395,7 +395,7 @@ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url); llxHeader('',$langs->trans("Agenda"),$help_url);
$form = new Form($db); $form = new Form($db);
$htmlactions = new FormActions($db); $formactions = new FormActions($db);
if ($action == 'create') if ($action == 'create')
{ {
@ -467,7 +467,7 @@ if ($action == 'create')
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<tr><td width="30%"><span class="fieldrequired">'.$langs->trans("Type").'</span></b></td><td>'; print '<tr><td width="30%"><span class="fieldrequired">'.$langs->trans("Type").'</span></b></td><td>';
$htmlactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto"); $formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '</td></tr>'; print '</td></tr>';
} }
else print '<input type="hidden" name="actioncode" value="AC_OTH">'; else print '<input type="hidden" name="actioncode" value="AC_OTH">';
@ -512,7 +512,7 @@ if ($action == 'create')
if (GETPOST("afaire") == 1) $percent=0; if (GETPOST("afaire") == 1) $percent=0;
else if (GETPOST("afaire") == 2) $percent=100; else if (GETPOST("afaire") == 2) $percent=100;
} }
$htmlactions->form_select_status_action('formaction',$percent,1,'complete'); $formactions->form_select_status_action('formaction',$percent,1,'complete');
print '</td></tr>'; print '</td></tr>';
// Location // Location
@ -740,7 +740,7 @@ if ($id > 0)
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">'; print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
$htmlactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto"); $formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '</td></tr>'; print '</td></tr>';
} }
@ -766,7 +766,7 @@ if ($id > 0)
// Status // Status
print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">'; print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
$percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage; $percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage;
$htmlactions->form_select_status_action('formaction',$percent,1); $formactions->form_select_status_action('formaction',$percent,1);
print '</td></tr>'; print '</td></tr>';
// Location // Location

View File

@ -347,7 +347,10 @@ else
$sql.= ')'; $sql.= ')';
} }
if ($type) $sql.= " AND ca.id = ".$type; if ($type) $sql.= " AND ca.id = ".$type;
if ($status == 'done') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } if ($status == '0') { $sql.= " AND a.percent = 0"; }
if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } // Running
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
if ($filtera > 0 || $filtert > 0 || $filterd > 0) if ($filtera > 0 || $filtert > 0 || $filterd > 0)
{ {

View File

@ -153,7 +153,10 @@ if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($type) $sql.= " AND c.id = ".$type; if ($type) $sql.= " AND c.id = ".$type;
if ($status == 'done') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } if ($status == '0') { $sql.= " AND a.percent = 0"; }
if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } // Running
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
if ($filtera > 0 || $filtert > 0 || $filterd > 0) if ($filtera > 0 || $filtert > 0 || $filterd > 0)
{ {

View File

@ -48,13 +48,15 @@ class FormActions
/** /**
* Show list of action status * Show list of action status
* *
* @param string $formname Name of form where select in included * @param string $formname Name of form where select is included
* @param string $selected Preselected value (-1..100) * @param string $selected Preselected value (-1..100)
* @param int $canedit 1=can edit, 0=read only * @param int $canedit 1=can edit, 0=read only
* @param string $htmlname Name of html prefix for html fields (selectX and valX) * @param string $htmlname Name of html prefix for html fields (selectX and valX)
* @param string $showempty Show an empty line if select is used
* @param string $onlyselect 0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
* @return void * @return void
*/ */
function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete') function form_select_status_action($formname,$selected,$canedit=1,$htmlname='complete',$showempty=0,$onlyselect=0)
{ {
global $langs,$conf; global $langs,$conf;
@ -64,6 +66,7 @@ class FormActions
'50' => $langs->trans("ActionRunningShort"), '50' => $langs->trans("ActionRunningShort"),
'100' => $langs->trans("ActionDoneShort") '100' => $langs->trans("ActionDoneShort")
); );
// +ActionUncomplete
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
@ -112,18 +115,32 @@ class FormActions
} }
} }
</script>\n"; </script>\n";
}
if (! empty($conf->use_javascript_ajax) || $onlyselect)
{
//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="status" id="select'.$htmlname.'" class="flat">';
if ($showempty) print '<option value=""'.($selected == ''?' selected="selected"':'').'></option>';
foreach($listofstatus as $key => $val) foreach($listofstatus as $key => $val)
{ {
print '<option value="'.$key.'"'.(($selected == $key) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected="selected"' : '').'>'.$val.'</option>'; print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected="selected"' : '').'>'.$val.'</option>';
if ($key == '50' && $onlyselect == 2)
{
print '<option value="todo"'.($selected == 'todo' ? ' selected="selected"' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionRunningNotStarted")."+".$langs->trans("ActionRunningShort").')</option>';
}
} }
print '</select>'; print '</select>';
if ($selected == 0 || $selected == 100) $canedit=0; if ($selected == 0 || $selected == 100) $canedit=0;
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled="disabled"').'>';
print '<span class="hideifna">%</span>'; if (empty($onlyselect))
{
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled="disabled"').'>';
print '<span class="hideifna">%</span>';
}
} }
else else
{ {
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled="disabled"').'>%'; print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled="disabled"').'>%';
} }
} }

View File

@ -43,8 +43,8 @@
* @param string $actioncode Preselected value of actioncode for filter on type * @param string $actioncode Preselected value of actioncode for filter on type
* @return void * @return void
*/ */
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $showextcals=array(), $actioncode='') { function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $showextcals=array(), $actioncode='')
{
global $conf, $user, $langs, $db; global $conf, $user, $langs, $db;
// Filters // Filters
@ -87,13 +87,19 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions=new FormActions($db); $formactions=new FormActions($db);
print '<tr>'; print '<tr>';
print '<td class="nowrap">'; print '<td class="nowrap">';
print $langs->trans("Type"); print $langs->trans("Type");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">'; print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">';
print $formactions->select_type_actions($actioncode, "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0)); print $formactions->select_type_actions($actioncode, "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0));
print '</td></tr>';
print '<tr>';
print '<td class="nowrap">';
print $langs->trans("Status");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">';
$formactions->form_select_status_action('formaction',$status,1,'complete',1,2);
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -356,6 +356,7 @@ ActionNotApplicable=Not applicable
ActionRunningNotStarted=To start ActionRunningNotStarted=To start
ActionRunningShort=Started ActionRunningShort=Started
ActionDoneShort=Finished ActionDoneShort=Finished
ActionUncomplete=Uncomplete
CompanyFoundation=Company/Foundation CompanyFoundation=Company/Foundation
ContactsForCompany=Contacts for this third party ContactsForCompany=Contacts for this third party
ContactsAddressesForCompany=Contacts/addresses for this third party ContactsAddressesForCompany=Contacts/addresses for this third party

View File

@ -355,6 +355,7 @@ ActionsDoneShort=Effectuées
ActionNotApplicable=Non applicable ActionNotApplicable=Non applicable
ActionRunningNotStarted=A réaliser ActionRunningNotStarted=A réaliser
ActionRunningShort=En cours ActionRunningShort=En cours
ActionUncomplete=Incomplet
ActionDoneShort=Terminé ActionDoneShort=Terminé
CompanyFoundation=Société ou institution CompanyFoundation=Société ou institution
ContactsForCompany=Contacts de ce tiers ContactsForCompany=Contacts de ce tiers

View File

@ -0,0 +1,4 @@
# Dolibarr language file - Source file is en_US - salaries
NewSalaryPayment=Novo pagamento de salário
SalaryPayment=Pagamento de salário
SalariesPayments=Pagamentos de salários