Skip to content
Snippets Groups Projects
Commit 2deadea4 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Filter on event status

parent 012d2c2a
No related branches found
No related tags found
No related merge requests found
......@@ -395,7 +395,7 @@ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
$form = new Form($db);
$htmlactions = new FormActions($db);
$formactions = new FormActions($db);
if ($action == 'create')
{
......@@ -467,7 +467,7 @@ if ($action == 'create')
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
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>';
}
else print '<input type="hidden" name="actioncode" value="AC_OTH">';
......@@ -512,7 +512,7 @@ if ($action == 'create')
if (GETPOST("afaire") == 1) $percent=0;
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>';
// Location
......@@ -740,7 +740,7 @@ if ($id > 0)
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
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>';
}
......@@ -766,7 +766,7 @@ if ($id > 0)
// Status
print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
$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>';
// Location
......
......@@ -347,7 +347,10 @@ else
$sql.= ')';
}
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 ($filtera > 0 || $filtert > 0 || $filterd > 0)
{
......
......@@ -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 ($socid) $sql.= " AND s.rowid = ".$socid;
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 ($filtera > 0 || $filtert > 0 || $filterd > 0)
{
......
......@@ -48,13 +48,15 @@ class FormActions
/**
* Show list of action status
*
* @param string $formname Name of form where select in included
* @param string $selected Preselected value (-1..100)
* @param int $canedit 1=can edit, 0=read only
* @param string $htmlname Name of html prefix for html fields (selectX and valX)
* @param string $formname Name of form where select is included
* @param string $selected Preselected value (-1..100)
* @param int $canedit 1=can edit, 0=read only
* @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
*/
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;
......@@ -64,6 +66,7 @@ class FormActions
'50' => $langs->trans("ActionRunningShort"),
'100' => $langs->trans("ActionDoneShort")
);
// +ActionUncomplete
if (! empty($conf->use_javascript_ajax))
{
......@@ -112,18 +115,32 @@ class FormActions
}
}
</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">';
if ($showempty) print '<option value=""'.($selected == ''?' selected="selected"':'').'></option>';
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>';
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
{
{
print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled="disabled"').'>%';
}
}
......@@ -220,7 +237,7 @@ class FormActions
global $langs,$user,$form;
if (! is_object($form)) $form=new Form($db);
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$caction=new CActionComm($this->db);
......
......@@ -43,8 +43,8 @@
* @param string $actioncode Preselected value of actioncode for filter on type
* @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;
// 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';
$formactions=new FormActions($db);
print '<tr>';
print '<td class="nowrap">';
print $langs->trans("Type");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone">';
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>';
}
......
......@@ -356,6 +356,7 @@ ActionNotApplicable=Not applicable
ActionRunningNotStarted=To start
ActionRunningShort=Started
ActionDoneShort=Finished
ActionUncomplete=Uncomplete
CompanyFoundation=Company/Foundation
ContactsForCompany=Contacts for this third party
ContactsAddressesForCompany=Contacts/addresses for this third party
......
......@@ -355,6 +355,7 @@ ActionsDoneShort=Effectuées
ActionNotApplicable=Non applicable
ActionRunningNotStarted=A réaliser
ActionRunningShort=En cours
ActionUncomplete=Incomplet
ActionDoneShort=Terminé
CompanyFoundation=Société ou institution
ContactsForCompany=Contacts de ce tiers
......
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment