Skip to content

Commit

Permalink
Merge pull request #31 from keha35/9.2/bugfixes
Browse files Browse the repository at this point in the history
Adding criteras "Begin" and "End" for datefields
  • Loading branch information
Amandine Manceau authored Jun 21, 2018
2 parents 1f1733e + 63f80cc commit 72900d9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions inc/helper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,24 @@ static function manageCriterias($params) {
$crit['crit']['status'] = $status;
}
}
if (in_array("begin", $criterias)) {
if (isset($params['opt']['begin'])
&& $params['opt']["begin"] > 0) {
$opt["begin"] = $params['opt']['begin'];
$crit['crit']['begin'] = $params['opt']['begin'];
} else {
$opt["begin"] = date("Y-m-d");
}
}
if (in_array("end", $criterias)) {
if (isset($params['opt']['end'])
&& $params['opt']["end"] > 0) {
$opt["end"] = $params['opt']['end'];
$crit['crit']['end'] = $params['opt']['end'];
} else {
$opt["end"] = date("Y-m-d");
}
}
$crit['opt'] = $opt;

return $crit;
Expand Down Expand Up @@ -505,6 +523,24 @@ static function getForm($widgetId, $onsubmit = false, $opt, $criterias) {
$form .= "</br></br>";
}
}
if (in_array("begin", $criterias)) {
$form .= __('Start');
$form .= "&nbsp;";
$form .= Html::showDateField("begin", array('value' => $opt['begin'], 'maybeempty' => false, 'display' => false));
$form .= "&nbsp;";
if ($count > 1) {
$form .= "</br></br>";
}
}
if (in_array("end", $criterias)) {
$form .= __('End');
$form .= "&nbsp;";
$form .= Html::showDateField("end", array('value' => $opt['end'], 'maybeempty' => false, 'display' => false));
$form .= "&nbsp;";
if ($count > 1) {
$form .= "</br></br>";
}
}
$form .= self::getFormFooter();

return $form;
Expand Down

0 comments on commit 72900d9

Please sign in to comment.