| |
---|
| | if($section['Category'][1] == "-"){ |
---|
| | $jsonArray['align'] = "bad"; |
---|
| | $jsonArray['calCol'] = "#e81b1b"; |
---|
| | $jsonArray['title1'] = "Streak"; |
---|
| | $jsonArray['title2'] = "Top"; |
---|
| | $jsonArray['title3'] = "Total (Year)"; |
---|
| | $jsonArray['title2'] = "Total (Year)"; |
---|
| | $jsonArray['title3'] = "Top"; |
---|
| | |
---|
| | $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog); |
---|
| | $jsonArray['result2'] = habit_get_stat_top_missing($section['Activity'], $moodlog); |
---|
| | $jsonArray['result3'] = habit_get_stat_year($section['Activity'], $moodlog); |
---|
| | $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog); |
---|
| | $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog); |
---|
| | } |
---|
| | $todayCheck = habit_check_daily($section['Activity'], $moodlog); |
---|
| | if ($todayCheck) { |
---|
| | $jsonArray['buttonClass'] = 'button-'.$jsonArray['align']; |
---|
| |
---|
| | |
---|
| | if( $weekCount < $multiplier ) |
---|
| | if($todayCheck) |
---|
| | $jsonArray['buttonText'] = $weekCount; |
---|
| | if($weekCount >= $multiplier) |
---|
| | $jsonArray['buttonClass'] = 'button-done'; |
---|
| | if( $todayCheck ) { |
---|
| | $jsonArray['buttonClass'] = 'button-neut'; |
---|
| | if($weekCount >= $multiplier) |
---|
| | $jsonArray['buttonClass'] = 'button-good'; |
---|
| |
---|
| | |
---|
| | if($found) |
---|
| | return json_encode($jsonArray); |
---|
| | return false; |
---|
| | } |
---|
| | |
---|
| | function habit_get_json_all($moodlog, $habitlog) { |
---|
| | $fileContent = file_get_contents($habitlog); |
---|
| | $resultArray = habit_parse_file($fileContent); |
---|
| | |
---|
| | $jsonWordsArray = array(); |
---|
| | |
---|
| | foreach ($resultArray as $section) { |
---|
| | $jsonArray = array(); |
---|
| | $jsonArray['activity'] = $section['Activity']; |
---|
| | $jsonArray['align'] = ""; |
---|
| | $jsonArray['buttonClass'] = ""; |
---|
| | $jsonArray['buttonText'] = ""; |
---|
| | |
---|
| | if ($section['Category'][0] == "d") { |
---|
| | $jsonArray['freq'] = "d"; |
---|
| | |
---|
| | if ($section['Category'][1] == "+") { |
---|
| | $jsonArray['align'] = "good"; |
---|
| | $jsonArray['calCol'] = "#58e81b"; |
---|
| | $jsonArray['title1'] = "Streak"; |
---|
| | $jsonArray['title2'] = "Missed"; |
---|
| | $jsonArray['title3'] = "Top"; |
---|
| | $jsonArray['result1'] = habit_get_stat_streak($section['Activity'], $moodlog); |
---|
| | $jsonArray['result2'] = habit_get_stat_missed($section['Activity'], $moodlog); |
---|
| | $jsonArray['result3'] = habit_get_stat_top($section['Activity'], $moodlog); |
---|
| | } elseif ($section['Category'][1] == "-") { |
---|
| | $jsonArray['align'] = "bad"; |
---|
| | $jsonArray['calCol'] = "#e81b1b"; |
---|
| | $jsonArray['title1'] = "Streak"; |
---|
| | $jsonArray['title2'] = "Total (Year)"; |
---|
| | $jsonArray['title3'] = "Top"; |
---|
| | $jsonArray['result1'] = habit_get_stat_missed($section['Activity'], $moodlog); |
---|
| | $jsonArray['result2'] = habit_get_stat_year($section['Activity'], $moodlog); |
---|
| | $jsonArray['result3'] = habit_get_stat_top_missing($section['Activity'], $moodlog); |
---|
| | } |
---|
| | |
---|
| | $todayCheck = habit_check_daily($section['Activity'], $moodlog); |
---|
| | |
---|
| | if ($todayCheck) { |
---|
| | $jsonArray['buttonClass'] = 'button-' . $jsonArray['align']; |
---|
| | } |
---|
| | } elseif ($section['Category'][0] == "w") { |
---|
| | $jsonArray['freq'] = "w"; |
---|
| | |
---|
| | $multiplier = $section['Category'][1]; |
---|
| | $jsonArray['align'] = "good"; |
---|
| | $jsonArray['title1'] = "Streak"; |
---|
| | $jsonArray['title2'] = "Missed"; |
---|
| | $jsonArray['title3'] = "Top"; |
---|
| | $jsonArray['result1'] = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog); |
---|
| | $jsonArray['result2'] = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog); |
---|
| | $jsonArray['result3'] = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog); |
---|
| | |
---|
| | $todayCheck = habit_check_daily($section['Activity'], $moodlog); |
---|
| | $weekCount = habit_count_weekly($section['Activity'], $moodlog); |
---|
| | $jsonArray['weekSoFar'] = $weekCount; |
---|
| | $jsonArray['weekGoal'] = $multiplier; |
---|
| | |
---|
| | if ($weekCount < $multiplier && $todayCheck) { |
---|
| | $jsonArray['buttonText'] = $weekCount; |
---|
| | } |
---|
| | |
---|
| | if ($weekCount >= $multiplier) { |
---|
| | $jsonArray['buttonClass'] = 'button-done'; |
---|
| | } |
---|
| | |
---|
| | if ($todayCheck) { |
---|
| | $jsonArray['buttonClass'] = 'button-neut'; |
---|
| | |
---|
| | if ($weekCount >= $multiplier) { |
---|
| | $jsonArray['buttonClass'] = 'button-good'; |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | $jsonWordsArray[] = $jsonArray; |
---|
| | } |
---|
| | |
---|
| | return json_encode($jsonWordsArray); |
---|
| | } |
---|
| | |
---|
| | /*** |
---|
| | * creating calendar stuff |
---|
| |
---|
| | |