Commit 093426e8 authored by okhin's avatar okhin 🚴

Adding a page field where needed

parent 151faf24
Pipeline #2241 passed with stages
in 12 seconds
...@@ -85,13 +85,15 @@ class Admin extends Controller ...@@ -85,13 +85,15 @@ class Admin extends Controller
$public = $f3->exists('POST.public') ? $f3->get('POST.public') : ''; $public = $f3->exists('POST.public') ? $f3->get('POST.public') : '';
$status = $f3->exists('POST.status') ? $f3->get('POST.status') : ''; $status = $f3->exists('POST.status') ? $f3->get('POST.status') : '';
$limit = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50; $limit = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50;
$page = $f3->exists('POST.page') ? (int) $f3->get('POST.page') : 1;
$results = $f3->get('container')['donation_finder']->adminSearch($text, $sum, $public, $status, $limit); $results = $f3->get('container')['donation_finder']->adminSearch($text, $sum, $public, $status, $limit, $page);
$f3->set('row_count', count($results)); $f3->set('row_count', count($results));
$f3->set('texte', $text); $f3->set('texte', $text);
$f3->set('somme', $sum); $f3->set('somme', $sum);
$f3->set('limite', $limit); $f3->set('limite', $limit);
$f3->set('page', $page);
$f3->set('public', $public); $f3->set('public', $public);
$f3->set('status', $status); $f3->set('status', $status);
$f3->set('data', $results); $f3->set('data', $results);
...@@ -383,7 +385,8 @@ class Admin extends Controller ...@@ -383,7 +385,8 @@ class Admin extends Controller
$hoodie = ''; $hoodie = '';
$pseudo = ''; $pseudo = '';
$quoi = 0; $quoi = 0;
$limite = '50'; $limite = 50;
$page = 1;
$status = ''; $status = '';
$db = $f3->get('DB'); $db = $f3->get('DB');
if ($f3->get('VERB')=='POST') { if ($f3->get('VERB')=='POST') {
...@@ -415,10 +418,8 @@ class Admin extends Controller ...@@ -415,10 +418,8 @@ class Admin extends Controller
$pishirt = $f3->get('POST.pishirt'); $pishirt = $f3->get('POST.pishirt');
$hoodie = $f3->get('POST.hoodie'); $hoodie = $f3->get('POST.hoodie');
$quoi = $quoi + $pibag + $piplome + $pishirt + $hoodie; $quoi = $quoi + $pibag + $piplome + $pishirt + $hoodie;
$limite = $f3->get('POST.limite'); $limite = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50;
if ($limite=='') { $page = $f3->exists('POST.page') ? (int) $f3->get('POST.page') : 1;
$limite = '50';
}
$status = $f3->get('POST.status'); $status = $f3->get('POST.status');
} }
...@@ -486,7 +487,9 @@ class Admin extends Controller ...@@ -486,7 +487,9 @@ class Admin extends Controller
if ($status) { if ($status) {
$query .= " AND c.status IN (".\Utils::asl($status).") "; $query .= " AND c.status IN (".\Utils::asl($status).") ";
} }
$query .= " ORDER BY c.datec DESC LIMIT 0,".$limite.";"; $first = ($page - 1) * $limite;
$last = $page * $limite;
$query .= " ORDER BY c.datec DESC LIMIT $first, $last;";
$result = $db->query($query); $result = $db->query($query);
$data = array(); $data = array();
if ($result) { if ($result) {
...@@ -525,6 +528,7 @@ class Admin extends Controller ...@@ -525,6 +528,7 @@ class Admin extends Controller
$f3->set('pishirt', $pishirt); $f3->set('pishirt', $pishirt);
$f3->set('hoodie', $hoodie); $f3->set('hoodie', $hoodie);
$f3->set('limite', $limite); $f3->set('limite', $limite);
$f3->set('page', $page);
$f3->set('status', $status); $f3->set('status', $status);
$f3->set('query', $query); $f3->set('query', $query);
$f3->set('data', $data); $f3->set('data', $data);
...@@ -792,12 +796,14 @@ class Admin extends Controller ...@@ -792,12 +796,14 @@ class Admin extends Controller
$text = $f3->exists('POST.texte') ? $f3->get('POST.texte') : ''; $text = $f3->exists('POST.texte') ? $f3->get('POST.texte') : '';
$status = $f3->exists('POST.status') ? $f3->get('POST.status') : ''; $status = $f3->exists('POST.status') ? $f3->get('POST.status') : '';
$limit = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50; $limit = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50;
$page = $f3->exists('POST.page') ? (int) $f3->get('POST.page') : 1;
$results = $f3->get('container')['user_finder']->adminSearch($text, $status, $limit); $results = $f3->get('container')['user_finder']->adminSearch($text, $status, $limit);
$f3->set('texte', $text); $f3->set('texte', $text);
$f3->set('status', $status); $f3->set('status', $status);
$f3->set('limite', $limit); $f3->set('limite', $limit);
$f3->set('page', $page);
$f3->set('data', $results); $f3->set('data', $results);
$f3->set('row_count', count($results)); $f3->set('row_count', count($results));
$f3->set('block_content', 'backend/users.html'); $f3->set('block_content', 'backend/users.html');
...@@ -809,6 +815,7 @@ class Admin extends Controller ...@@ -809,6 +815,7 @@ class Admin extends Controller
$texte = ''; $texte = '';
$status = ''; $status = '';
$limite = '50'; $limite = '50';
$page = '1';
$db = $f3->get('DB'); $db = $f3->get('DB');
if ($f3->get('VERB')=='POST') { if ($f3->get('VERB')=='POST') {
if ($f3->exists('POST.action')) { if ($f3->exists('POST.action')) {
...@@ -836,12 +843,11 @@ class Admin extends Controller ...@@ -836,12 +843,11 @@ class Admin extends Controller
break; break;
} }
} }
$texte = $f3->get('POST.texte');
$status = $f3->get('POST.status'); $limit = $f3->exists('POST.limite') ? (int) $f3->get('POST.limite') : 50;
$limite = $f3->get('POST.limite'); $page = $f3->exists('POST.page') ? (int) $f3->get('POST.page') : 1;
if ($limite=='') { $texte = $f3->exists('POST.texte') ? $f3->get('POST.texte') : '';
$limite = '50'; $status = $f3->exists('POST.status') ? $f3->get('POST.status') : '';
}
} }
$query = "SELECT id, email, expiration, status FROM users WHERE identifier!='' AND identifier IS NOT NULL AND status != ''"; $query = "SELECT id, email, expiration, status FROM users WHERE identifier!='' AND identifier IS NOT NULL AND status != ''";
...@@ -852,7 +858,9 @@ class Admin extends Controller ...@@ -852,7 +858,9 @@ class Admin extends Controller
if ($status!='') { if ($status!='') {
$query .= " AND status='".$status."'"; $query .= " AND status='".$status."'";
} }
$query .= " ORDER BY expiration ASC LIMIT 0,".$limite.";"; $first = ($page - 1) * $limit;
$last = $page * $limit;
$query .= " ORDER BY expiration ASC LIMIT $first, $last;";
$result = $db->query($query); $result = $db->query($query);
$cbs = array(); $cbs = array();
if ($result) { if ($result) {
...@@ -886,6 +894,7 @@ class Admin extends Controller ...@@ -886,6 +894,7 @@ class Admin extends Controller
$f3->set('limite', $limite); $f3->set('limite', $limite);
$f3->set('query', $query); $f3->set('query', $query);
$f3->set('data', $cbs); $f3->set('data', $cbs);
$f3->set('page', $page);
if ($export) { if ($export) {
$statuts = $f3->get('CB_STATUTS'); $statuts = $f3->get('CB_STATUTS');
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
</repeat> </repeat>
</select> </select>
<label for="page">Page</label>
<input type="text" id="page" name="page" size="3" value="{{ @page }}" />
<label for="limite">Limite</label> <label for="limite">Limite</label>
<input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" /> <input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" />
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
<label for="limite">Limite</label> <label for="limite">Limite</label>
<input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" /> <input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" />
<label for="page">Page</label>
<input type="text" id="page" name="page" size="3" value="{{ @page }}" />
<input type="submit" value="Filtrer" /> <input type="submit" value="Filtrer" />
</form> </form>
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
</repeat> </repeat>
</select> </select>
<label for="page">Page</label>
<input type="text" id="page" name="page" size="3" value="{{ @page }}" />
<label for="limite">Limite</label> <label for="limite">Limite</label>
<input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" /> <input type="text" id="limite" name="limite" size="3" value="{{ @limite }}" />
......
...@@ -43,7 +43,7 @@ class DonationFinder ...@@ -43,7 +43,7 @@ class DonationFinder
* *
* @return array * @return array
*/ */
public function adminSearch($text, $sum, $public, $status, $limit = 50) public function adminSearch($text, $sum, $public, $status, $limit = 50, $page = 1)
{ {
$query = <<<EOQ $query = <<<EOQ
SELECT d.id as id, SELECT d.id as id,
...@@ -86,7 +86,10 @@ EOQ; ...@@ -86,7 +86,10 @@ EOQ;
$query .= ' AND d.status IN (:status) '; $query .= ' AND d.status IN (:status) ';
$params['status'] = $status; $params['status'] = $status;
} }
$query .= " ORDER BY datec DESC LIMIT 0,$limit";
$first = ($page - 1) * $limit;
$last = ($page) * $limit;
$query .= " ORDER BY datec DESC LIMIT $first, $last";
return $this->connection->fetchAll($query, $params); return $this->connection->fetchAll($query, $params);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment