Skip to content

Commit

Permalink
Merge pull request #111 from dbarzin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dbarzin authored Jul 28, 2024
2 parents d40cab1 + 0590b32 commit e15ec79
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ public function __toString()
public function addEvent($txt, $date, $days = 1, $color = '', $id = null)
{
$color = $color ? ' ' . $color : $color;
$this->events[] = [$txt, $date, $days, $color, $id];
$this->events[] = [$txt === null ? '&nbsp' : $txt, $date, $days, $color, $id];
}
}
10 changes: 9 additions & 1 deletion app/Console/Commands/SendNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,15 @@ public function handle()
$message = $txt;

// Send mail
if (mail($to_email, '=?UTF-8?B?' . base64_encode($subject) . '?=', utf8_decode($message), implode("\r\n", $headers), '-f ' . $to_email)) {
if (mail(
$to_email,
'=?UTF-8?B?' . base64_encode($subject) . '?=',
mb_convert_encoding($message, 'UTF-8', 'ISO-8859-1'),
implode("\r\n", $headers),
'-f ' .
$to_email
)
) {
Log::debug('Mail sent to '.$to_email);
} else {
Log::debug('Email sending fail.');
Expand Down
2 changes: 2 additions & 0 deletions app/Exports/DomainsExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function headings(): array

public function styles(Worksheet $worksheet)
{
// fix unused
$worksheet;
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
Expand Down
2 changes: 2 additions & 0 deletions app/Exports/MeasuresExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function headings(): array

public function styles(Worksheet $sheet)
{
// fix unused
$sheet;
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true],
Expand Down
99 changes: 48 additions & 51 deletions app/Http/Controllers/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public function edit(int $id)
// get all attributes
$values = [];
$attributes = DB::table('measures')->select('attributes')->get();
foreach ($attributes as $id => $key) {
foreach ($attributes as $key) {
foreach (explode(' ', $key->attributes) as $value) {
array_push($values, $value);
}
Expand Down Expand Up @@ -1068,21 +1068,17 @@ public function make(Request $request)
$request->session()->put('control', $id);

// compute next control date
$next_date = date(
'Y-m-d',
strtotime(
$control->periodicity . ' months',
strtotime($control->plan_date)
)
);

// compute next control date
$next_date =
$control->next_date === null
? \Carbon\Carbon::createFromFormat('Y-m-d', $control->plan_date)
->addMonths($control->periodicity)
->format('Y-m-d')
: $control->next_date->format('Y-m-d');
if ($control->periodicity === 0) {
// Once
$next_date = null;
} else {
$next_date =
$control->next_date === null
? \Carbon\Carbon::createFromFormat('Y-m-d', $control->plan_date)
->addMonths($control->periodicity)
->format('Y-m-d')
: $control->next_date->format('Y-m-d');
}

// return view
return view('controls.make')
Expand Down Expand Up @@ -1157,46 +1153,47 @@ public function doMake()
// Auditee -> propose control
if (Auth::User()->role === 5) {
$control->status = 1;
}
// if there is no next control
elseif ($control->next_id === null) {
// create a new control
$new_control = $control->replicate();
$new_control->observations = null;
$new_control->realisation_date = null;
$new_control->note = null;
$new_control->score = null;
$new_control->status = 0;
// only admin and user can update the plan_date, realisation_date and action_plan
if (Auth::User()->role === 1 || Auth::User()->role === 2) {
$new_control->plan_date = request('next_date');
} else {
$new_control->plan_date = date(
'Y-m-d',
strtotime(
$control->periodicity . ' months',
strtotime($control->plan_date)
)
);
}
} else {
// set status done
$control->status = 2;

$new_control->save();
// if there is no next control and control not once
if (($control->next_id === null) && ($control->periodicity !== 0)) {
// create a new control
$new_control = $control->replicate();
$new_control->observations = null;
$new_control->realisation_date = null;
$new_control->note = null;
$new_control->score = null;
$new_control->status = 0;
// only admin and user can update the plan_date, realisation_date and action_plan
if (Auth::User()->role === 1 || Auth::User()->role === 2) {
$new_control->plan_date = request('next_date');
} else {
$new_control->plan_date = date(
'Y-m-d',
strtotime(
$control->periodicity . ' months',
strtotime($control->plan_date)
)
);
}

// Set owners
$new_control
->owners()
->sync($control->owners->pluck('id')->toArray());
$new_control->save();

// Set measures
$new_control
->measures()
->sync($control->measures->pluck('id')->toArray());
// Set owners
$new_control
->owners()
->sync($control->owners->pluck('id')->toArray());

// set status done
$control->status = 2;
// Set measures
$new_control
->measures()
->sync($control->measures->pluck('id')->toArray());

// make link
$control->next_id = $new_control->id;
// make link
$control->next_id = $new_control->id;
}
}

// update control
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class ReportController extends Controller
{
public function show(Request $request)
public function show()
{
// get all frameworks
$frameworks = DB::table('domains')
Expand Down
5 changes: 3 additions & 2 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DB;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Log;
Expand All @@ -30,8 +31,8 @@ public function boot()
URL::forceScheme('https');
}

if (true) {
//if (Config::get('APP_DEBUG')) {
// if (true) {
if (Config::get('APP_DEBUG')) {
DB::listen(function ($query) {
Log::info(
$query->sql,
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'unplan' => 'Unplan',
'validate' => 'Validate',

'once' => 'Once',
'monthly' => 'Monthly',
'quarterly' => 'Quarterly',
'biannually' => 'Biannually',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/fr/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'unplan' => 'Déplanifier',
'validate' => 'Valider',

'once' => 'Une fois',
'monthly' => 'Mensuel',
'quarterly' => 'Trimestriel',
'biannually' => 'Bisanuel',
Expand Down
1 change: 1 addition & 0 deletions resources/views/controls/plan.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
</div>
<div class="cell-2">
<select name="periodicity" data-role="select">
<option value="1" {{ $control->periodicity==0 ? "selected" : ""}}>{{ trans('common.once') }}</option>
<option value="1" {{ $control->periodicity==1 ? "selected" : ""}}>{{ trans('common.monthly') }}</option>
<option value="3" {{ $control->periodicity==3 ? "selected" : ""}}>{{ trans('common.quarterly') }}</option>
<option value="6" {{ $control->periodicity==6 ? "selected" : ""}}>{{ trans('common.biannually') }}</option>
Expand Down
1 change: 1 addition & 0 deletions resources/views/controls/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<strong>{{ trans('cruds.control.fields.periodicity') }}</strong>
</div>
<div class="cell">
@if ($control->periodicity==0) {{ trans("common.once") }} @endif
@if ($control->periodicity==1) {{ trans("common.monthly") }} @endif
@if ($control->periodicity==3) {{ trans("common.quarterly") }} @endif
@if ($control->periodicity==6) {{ trans("common.biannually") }} @endif
Expand Down
1 change: 1 addition & 0 deletions resources/views/measures/plan.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
</div>
<div class="cell-3">
<select name="periodicity" data-role="select">
<option value="0" {{ $measure->periodicity==0 ? "selected" : ""}}>{{ trans('common.once') }}</option>
<option value="1" {{ $measure->periodicity==1 ? "selected" : ""}}>{{ trans('common.monthly') }}</option>
<option value="3" {{ $measure->periodicity==3 ? "selected" : ""}}>{{ trans('common.quarterly') }}</option>
<option value="6" {{ $measure->periodicity==6 ? "selected" : ""}}>{{ trans('common.biannually') }}</option>
Expand Down

0 comments on commit e15ec79

Please sign in to comment.