@@ -23,7 +23,10 @@ public function __construct( Template $temp, Login $login ) {
2323 $ this ->serverDir = API ::getStorageDir ($ this ->login ->getGroup (), 'Server ' );
2424
2525 if ( $ _SERVER ['REQUEST_METHOD ' ] === 'POST ' ){
26- $ this ->addNew ();
26+ $ addDay = $ this ->addNew ();
27+ if (!is_null ($ addDay )){
28+ $ _GET ['day ' ] = $ addDay ;
29+ }
2730 }
2831 if ( isset ( $ _GET ['day ' ] ) ){
2932 $ this ->viewDay ($ _GET ['day ' ] . '.json ' );
@@ -69,7 +72,7 @@ private function viewDay(string $file) : void {
6972 }
7073 }
7174
72- private function addNew () : void {
75+ private function addNew () : ? string {
7376 $ this ->temp ->setContent ('NOTEDISABLE ' ,'' );
7477
7578 $ fourDigits = array ('begin_Y ' , 'end_Y ' );
@@ -107,7 +110,7 @@ private function addNew() : void {
107110 $ r = new JSONReader (API ::getStorageDir ($ this ->login ->getGroup (), 'Server ' , true ) . date ('Y-m-d ' , $ begin ));
108111 if ($ r ->setValue ([null ], $ task )){
109112 $ this ->temp ->setContent ('NOTEMSG ' ,'Added task. ' );
110- return ;
113+ return date ( ' Y-m-d ' , $ begin ) ;
111114 }
112115 }
113116 $ this ->temp ->setContent ('NOTEMSG ' ,'Unable to save new task. ' );
@@ -116,6 +119,7 @@ private function addNew() : void {
116119 $ this ->temp ->setContent ('NOTEMSG ' ,'End has to be later than begin! ' );
117120 }
118121 }
122+ return null ;
119123 }
120124
121125 private function initDir () : bool {
@@ -140,7 +144,7 @@ private function generateTimestamp(array $post, string $prefix) : int{
140144 private function setUpHtml (){
141145 if ( is_dir ($ this ->serverDir ) ){
142146 $ ds = array ();
143- foreach ( scandir ($ this ->serverDir ) as $ d ){
147+ foreach ( scandir ($ this ->serverDir , SCANDIR_SORT_DESCENDING ) as $ d ){
144148 if ( preg_match (API ::FILENAME_PREG , $ d ) === 1 ){
145149 $ ds [] = array ("DAY " => substr ($ d , 0 , -5 ));
146150 }
0 commit comments