Parcourir la source

[Enhancement] Add ALL and NONE to <select>

Foppe Hemminga il y a 5 ans
Parent
commit
88217c8c99
2 fichiers modifiés avec 18 ajouts et 0 suppressions
  1. 16 0
      index.php
  2. 2 0
      snippets.php

+ 16 - 0
index.php

@@ -70,6 +70,22 @@ if ( $action == 's' ) {
     $maintainer = get_maintainer( $_REQUEST['maintainer'] );
     $player = $_REQUEST['player'];
     $properties = $_REQUEST['properties'];
+    if ( in_array( 'ALL', $properties ) ) {
+        $query = <<<QUERY
+            SELECT DISTINCT property FROM properties; 
+QUERY;
+        $stmt = $pdo->prepare( $query );
+        $stmt->execute();
+        $rows = $stmt->fetchAll();
+        $properties = [];
+        foreach( $rows as $row ) {
+            $properties[] = $row['property'];
+        }
+    }
+    if ( in_array( 'NONE', $properties ) ) {
+        $properties = [];
+        $properties[] = "name";
+    }
     store_player_properties( $player, $maintainer, $properties );
     $screen = 3;
 }

+ 2 - 0
snippets.php

@@ -187,6 +187,8 @@ QUERY;
 		<div class="form-group">
 			<label for="player-edit">Select properties for player ${name} [${player}]</label>
 			<select class="selectpicker" multiple form="player-edit" name="properties[]">
+				<option>ALL</option>
+				<option>NONE</option>
 HTML;
 	$snippets[3] .= "\n";
 	/*