Debug module resource. Filter on agenda.

This commit is contained in:
Laurent Destailleur 2016-06-06 13:05:36 +02:00
parent 681249de8a
commit 9b6e5196ea
6 changed files with 48 additions and 12 deletions

View File

@ -78,7 +78,7 @@ if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no per
}
$action=GETPOST('action','alpha');
//$year=GETPOST("year");
$resourceid=GETPOST("resourceid","int");
$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
@ -292,6 +292,7 @@ if ($status == 'todo') $title=$langs->trans("ToDoActions");
$param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtert) $param.="&filtert=".$filtert;
@ -349,7 +350,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup,'', $resourceid);
dol_fiche_end();
@ -442,12 +443,15 @@ $sql.= ' a.fk_soc, a.fk_contact,';
$sql.= ' ca.code as type_code, ca.libelle as type_label';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
// We must filter on resource table
if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code IN ('".implode("','", explode(',',$actioncode))."')";
if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 > 0) $sql.= ' AND a.fk_soc = '.$socid;

View File

@ -36,6 +36,7 @@ $langs->load("agenda");
$langs->load("commercial");
$action=GETPOST('action','alpha');
$resourceid=GETPOST("resourceid","int");
$year=GETPOST("year",'int');
$month=GETPOST("month",'int');
$day=GETPOST("day",'int');
@ -156,6 +157,7 @@ $listofextcals=array();
$param='';
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($actioncode != '') $param.="&actioncode=".$actioncode;
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtert) $param.="&filtert=".$filtert;
@ -178,12 +180,15 @@ $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
// We must filter on resource table
if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= " WHERE c.id = a.fk_action";
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND c.code IN ('".$db->escape($actioncode)."')";
if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 > 0) $sql.= " AND s.rowid = ".$socid;
@ -242,7 +247,7 @@ if ($resql)
$head = calendars_prepare_head($param);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup,'',$resourceid);
dol_fiche_end();
// Add link to show birthdays
@ -288,6 +293,7 @@ if ($resql)
$nav='';
if ($optioncss != '') $nav.= '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.='<input type="hidden" name="status" value="'.$status.'">';
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';

View File

@ -76,7 +76,7 @@ if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no per
//$action=GETPOST('action','alpha');
$action='show_pertype';
//$year=GETPOST("year");
$resourceid=GETPOST("resourceid","int");
$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
@ -202,6 +202,7 @@ if ($status == 'todo') $title=$langs->trans("ToDoActions");
$param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtert) $param.="&filtert=".$filtert;
@ -252,6 +253,7 @@ $nav.='<input type="hidden" name="action" value="' . $action . '">';
$nav.='<input type="hidden" name="usertodo" value="' . $filtert . '">';
$nav.='<input type="hidden" name="usergroup" value="' . $usergroup . '">';
$nav.='<input type="hidden" name="actioncode" value="' . $actioncode . '">';
$nav.='<input type="hidden" name="resourceid" value="' . $resourceid . '">';
$nav.='<input type="hidden" name="status" value="' . $status . '">';
$nav.='<input type="hidden" name="socid" value="' . $socid . '">';
$nav.='<input type="hidden" name="projectid" value="' . $projectid . '">';
@ -279,7 +281,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup);
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
dol_fiche_end();
$showextcals=$listofextcals;
@ -356,12 +358,15 @@ $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,';
$sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
// We must filter on resource table
if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'";
if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 > 0) $sql.= ' AND a.fk_soc = '.$socid;

View File

@ -76,7 +76,7 @@ if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no per
//$action=GETPOST('action','alpha');
$action='show_peruser'; //We use 'show_week' mode
//$year=GETPOST("year");
$resourceid=GETPOST("resourceid","int");
$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
@ -202,6 +202,7 @@ if ($status == 'todo') $title=$langs->trans("ToDoActions");
$param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtert) $param.="&filtert=".$filtert;
@ -255,6 +256,7 @@ $nav.='<input type="hidden" name="action" value="' . $action . '">';
$nav.='<input type="hidden" name="usertodo" value="' . $filtert . '">';
$nav.='<input type="hidden" name="usergroup" value="' . $usergroup . '">';
$nav.='<input type="hidden" name="actioncode" value="' . $actioncode . '">';
$nav.='<input type="hidden" name="resourceid" value="' . $resourceid . '">';
$nav.='<input type="hidden" name="status" value="' . $status . '">';
$nav.='<input type="hidden" name="socid" value="' . $socid . '">';
$nav.='<input type="hidden" name="projectid" value="' . $projectid . '">';
@ -287,7 +289,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup);
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
dol_fiche_end();
$showextcals=$listofextcals;
@ -364,12 +366,15 @@ $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,';
$sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
// We must filter on resource table
if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'";
if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 > 0) $sql.= ' AND a.fk_soc = '.$socid;

View File

@ -41,12 +41,13 @@
* @param int $socid Third party id
* @param string $action Action string
* @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend
* @param string|array $actioncode Preselected value(s) of actioncode for filter on type
* @param string|array $actioncode Preselected value(s) of actioncode for filter on event type
* @param int $usergroupid Id of group to filter on users
* @param string $excludetype A type to exclude ('systemauto', 'system', '')
* @param string $excludetype A type to exclude ('systemauto', 'system', '')
* @param int $resourceid Preselected value of resource for filter on resource
* @return void
*/
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='')
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
{
global $conf, $user, $langs, $db, $hookmanager;
global $begin_h, $end_h, $begin_d, $end_d;
@ -80,6 +81,20 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
print '</td></tr>';
if ($conf->resource->enabled)
{
include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php';
$formresource=new FormResource($db);
// Resource
print '<tr>';
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
print $langs->trans("Resource");
print ' &nbsp;</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px; padding-right: 4px;">';
print $formresource->select_resource_list($resourceid, "resourceid", '', 1, 0, 0, null, '', 2);
print '</td></tr>';
}
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions=new FormActions($db);

View File

@ -17,11 +17,12 @@
*/
/**
* \file place/class/html.formresource.class.php
* \file resource/class/html.formresource.class.php
* \ingroup core
* \brief Class file to manage forms into resource module
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php");
require_once(DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php");
/**
@ -56,7 +57,7 @@ class FormResource
/**
* Output html form to select a resource
*
* @param string $selected Preselected type
* @param int $selected Preselected resource id
* @param string $htmlname Name of field in form
* @param string $filter Optionnal filters criteras (example: 's.rowid <> x')
* @param int $showempty Add an empty field