Support forumCategory: Feature requestsPatch for new functionality
Paolo Emilio Mazzon asked 2 years ago

Hello Nikola, I’ve added a new functionality to the plugin. I don’t know if this can be of any interest to other users so I post here the patch for the sources. Feel free to integrate it if you think it’s useful.
The patch allow the days of the calendar to be colored differently if there are some slots busy but there are still some slots available. I see the plugin now marks days as “all free” or “all busy” instead (which is misleading in my opinion). Partially busy days are marked orange: please change the color if you don’t like it 🙂
The patch can be applied by copying it in the main source directory and then using
patch -p0<some-busy.patch
 

--- src/report.php.orig	2016-08-15 20:46:28.000000000 +0200
+++ src/report.php	2021-01-25 13:55:09.021654937 +0100
@@ -108,6 +108,16 @@
 
         $result = array();
 
+     /**
+      * 
+      * new display logic: date can be in four different states
+      * 
+      *   no-slots => no slots are present (e.g. holidays)
+      *       free => all slots are free
+      *       busy => all slots are taken
+      * some-slots => some slots are taken 
+      */
+
         foreach ($slots as $key => $value) {
             if ($currentDate > $key) {
                 continue;
@@ -118,20 +128,26 @@
                 continue;
             }
 
-            $has_free = false;
+            $has_busy = 0;
+			$allbusy = true;
             foreach ($value as $k => $v) {
-                if (((int)$v['count']) > 0) {
-                    $result[$key] = 'free';
-                    $has_free = true;
-                    break;
+                if (((int)$v['count']) == 0) {
+					$has_busy += 1;
                 }
+				else {
+					$allbusy = false;
+				}
             }
+			$result[$key] = 'free';
 
-            if (!$has_free) {
+			if ($allbusy) {
                 $result[$key] = 'busy';
             }
+            else if ($has_busy > 0) {
+                     $result[$key] = 'some-slots';
+            }
         }
 
         return $result;
     }
-}
\ No newline at end of file
+}
--- css/eafront-bootstrap.css.orig	2020-09-27 15:37:42.000000000 +0200
+++ css/eafront-bootstrap.css	2021-01-25 13:57:32.188880954 +0100
@@ -252,6 +252,17 @@
 	
 }
 
+.ea-bootstrap .ui-datepicker .some-slots, .ea-bootstrap .ui-datepicker .some-slots:hover {
+        background-color:rgba(255,180,0,0.75);
+        color: #fff;
+        cursor: default;
+}
+
+.ea-bootstrap .ui-datepicker .some-slots a {
+        color: #fff;
+        cursor: default;
+}
+
 .ea-bootstrap .ui-datepicker .no-slots, .ea-bootstrap .ui-datepicker .no-slots:hover {
 	background-color:rgba(163,163,117,0.5);
 	color: #fff;
@@ -383,4 +394,4 @@
     width: 100%;  
   }*/
 }
-/* BOOTSRAP FORM FIELDS LABEL ABOVE THE FIELD - END */
\ No newline at end of file
+/* BOOTSRAP FORM FIELDS LABEL ABOVE THE FIELD - END */
elkosx18 replied 2 years ago

The patch is great. I would welcome to see it getting merged as it is a great improvement. Thank you

3 Answers
Nikola Loncar Staff answered 2 years ago

Thanks for code we will test it out. 🙂

Best regards,
Nikola

elkosx18 answered 2 years ago

Dear Nikola,
 
currently the patch is still working with latest version and its just a little of code (you may could add a checkbox in config for activation or not) and this little piece of code makes it much more intuitive to use. Why you ain’t merging it?
 
Sincerely,
Elkosx18

Nikola Loncar Staff answered 2 years ago

Hi, sorry for waiting. It will be added in next version.

Best regards,
Nikola

elkosx18 replied 2 years ago

Awesome, thanks in advance!