Completed
Pull Request — master (#178)
by Corey
04:40
created
site/controllers/CheckinController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
   public function actionIndex() {
38 38
     $form = Yii::$container->get(\site\models\CheckinForm::class);
39 39
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
40
-      if(!$form->compileBehaviors()) {
40
+      if (!$form->compileBehaviors()) {
41 41
         return $this->redirect(['view']);
42 42
       }
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
       return $this->redirect(['questions']);
49 49
     }
50 50
 
51
-    $behaviors  = Yii::$container->get(BehaviorInterface::class)::$behaviors;
51
+    $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors;
52 52
     $custom = \common\models\CustomBehavior::find(['user_id' => Yii::$app->user->identity->id])->asArray()->all();
53 53
     return $this->render('index', [
54 54
       'categories'    => Yii::$container->get(CategoryInterface::class)::$categories,
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     $date = Yii::$container->get(TimeInterface::class)->getLocalDate();
64 64
 
65 65
     $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date);
66
-    if(count($user_behaviors) === 0) {
66
+    if (count($user_behaviors) === 0) {
67 67
       return $this->redirect(['view']);
68 68
     }
69 69
 
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
       $form->deleteToday();
74 74
 
75 75
       $behaviors = $user_behavior->findAll($form->getUserBehaviorIds());
76
-      if($result = $form->saveAnswers(Yii::$app->user->identity->id, $behaviors)) {
76
+      if ($result = $form->saveAnswers(Yii::$app->user->identity->id, $behaviors)) {
77 77
 
78
-        if(Yii::$app->user->identity->send_email) {
79
-          if(Yii::$app->user->identity->sendEmailReport($date)) {
78
+        if (Yii::$app->user->identity->send_email) {
79
+          if (Yii::$app->user->identity->sendEmailReport($date)) {
80 80
             Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.');
81 81
           } else {
82 82
             Yii::$app->session->setFlash('success', 'Your check-in is complete.');
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     $raw_pie_data  = $user_behavior::decorate($user_behavior->getBehaviorsWithCounts());
133 133
     $answer_pie    = $user_behavior->getBehaviorsByCategory($raw_pie_data);
134 134
 
135
-    $pie_data   = [
135
+    $pie_data = [
136 136
       "labels"   => array_column($answer_pie, "name"),
137 137
       "datasets" => [[
138 138
           "data"                 => array_map('intval', array_column($answer_pie, "count")),
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
     $checkins = $user_behavior->getCheckInBreakdown($period);
168 168
 
169 169
     $accum = [];
170
-    foreach($checkins as $date => $cats) {
171
-      for($i = 1; $i <= 7; $i ++) {
170
+    foreach ($checkins as $date => $cats) {
171
+      for ($i = 1; $i <= 7; $i++) {
172 172
         $accum[$i][] = array_key_exists($i, $cats) ? $cats[$i]['count'] : [];
173 173
       }
174 174
     }
175 175
 
176 176
     $bar_datasets = [];
177
-    foreach($accum as $idx => $data) {
177
+    foreach ($accum as $idx => $data) {
178 178
       $bar_datasets[] = [
179 179
         'label' => ($category::getCategories())[$idx],
180 180
         'backgroundColor' => $category::$colors[$idx]['color'],
Please login to merge, or discard this patch.