diff --git a/app/Http/Controllers/ControlController.php b/app/Http/Controllers/ControlController.php
index 2308b5a3..e58a8c2b 100644
--- a/app/Http/Controllers/ControlController.php
+++ b/app/Http/Controllers/ControlController.php
@@ -554,6 +554,79 @@ public function edit(int $id)
->with('users', $users);
}
+ /**
+ * Clone a control.
+ *
+ * @param int Control id
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function clone(Request $request)
+ {
+ // Only for admin and users
+ abort_if(
+ (Auth::User()->role !== 1) && (Auth::User()->role !== 2),
+ Response::HTTP_FORBIDDEN,
+ '403 Forbidden'
+ );
+
+ // get all clauses
+ $all_measures = DB::table('measures')
+ ->select('id', 'clause')
+ ->orderBy('id')
+ ->get();
+
+ // get all scopes
+ $scopes = DB::table('controls')
+ ->select('scope')
+ ->whereNotNull('scope')
+ ->where('scope', '<>', '')
+ ->whereIn('status', [0, 1])
+ ->distinct()
+ ->orderBy('scope')
+ ->get()
+ ->pluck('scope')
+ ->toArray();
+
+ // get all attributes
+ $values = [];
+ $attributes = DB::table('measures')->select('attributes')->get();
+ foreach ($attributes as $key) {
+ foreach (explode(' ', $key->attributes) as $value) {
+ array_push($values, $value);
+ }
+ }
+ sort($values);
+ $values = array_unique($values);
+
+ $users = User::orderBy('name')->get();
+
+ // Get Control
+ $control = Control::find($request->id);
+
+ // Workstation not found
+ abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');
+
+ $request->merge($control->only(
+ [
+ "name","scope", "objective",
+ "input", "periodicity", "model", "action_plan",
+ "plan_date"
+ ]
+ )
+ );
+ $request->merge(['measures' => $control->measures()->pluck('id')->toArray()]);
+ $request->merge(['attributes' => explode(' ', $control->attributes)]);
+ $request->merge(['owners' => $control->owners()->pluck('id')->toArray()]);
+ $request->flash();
+
+ return view('controls.create')
+ ->with('scopes', $scopes)
+ ->with('all_measures', $all_measures)
+ ->with('attributes', $values)
+ ->with('users', $users);
+ }
+
/**
* Remove the specified resource from storage.
*
diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php
index 6caa2016..8ec0ca80 100644
--- a/app/Http/Controllers/DomainController.php
+++ b/app/Http/Controllers/DomainController.php
@@ -151,12 +151,17 @@ public function destroy(Domain $domain)
// Has measures ?
if (DB::table('measures')
->where('domain_id', $domain->id)
+ ->join('control_measure','measures.id','control_measure.measure_id')
->exists()) {
return back()
- ->withErrors(['msg' => 'There are controls associated with this framework !'])
+ ->withErrors(['msg' => 'There are measures associated with this framework !'])
->withInput();
}
+ // Delete measures
+ DB::table('measures')->where('domain_id', $domain->id)->delete();
+
+ // Delete domain
$domain->delete();
return redirect('/domains');
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index dd9eb0ba..0a0ab7f1 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -115,7 +115,7 @@ public function edit(User $user)
// Allow only admin or the owner of the profile to edit
$this->authorizeAdminOrOwner($user);
- $controls = Control::select('id', 'clause')->whereNull('realisation_date')->orderBy('clause')->get();
+ $controls = Control::select('id', 'name')->whereNull('realisation_date')->orderBy('name')->get();
return view('users.edit', compact('user', 'controls'));
}
diff --git a/docs/controls.fr.md b/docs/controls.fr.md
index ba7614c6..9786bc2e 100644
--- a/docs/controls.fr.md
+++ b/docs/controls.fr.md
@@ -93,27 +93,29 @@ Cet écran permet de réaliser un contrôle de sécurité.
Cet écran contient :
-* Le nom du contrôle
+* Le ou les clauses,
-* L’objectif
+* Le nom du contrôle,
-* Les données
+* L’objectif,
-* La date de réalisation, la date de planification
+* Les données,
-* Les observation du contrôle
+* La date de réalisation, la date de planification,
-* Une zone pour sauvegarder les preuves (**CTRL+V** permet de coller un fichier ou une capture d'écran)
+* Les observation du contrôle,
-* Un lien permettant de télécharger la fiche de contrôles
+* Une zone pour sauvegarder les preuves (**CTRL+V** permet de coller un fichier ou une capture d'écran),
-* Le modèle de calcul appliqué
+* Un lien permettant de télécharger la fiche de contrôles,
-* La note
+* Le modèle de calcul appliqué,
-* Le score
+* La note,
-* Le plan d’action
+* Le score,
+
+* Le plan d’action,
* La date du prochaine contrôle
diff --git a/docs/controls.md b/docs/controls.md
index bace4752..9565a6d9 100644
--- a/docs/controls.md
+++ b/docs/controls.md
@@ -95,29 +95,31 @@ This screen allows you to perform a measurement.
This screen contains:
-* The name of the measurement
+* The clauses,
-* The goal
+* The name of the measurement,
-* Data
+* The objective,
-* Completion date, planning date
+* The input data,
+
+* Completion date, planning date,
* A text area for observations
* A file area for saving evidence (**CTRL+V** can be used to paste a file or screenshot)
-* A link to download the measurement sheet
+* A link to download the measurement sheet,
-* The computation model applied
+* The computation model applied,
-* The note
+* The note,
-* The score
+* The score,
-* The action plan
+* The action plan,
-* The date of the next check
+* The date of the next check,
[![Screenshot](images/c3.png)](images/c3.png)
[![Screenshot](images/c4.png)](images/c4.png)
diff --git a/resources/views/controls/create.blade.php b/resources/views/controls/create.blade.php
index c0e69197..40287bca 100644
--- a/resources/views/controls/create.blade.php
+++ b/resources/views/controls/create.blade.php
@@ -70,9 +70,9 @@
diff --git a/resources/views/controls/index.blade.php b/resources/views/controls/index.blade.php
index 9cccccfa..7756c5ed 100644
--- a/resources/views/controls/index.blade.php
+++ b/resources/views/controls/index.blade.php
@@ -148,7 +148,7 @@
>