add "to" date to the export_issues method; updated strings to eng

This commit is contained in:
Marco Cavalli 2023-10-11 12:06:29 +02:00
parent 9e38ed5a90
commit 94542ea555
2 changed files with 62 additions and 28 deletions

View File

@ -88,7 +88,7 @@ class GiteaApiController extends Controller
return $datetime->format('Y-m-d H:i:s');
}
private function export_issues(string $from_date, array $issues_params)
private function export_issues(string $from_date, string $to_date, array $issues_params)
{
$data = array();
$repositories = $this->get_repositories();
@ -96,7 +96,8 @@ class GiteaApiController extends Controller
$issues = $this->get_issues($repository['name'], $issues_params);
foreach ($issues as $issue) {
$from_datetime = $this->date_to_datetime($from_date);
if (substr($issue['closed_at'], 0, 19) > $from_datetime) {
$to_datetime = $this->date_to_datetime($to_date);
if (substr($issue['closed_at'], 0, 19) > $from_datetime && substr($issue['closed_at'], 0, 19) <= $to_datetime) {
$data[] = $this->create_columns($issue);
}
}
@ -111,8 +112,9 @@ class GiteaApiController extends Controller
if ($req->input('token') != getenv('GITEA_TOKEN')) {
return redirect('/');
}
$date = $req->input('year') . '-' . $req->input('month') . '-01';
$this->export_issues($date, ['state' => 'closed']);
$from = $req->input('from_year') . '-' . $req->input('from_month') . '-01';
$to = $req->input('to_year') . '-' . $req->input('to_month') . '-31';
$this->export_issues($from, $to, ['state' => 'closed']);
return view('backend', [
'token' => getenv('GITEA_TOKEN')
]);

View File

@ -3,36 +3,68 @@
@section('title', 'Backoffice')
@section('content')
<section class="login" style="max-width:800px;width:100%:">
<section class="login" style="max-width:800px;width:100%;">
<div class="card">
<div class="card-header">
Genera il file
File exporter
</div>
<div class="card-body">
<form name="search-form" action="{{ url('export') }}" method="POST">
<input type="hidden" name="token" value="{{$token}}">
<p>Esportazione a partire da:</p>
<input type="hidden" name="token" value="{{ $token }}">
<div class="row">
<div class="col-md-6">
<p>From:</p>
<div class="mb-3">
<label for="Mese" class="form-label">Mese</label>
<select class="form-control" id="month" name="month">
<option value="01">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">Jun</option>
<option value="07">Jul</option>
<option value="08">Aug</option>
<option value="09">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
<label for="from_month" class="form-label">Mese</label>
<select class="form-control" id="from_month" name="from_month">
<option value="01" {{ date('m') == '02' ? 'selected' : '' }}>Jan</option>
<option value="02" {{ date('m') == '03' ? 'selected' : '' }}>Feb</option>
<option value="03" {{ date('m') == '04' ? 'selected' : '' }}>Mar</option>
<option value="04" {{ date('m') == '05' ? 'selected' : '' }}>Apr</option>
<option value="05" {{ date('m') == '06' ? 'selected' : '' }}>May</option>
<option value="06" {{ date('m') == '07' ? 'selected' : '' }}>Jun</option>
<option value="07" {{ date('m') == '08' ? 'selected' : '' }}>Jul</option>
<option value="08" {{ date('m') == '09' ? 'selected' : '' }}>Aug</option>
<option value="09" {{ date('m') == '10' ? 'selected' : '' }}>Sep</option>
<option value="10" {{ date('m') == '11' ? 'selected' : '' }}>Oct</option>
<option value="11" {{ date('m') == '12' ? 'selected' : '' }}>Nov</option>
<option value="12" {{ date('m') == '01' ? 'selected' : '' }}>Dec</option>
</select>
</div>
<div class="mb-3">
<label for="Anno" class="form-label">Anno</label>
<input type="number" value="{{date('Y')}}" min="2000" max="2099" class="form-control" id="year" name="year">
<label for="from_year" class="form-label">Anno</label>
<input type="number"
value="{{ date('m') == '01' ? date('Y', strtotime('-1 year')) : date('Y') }}"
min="2000" max="2099" class="form-control" id="from_year" name="from_year">
</div>
</div>
<div class="col-md-6">
<p>To:</p>
<div class="mb-3">
<label for="to_month" class="form-label">Mese</label>
<select class="form-control" id="to_month" name="to_month">
<option value="01" {{ date('m') == '01' ? 'selected' : '' }}>Jan</option>
<option value="02" {{ date('m') == '02' ? 'selected' : '' }}>Feb</option>
<option value="03" {{ date('m') == '03' ? 'selected' : '' }}>Mar</option>
<option value="04" {{ date('m') == '04' ? 'selected' : '' }}>Apr</option>
<option value="05" {{ date('m') == '05' ? 'selected' : '' }}>May</option>
<option value="06" {{ date('m') == '06' ? 'selected' : '' }}>Jun</option>
<option value="07" {{ date('m') == '07' ? 'selected' : '' }}>Jul</option>
<option value="08" {{ date('m') == '08' ? 'selected' : '' }}>Aug</option>
<option value="09" {{ date('m') == '09' ? 'selected' : '' }}>Sep</option>
<option value="10" {{ date('m') == '10' ? 'selected' : '' }}>Oct</option>
<option value="11" {{ date('m') == '11' ? 'selected' : '' }}>Nov</option>
<option value="12" {{ date('m') == '12' ? 'selected' : '' }}>Dec</option>
</select>
</div>
<div class="mb-3">
<label for="to_year" class="form-label">Anno</label>
<input type="number" value="{{ date('Y') }}" min="2000" max="2099"
class="form-control" id="to_year" name="to_year">
</div>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary" style="width:100%;">Entra</button>
</form>
</div>