Skip to content

Commit

Permalink
FIX #21
Browse files Browse the repository at this point in the history
Added contributor selection and all sorts
  • Loading branch information
bgenere committed Mar 22, 2017
1 parent 1470719 commit e1334de
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/modules/modVignoble.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct($db)
/**
* version : module version as x.x.x
*/
$this->version = '0.5';
$this->version = '0.6';
/**
* const_name : module constant to save module status enabled/disabled
*/
Expand Down
56 changes: 37 additions & 19 deletions cultivationprogress.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

$timespent = getTaskTimeSpent($cultivationproject, $sort, $filter["timespent"]);


displayView($cultivationproject, $timespent, $sort, $filter);

/* close database */
Expand Down Expand Up @@ -106,7 +105,7 @@ function displayView(Project $cultivationproject, $timespent, $sort, $filter)
function displaySearchForm(Project $cultivationproject, $filter, $sort)
{
global $db, $conf, $langs, $user;

$form = new Form($db);
print '<div class="fichecenter">';

Expand All @@ -116,18 +115,16 @@ function displaySearchForm(Project $cultivationproject, $filter, $sort)
print '<input type="hidden" name="sortorder" value="' . $sort['order'] . '">';
print '<table class="noborder nohover centpercent">';
// Form header
print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("Search") . '</td></tr>';
// Date Begin and Button
print '<tr class="liste_titre"><td colspan="5">' . $langs->trans("Search") . '</td></tr>';
// Date Begin End and Button
print '<tr>';
print '<td class="nowrap"><label for="datebegin">' . $langs->trans("DateStart") . '</label></td>';
print '<td>' . $form->select_date($filter['datebegin'], 'datebegin', 0, 0, 0, "datebegin", 1, 1, 1) . '</td>';
print '<td rowspan="3"><input type="submit" value="' . $langs->trans("Search") . '" class="button"></td>';
print '</tr>';
// Date End
print '<tr>';
print '<td class="nowrap"><label for="dateend">' . $langs->trans("DateEnd") . '</label></td>';
print '<td>' . $form->select_date($filter['dateend'], 'dateend', 0, 0, 0, "dateend", 1, 1, 1) . '</td>';
print '<td rowspan="2"><input type="submit" value="' . $langs->trans("Search") . '" class="button"></td>';
print '</tr>';

// Tasks
$tasks = array();
$lines = getProjectTasks($cultivationproject);
Expand All @@ -138,7 +135,13 @@ function displaySearchForm(Project $cultivationproject, $filter, $sort)
print '<tr>';
print '<td class="nowrap"><label for="tasks">' . $langs->trans("Tasks") . '</label></td>';
print '<td>' . $form->multiselectarray('multitasks', $tasks, $filter['tasks'], 0, 0, '', 0, '90%') . '</td>';

// Contributors
$contributors = getProjectContributors(null, $cultivationproject, 0);
print '<td class="nowrap"><label for="by">' . $langs->trans("By") . '</label></td>';
print '<td>' . $form->multiselectarray('multicontributors', $contributors, GETPOST('multicontributors'), 0, 0, '', 0, '90%') . '</td>';
print '</tr>';

print '</table>';
print '</form>';
print '<br>';
Expand Down Expand Up @@ -168,7 +171,7 @@ function displayTable($tablename, $table, $sort, $urlparam)
'date' => array(
'align' => 'left',
'label' => 'Date',
'sort' => 'date,taskref',
'sort' => 'date,taskref,u.firstname,u.lastname,plotref',
'display' => 'print dol_print_date($line->date,"day");',
'norepeat' => true
),
Expand All @@ -177,13 +180,14 @@ function displayTable($tablename, $table, $sort, $urlparam)
'label' => 'Task',
'display' => 'displayTask($line);',
'norepeat' => true,
'sort' => 'taskref,date'
'sort' => 'taskref,date,u.firstname,u.lastname,plotref'
),
'contributor' => array(
'align' => 'left',
'label' => 'By',
'display' => 'displayUser($line);',
'norepeat' => true
'norepeat' => true,
'sort' => 'u.firstname,u.lastname,date,taskref,plotref'
),
'note' => array(
'align' => 'left',
Expand All @@ -204,7 +208,8 @@ function displayTable($tablename, $table, $sort, $urlparam)
'plotref' => array(
'align' => 'left',
'label' => 'Plot',
'display' => 'displayPlot($line);'
'display' => 'displayPlot($line);',
'sort' => 'plotref,date,taskref,u.firstname,u.lastname'
),
'plotprogress' => array(
'align' => 'right',
Expand Down Expand Up @@ -332,7 +337,7 @@ function getsort()
{
$sortfield = GETPOST(sortfield, 'alpha');
if (empty($sortfield)) {
$sortfield = 'date,taskref';
$sortfield = 'date,taskref,u.firstname,u.lastname,plotref';
}
$sortorder = GETPOST(sortorder, 'alpha');
if (empty($sortorder)) {
Expand Down Expand Up @@ -386,19 +391,30 @@ function getfilter()
$selectedtasks = " pt.ref IN ('" . implode("','", $tasks) . "')";
}

$contributors = GETPOST('multicontributors','array');

if (empty($contributors)){
$contributors = GETPOST('contributors','alpha');
if (empty($contributors)){
$selectedcontributors = "t.fk_user IS NOT NULL";
} else {
$selectedcontributors = "t.fk_user IN ".$contributors;
$contributors = explode("','", trim($contributors, "('')"));
}
} else {
$selectedcontributors = "t.fk_user IN ('" . implode("','", $contributors) . "')";
}

$filter = array(
"datebegin" => $datebegin,
"dateend" => $dateend,
"tasks" => $tasks,
"contributors" => $contributors,
"timespent" => array(
" t.task_date >= '" . $datebegin . "' ",
" t.task_date <= '" . $dateend . "' ",
$selectedtasks
),
"plotprogress" => array(
" t.dateprogress >= '" . $datebegin . "' ",
" t.dateprogress <= '" . $dateend . "' ",
$selectedtasks
$selectedtasks,
$selectedcontributors
)
);

Expand All @@ -423,6 +439,8 @@ function buildSearchParameters($filter)
$param .= "&amp;dateend=" . urlencode($filter['dateend']);
if (! empty($filter['tasks']))
$param .= "&amp;tasks=" . urlencode("('" . implode("','", $filter['tasks']) . "')");
if (! empty($filter['contributors']))
$param .= "&amp;contributors=" . urlencode("('" . implode("','", $filter['contributors']) . "')");
return $param;
}

Expand Down
13 changes: 11 additions & 2 deletions lib/cultivationtask.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,22 +576,31 @@ function get_dolusers($force_entity = 0, $morefilter = '', $noactive = 0)
* the current task
* @param Project $projectstatic
* the cultivation project
* @param $all
* flag to remove the all option
* @return array[] list of contributors for project
*/
function getProjectContributors($task, $projectstatic)
function getProjectContributors($task, $projectstatic, $all = 1)
{
Global $db, $conf, $user, $langs;

if ($task->project->public)
$contributorsofproject = get_dolusers(); // get all users
else
$contributorsofproject = $projectstatic->Liste_Contact(- 1, 'internal'); // Only users of project. // selection of users

if ($all){
$contributors = array(
'0' => $langs->trans("All")
);
} else {
$contributors = array();

}

foreach ($contributorsofproject as $contributor) {
$key = $contributor["id"];
$value = $contributor["firstname"].' '.$contributor["lastname"];
$value = $contributor["firstname"] . ' ' . $contributor["lastname"];
$contributors[$key] = $value;
}
return $contributors;
Expand Down

0 comments on commit e1334de

Please sign in to comment.