Merge branch '17648' into 1.11.x

pull/3547/head
Yannick Warnier 5 years ago
commit 3dc4de1394
  1. 58
      main/inc/lib/myspace.lib.php
  2. 20
      main/mySpace/admin_view.php
  3. 30
      plugin/check_extra_field_author_company/CheckExtraFieldAuthorsCompanyPlugin.php

@ -1011,8 +1011,8 @@ class MySpace
* Export to cvs a list of users who were enrolled in the lessons. * Export to cvs a list of users who were enrolled in the lessons.
* It is necessary that in the extra field, a company is defined. * It is necessary that in the extra field, a company is defined.
* *
* @param null $startDate * @param string|null $startDate
* @param null $endDate * @param string|null $endDate
* *
* @return array * @return array
*/ */
@ -1052,8 +1052,8 @@ class MySpace
* Displays a list as a table of users who were enrolled in the lessons. * Displays a list as a table of users who were enrolled in the lessons.
* It is necessary that in the extra field, a company is defined. * It is necessary that in the extra field, a company is defined.
* *
* @param null $startDate * @param string|null $startDate
* @param null $endDate * @param string|null $endDate
*/ */
public static function displayResumeCompany( public static function displayResumeCompany(
$startDate = null, $startDate = null,
@ -1081,14 +1081,25 @@ class MySpace
$form = new FormValidator('searchDate', 'get'); $form = new FormValidator('searchDate', 'get');
$form->addHidden('display', 'company'); $form->addHidden('display', 'company');
$today = new DateTime();
if (empty($startDate)) {
$startDate = api_get_local_time($today->modify('first day of this month')->format('Y-m-d'));
}
if (empty($endDate)) {
$endDate = api_get_local_time($today->modify('last day of this month')->format('Y-m-d'));
}
$form->addDatePicker( $form->addDatePicker(
'startDate', 'startDate',
get_lang('DateStart'), get_lang('DateStart'),
[]); [
'value' => $startDate,
]);
$form->addDatePicker( $form->addDatePicker(
'endDate', 'endDate',
get_lang('DateEnd'), get_lang('DateEnd'),
[]); [
'value' => $endDate,
]);
$form->addButtonSearch(get_lang('Search')); $form->addButtonSearch(get_lang('Search'));
if (count($companys) != 0) { if (count($companys) != 0) {
//$form->addButtonSave(get_lang('Ok'), 'export'); //$form->addButtonSave(get_lang('Ok'), 'export');
@ -1118,9 +1129,9 @@ class MySpace
/** /**
* Displays a list as a table of teachers who are set authors by a extra_field authors. * Displays a list as a table of teachers who are set authors by a extra_field authors.
* *
* @param null $startDate * @param string|null $startDate
* @param null $endDate * @param string|null $endDate
* @param bool $csv * @param bool $csv
*/ */
public static function displayResumeLP( public static function displayResumeLP(
$startDate = null, $startDate = null,
@ -1203,7 +1214,7 @@ class MySpace
$index = 0; $index = 0;
//icons for show and hode //icons for show and hode
$iconAdd = Display::return_icon('add.png', get_lang('ShowOrHide'), '', ICON_SIZE_SMALL); $iconAdd = Display::return_icon('add.png', get_lang('ShowOrHide'), '', ICON_SIZE_SMALL);
$iconRemove = Display::return_icon('error.png', get_lang('howOrHide'), '', ICON_SIZE_SMALL); $iconRemove = Display::return_icon('error.png', get_lang('ShowOrHide'), '', ICON_SIZE_SMALL);
$teacherNameTemp = ''; $teacherNameTemp = '';
foreach ($data as $teacherName => $reportData) { foreach ($data as $teacherName => $reportData) {
$lpCount = 0; $lpCount = 0;
@ -1251,16 +1262,25 @@ class MySpace
$form = new FormValidator('searchDate', 'get'); $form = new FormValidator('searchDate', 'get');
$form->addHidden('display', 'learningPath'); $form->addHidden('display', 'learningPath');
$today = new DateTime();
if (empty($startDate)) {
$startDate = $today->modify('first day of this month')->format('Y-m-d');
}
if (empty($endDate)) {
$endDate = $today->modify('last day of this month')->format('Y-m-d');
}
$form->addDatePicker( $form->addDatePicker(
'startDate', 'startDate',
get_lang('DateStart'), get_lang('DateStart'),
[] [
); 'value' => $startDate,
]);
$form->addDatePicker( $form->addDatePicker(
'endDate', 'endDate',
get_lang('DateEnd'), get_lang('DateEnd'),
[] [
); 'value' => $endDate,
]);
$form->addButtonSearch(get_lang('Search')); $form->addButtonSearch(get_lang('Search'));
if (count($data) != 0) { if (count($data) != 0) {
//$form->addButtonSave(get_lang('Ok'), 'export'); //$form->addButtonSave(get_lang('Ok'), 'export');
@ -3617,9 +3637,9 @@ class MySpace
* *
* if lpId is different to 0, this search by lp id too * if lpId is different to 0, this search by lp id too
* *
* @param null $startDate * @param string|null $startDate
* @param null $endDate * @param string|null $endDate
* @param int $lpId * @param int $lpId
* *
* @return array * @return array
*/ */
@ -3650,13 +3670,13 @@ class MySpace
// Settings condition and parametter GET to right date // Settings condition and parametter GET to right date
if (!empty($startDate)) { if (!empty($startDate)) {
$startDate = api_get_utc_datetime($startDate->format('Y-m-d')); $startDate = api_get_utc_datetime($startDate->setTime(0, 0, 0)->format('Y-m-d H:i:s'));
$_GET['startDate'] = $startDate; $_GET['startDate'] = $startDate;
$whereCondition .= " $whereCondition .= "
AND $tblItemProperty.lastedit_date >= '$startDate' "; AND $tblItemProperty.lastedit_date >= '$startDate' ";
} }
if (!empty($endDate)) { if (!empty($endDate)) {
$endDate = api_get_utc_datetime($endDate->format('Y-m-d')); $endDate = api_get_utc_datetime($endDate->setTime(23, 59, 59)->format('Y-m-d H:i:s'));
$_GET['endDate'] = $endDate; $_GET['endDate'] = $endDate;
$whereCondition .= " $whereCondition .= "
AND $tblItemProperty.lastedit_date <= '$endDate' "; AND $tblItemProperty.lastedit_date <= '$endDate' ";

@ -9,8 +9,12 @@ require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(); api_block_anonymous_users();
$exportCSV = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false; $exportCSV = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
// Catch param export_csv from buttom if (isset($_GET['export_csv']) && $exportCSV == false) {
$exportCSV = isset($_GET['export_csv']) && $exportCSV == false ? true : false; // to export learningPath and company
$exportCSV = true;
}
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null; $display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
$htmlHeadXtra[] = api_get_jqgrid_js(); $htmlHeadXtra[] = api_get_jqgrid_js();
@ -54,15 +58,9 @@ if ($exportCSV) {
MySpace::export_tracking_course_overview(); MySpace::export_tracking_course_overview();
exit; exit;
} elseif ('company' === $display) { } elseif ('company' === $display) {
// Getting dates
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
MySpace::exportCompanyResumeCsv($startDate, $endDate); MySpace::exportCompanyResumeCsv($startDate, $endDate);
exit; exit;
} elseif ('learningPath' === $display) { } elseif ('learningPath' === $display) {
// Getting dates
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
MySpace::displayResumeLP($startDate, $endDate, true); MySpace::displayResumeLP($startDate, $endDate, true);
exit; exit;
} }
@ -88,15 +86,9 @@ switch ($display) {
MySpace::display_tracking_course_overview(); MySpace::display_tracking_course_overview();
break; break;
case 'company': case 'company':
// Getting dates
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
MySpace::displayResumeCompany($startDate, $endDate); MySpace::displayResumeCompany($startDate, $endDate);
break; break;
case 'learningPath': case 'learningPath':
// Getting dates
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
MySpace::displayResumeLP($startDate, $endDate); MySpace::displayResumeLP($startDate, $endDate);
break; break;
case 'accessoverview': case 'accessoverview':

@ -256,11 +256,11 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
]; ];
$order = 0; $order = 0;
$query = "SELECT $query = "SELECT
id id
FROM FROM
".$this->tblExtraField." ".$this->tblExtraField."
WHERE WHERE
variable = 'company'"; variable = 'company'";
$companyId = Database::fetch_assoc(Database::query($query)); $companyId = Database::fetch_assoc(Database::query($query));
$companyId = isset($companyId['id']) ? $companyId['id'] : null; $companyId = isset($companyId['id']) ? $companyId['id'] : null;
for ($i = 0; $i < count($companys); $i++) { for ($i = 0; $i < count($companys); $i++) {
@ -299,11 +299,11 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
$variableName = strtolower(Database::escape_string(Security::remove_XSS($variableName))); $variableName = strtolower(Database::escape_string(Security::remove_XSS($variableName)));
$tblExtraField = $this->tblExtraField; $tblExtraField = $this->tblExtraField;
$query = "SELECT $query = "SELECT
* *
FROM FROM
$tblExtraField $tblExtraField
WHERE WHERE
variable = '$variableName'"; variable = '$variableName'";
$data = Database::fetch_assoc(Database::query($query)); $data = Database::fetch_assoc(Database::query($query));
if ($data == false or !isset($data['display_text'])) { if ($data == false or !isset($data['display_text'])) {
return []; return [];
@ -335,11 +335,11 @@ class CheckExtraFieldAuthorsCompanyPlugin extends Plugin
} }
if ($validVariable == true && $id != 0 && !empty($extraFieldType)) { if ($validVariable == true && $id != 0 && !empty($extraFieldType)) {
$query = "SELECT $query = "SELECT
id id
FROM FROM
".$this->tblExtraField." ".$this->tblExtraField."
WHERE WHERE
id = $id id = $id
AND AND
variable = '$variable' variable = '$variable'
AND AND

Loading…
Cancel
Save