Add jobs export
This commit is contained in:
parent
7e3246c6c0
commit
5aae62ddb6
@ -146,4 +146,9 @@ define("STRINGS", [
|
|||||||
"job added" => "Job added.",
|
"job added" => "Job added.",
|
||||||
"job deleted" => "Job deleted.",
|
"job deleted" => "Job deleted.",
|
||||||
"show all" => "Show all",
|
"show all" => "Show all",
|
||||||
|
"id" => "ID",
|
||||||
|
"deleted" => "Deleted",
|
||||||
|
"groups" => "Groups",
|
||||||
|
"all jobs" => "All Jobs (export)",
|
||||||
|
"include deleted" => "Include Deleted"
|
||||||
]);
|
]);
|
@ -64,7 +64,7 @@ if (LOADED) {
|
|||||||
$user = getUserByUsername($VARS['user']);
|
$user = getUserByUsername($VARS['user']);
|
||||||
}
|
}
|
||||||
if (isset($VARS['type']) && isset($VARS['format'])) {
|
if (isset($VARS['type']) && isset($VARS['format'])) {
|
||||||
generateReport($VARS['type'], $VARS['format'], $user, $VARS['startdate'], $VARS['enddate']);
|
generateReport($VARS['type'], $VARS['format'], $user, $VARS['startdate'], $VARS['enddate'], $VARS['deleted'] == "1");
|
||||||
die();
|
die();
|
||||||
} else {
|
} else {
|
||||||
lang("invalid parameters");
|
lang("invalid parameters");
|
||||||
@ -241,7 +241,61 @@ function getTotalsReport($user = null, $start = null, $end = null) {
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReportData($type, $user = null, $start = null, $end = null) {
|
function getJobsReport($showdeleted = true) {
|
||||||
|
global $database;
|
||||||
|
$jobs = $database->select('jobs', ['jobid (id)', 'jobname (name)', 'jobcode (code)', 'color', 'deleted']);
|
||||||
|
$all_groups = [];
|
||||||
|
$client = new GuzzleHttp\Client();
|
||||||
|
|
||||||
|
$response = $client
|
||||||
|
->request('POST', PORTAL_API, [
|
||||||
|
'form_params' => [
|
||||||
|
'key' => PORTAL_KEY,
|
||||||
|
'action' => "getgroups"
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
if ($response->getStatusCode() > 299) {
|
||||||
|
sendError($response->getBody());
|
||||||
|
}
|
||||||
|
$resp = json_decode($response->getBody(), TRUE);
|
||||||
|
if ($resp['status'] == "OK") {
|
||||||
|
foreach ($resp['groups'] as $g) {
|
||||||
|
$all_groups[$g['id']] = $g['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$header = [lang("id", false), lang("name", false), lang("code", false), lang("groups", false)];
|
||||||
|
if ($showdeleted) {
|
||||||
|
$header[] = lang('deleted', false);
|
||||||
|
}
|
||||||
|
$out = [$header];
|
||||||
|
for ($i = 0; $i < count($jobs); $i++) {
|
||||||
|
if ($jobs[$i]["deleted"] == 1 && !$showdeleted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$groups = $database->select("job_groups", 'groupid', ['jobid' => $jobs[$i]["id"]]);
|
||||||
|
$groupnames = [];
|
||||||
|
foreach ($groups as $g) {
|
||||||
|
if ($g == -1) {
|
||||||
|
$groupnames[] = lang("all groups", false);
|
||||||
|
} else {
|
||||||
|
$groupnames[] = $all_groups[$g];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$row = [
|
||||||
|
$jobs[$i]["id"],
|
||||||
|
$jobs[$i]["name"],
|
||||||
|
$jobs[$i]["code"],
|
||||||
|
implode("|", $groupnames)
|
||||||
|
];
|
||||||
|
if ($showdeleted) {
|
||||||
|
$row[] = $jobs[$i]["deleted"] == 1 ? "X" : "";
|
||||||
|
}
|
||||||
|
$out[] = $row;
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getReportData($type, $user = null, $start = null, $end = null, $deleted = true) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "shifts":
|
case "shifts":
|
||||||
return getShiftReport($user);
|
return getShiftReport($user);
|
||||||
@ -252,6 +306,8 @@ function getReportData($type, $user = null, $start = null, $end = null) {
|
|||||||
case "totals":
|
case "totals":
|
||||||
return getTotalsReport($user, $start, $end);
|
return getTotalsReport($user, $start, $end);
|
||||||
break;
|
break;
|
||||||
|
case "alljobs":
|
||||||
|
return getJobsReport($deleted);
|
||||||
default:
|
default:
|
||||||
return [["error"]];
|
return [["error"]];
|
||||||
}
|
}
|
||||||
@ -388,8 +444,8 @@ STYLE
|
|||||||
echo $out;
|
echo $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateReport($type, $format, $user = null, $start = null, $end = null) {
|
function generateReport($type, $format, $user = null, $start = null, $end = null, $deleted = true) {
|
||||||
$data = getReportData($type, $user, $start, $end);
|
$data = getReportData($type, $user, $start, $end, $deleted);
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case "ods":
|
case "ods":
|
||||||
dataToODS($data, $type, $user, $start, $end);
|
dataToODS($data, $type, $user, $start, $end);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -24,10 +23,11 @@ if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE") && !accou
|
|||||||
<h3 class="panel-title"><label for="type"><i class="fa fa-list"></i> <?php lang("report type"); ?></label></h3>
|
<h3 class="panel-title"><label for="type"><i class="fa fa-list"></i> <?php lang("report type"); ?></label></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<select name="type" class="form-control" required>
|
<select name="type" id="type" class="form-control" required>
|
||||||
<option value="shifts"><?php lang("shifts") ?></option>
|
<option value="shifts"><?php lang("shifts") ?></option>
|
||||||
<option value="punches"><?php lang("punches") ?></option>
|
<option value="punches"><?php lang("punches") ?></option>
|
||||||
<option value="totals"><?php lang("totals") ?></option>
|
<option value="totals"><?php lang("totals") ?></option>
|
||||||
|
<option value="alljobs"><?php lang("all jobs") ?></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -54,28 +54,39 @@ if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE") && !accou
|
|||||||
<h3 class="panel-title"><label><i class="fa fa-filter"></i> <?php lang("filter"); ?></label></h3>
|
<h3 class="panel-title"><label><i class="fa fa-filter"></i> <?php lang("filter"); ?></label></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="radio">
|
<div id="user-filter">
|
||||||
<label>
|
<div class="radio">
|
||||||
<input name="users" value="all" checked="" type="radio"> <i class="fa fa-users fa-fw"></i>
|
<label>
|
||||||
<?php lang("all managed users") ?>
|
<input name="users" value="all" checked="" type="radio"> <i class="fa fa-users fa-fw"></i>
|
||||||
</label>
|
<?php lang("all managed users") ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="radio">
|
||||||
|
<label>
|
||||||
|
<input name="users" value="one" type="radio"> <i class="fa fa-user fa-fw"></i>
|
||||||
|
<?php lang("one user") ?>
|
||||||
|
<div class="form-group" id="user-selection">
|
||||||
|
<input type="text" name="user" class="form-control" id="user-box" placeholder="<?php lang("choose user") ?>" />
|
||||||
|
<label class="control-label" id="user-not-managed-text" for="user-box"><i class="fa fa-warning"></i> <?php lang("not a managed user") ?></label>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="radio">
|
<div id="date-filter">
|
||||||
<label>
|
<label><i class="fa fa-calendar"></i> <?php lang("date range") ?></label><br />
|
||||||
<input name="users" value="one" type="radio"> <i class="fa fa-user fa-fw"></i>
|
<div class="input-group">
|
||||||
<?php lang("one user") ?>
|
<input type="text" id="startdate" name="startdate" class="form-control" />
|
||||||
<div class="form-group" id="user-selection">
|
<span class="input-group-addon"><i class="fa fa-chevron-right"></i></span>
|
||||||
<input type="text" name="user" class="form-control" id="user-box" placeholder="<?php lang("choose user") ?>" />
|
<input type="text" id="enddate" name="enddate" class="form-control" />
|
||||||
<label class="control-label" id="user-not-managed-text" for="user-box"><i class="fa fa-warning"></i> <?php lang("not a managed user") ?></label>
|
</div>
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<div id="deleted-filter">
|
||||||
<label><i class="fa fa-calendar"></i> <?php lang("date range") ?></label><br />
|
<div class="checkbox">
|
||||||
<div class="input-group">
|
<label>
|
||||||
<input type="text" id="startdate" name="startdate" class="form-control" />
|
<input name="deleted" value="1" checked="1" type="checkbox"> <i class="fa fa-trash fa-fw"></i>
|
||||||
<span class="input-group-addon"><i class="fa fa-chevron-right"></i></span>
|
<?php lang("include deleted") ?>
|
||||||
<input type="text" id="enddate" name="enddate" class="form-control" />
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,4 +61,27 @@ $(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#user-not-managed-text').css('visibility', 'hidden');
|
$('#user-not-managed-text').css('visibility', 'hidden');
|
||||||
|
|
||||||
|
$("#type").change(function () {
|
||||||
|
switch ($("#type").val()) {
|
||||||
|
case "shifts":
|
||||||
|
$('#date-filter').hide('fast');
|
||||||
|
$('#user-filter').show('fast');
|
||||||
|
$('#deleted-filter').hide('fast');
|
||||||
|
break;
|
||||||
|
case "alljobs":
|
||||||
|
$('#date-filter').hide('fast');
|
||||||
|
$('#user-filter').hide('fast');
|
||||||
|
$('#deleted-filter').show('fast');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$('#date-filter').show('fast');
|
||||||
|
$('#user-filter').show('fast');
|
||||||
|
$('#deleted-filter').hide('fast');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#date-filter').hide();
|
||||||
|
$('#deleted-filter').hide();
|
Loading…
x
Reference in New Issue
Block a user