/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/AdminController.php (5772B)
viewBuilder()->setTheme('AdminLTE');
$this->viewBuilder()->setClassName('AdminLTE.AdminLTE');
// Configure the login action to not require authentication, preventing
// the infinite redirect loop issue
$this->Authentication->addUnauthenticatedActions(['login']);
}
public function getFilters($model = null)
{
if (!empty($model)) {
$keywords = $this->request->getQuery();
$conditions = [];
foreach ($keywords as $keyword => $value) {
switch ($keyword) {
case 'user_name':
if (!empty($value)) {
$conditions[] = 'LOWER(CONCAT(Profiles.first_name, " ", Profiles.last_name)) LIKE "%' . strtolower($value) . '%"';
}
break;
//list product
case 'cause_name':
if (!empty($value)) {
$conditions[] = 'LOWER(Causes.name) LIKE "%' . strtolower($value) . '%"';
}
break;
case 'product_name':
if (!empty($value)) {
$conditions[] = 'LOWER(Products.name) LIKE "%' . strtolower($value) . '%"';
}
break;
case 'price_start':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Products.price >=' . strtolower($value);
}
break;
case 'price_end':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Products.price <=' . strtolower($value);
}
break;
case 'stock_start':
if (isset($value) && trim($value) != '') {
$conditions['Products.stock >='] = strtolower($value);
}
break;
case 'stock_end':
if (isset($value) && trim($value) != '') {
$conditions['Products.stock <='] = strtolower($value);
}
break;
// list orders
case 'order_status_date':
[$startDate, $endDate] = explode(' - ', $value);
if (!empty($startDate)) {
$conditions[$model . '.' . $keyword . ' >='] = date('Y-m-d', strtotime($startDate));
}
if (!empty($endDate)) {
$conditions[$model . '.' . $keyword . ' <='] = date('Y-m-d', strtotime($endDate));
}
break;
// list causes
case 'date_start':
[$startDate, $endDate] = explode(' - ', $value);
if (!empty($startDate)) {
$conditions[$model . '.' . $keyword . ' >='] = date('Y-m-d', strtotime($startDate));
}
if (!empty($endDate)) {
$conditions[$model . '.' . $keyword . ' <='] = date('Y-m-d', strtotime($endDate));
}
break;
case 'product_start':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Causes.product_count >=' . strtolower($value);
}
break;
case 'product_end':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Causes.product_count <=' . strtolower($value);
}
break;
case 'order_start':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Causes.order_count >=' . strtolower($value);
}
break;
case 'order_end':
if (isset($value) && trim($value) != '') {
$conditions[] = 'Causes.order_count <=' . strtolower($value);
}
break;
case 'date_end':
[$startDate, $endDate] = explode(' - ', $value);
if (!empty($startDate)) {
$conditions[$model . '.' . $keyword . ' >='] = date('Y-m-d', strtotime($startDate));
}
if (!empty($endDate)) {
$conditions[$model . '.' . $keyword . ' <='] = date('Y-m-d', strtotime($endDate));
}
break;
case 'page':
case 'sort':
case 'direction':
break;
default:
if (isset($value) && trim($value) != '') {
$conditions[$model . '.' . $keyword] = $value;
}
break;
}
}
return $conditions;
}
}
}