Add sort on last applied template

This commit is contained in:
Romain Neutron
2013-06-13 17:21:15 +02:00
parent 626e8df75b
commit 6584d3583a
3 changed files with 25 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ class Manage extends Helper
, 'like_value' => $request->get('like_value')
, 'sbas_id' => $request->get('sbas_id')
, 'base_id' => $request->get('base_id')
, 'last_model' => $this->request->get('last_model')
, 'srt' => $request->get("srt", \User_Query::SORT_CREATIONDATE)
, 'ord' => $request->get("ord", \User_Query::ORD_DESC)
, 'offset_start' => 0
@@ -69,6 +70,7 @@ class Manage extends Helper
$this->results = $query->sort_by($this->query_parms["srt"], $this->query_parms["ord"])
->like($this->query_parms['like_field'], $this->query_parms['like_value'])
->last_model_is($this->query_parms['last_model'])
->get_inactives($this->query_parms['inactives'])
->include_templates(false)
->on_bases_where_i_am($this->app['authentication']->getUser()->ACL(), array('canadmin'))
@@ -92,6 +94,7 @@ class Manage extends Helper
, 'like_value' => $this->request->get('like_value')
, 'sbas_id' => $this->request->get('sbas_id')
, 'base_id' => $this->request->get('base_id')
, 'last_model' => $this->request->get('last_model')
, 'srt' => $this->request->get("srt", \User_Query::SORT_CREATIONDATE)
, 'ord' => $this->request->get("ord", \User_Query::ORD_DESC)
, 'per_page' => $results_quantity
@@ -107,6 +110,7 @@ class Manage extends Helper
$this->results = $query->sort_by($this->query_parms["srt"], $this->query_parms["ord"])
->like($this->query_parms['like_field'], $this->query_parms['like_value'])
->last_model_is($this->query_parms['last_model'])
->get_inactives($this->query_parms['inactives'])
->include_templates(true)
->on_bases_where_i_am($this->app['authentication']->getUser()->ACL(), array('canadmin'))

View File

@@ -139,6 +139,7 @@ class User_Query implements User_QueryInterface
* @var int
*/
protected $offset_start;
protected $last_model;
/**
*
@@ -228,7 +229,7 @@ class User_Query implements User_QueryInterface
$sql .= ' AND usr.invite=0 ';
}
if (! $this->email_not_null) {
if ($this->email_not_null) {
$sql .= ' AND usr.usr_mail IS NOT NULL ';
}
@@ -321,6 +322,10 @@ class User_Query implements User_QueryInterface
}
}
if ($this->last_model) {
$sql .= ' AND usr.lastModel = "' . mysql_real_escape_string($this->last_model) . '" ';
}
$sql_like = array();
foreach ($this->like_field as $like_field => $like_value) {
@@ -397,6 +402,13 @@ class User_Query implements User_QueryInterface
return $this;
}
public function last_model_is($login = null)
{
$this->last_model = $login instanceof \User_Adapter ? $login->get_login() : $login;
return $this;
}
public function include_phantoms($boolean = true)
{
$this->include_phantoms = ! ! $boolean;

View File

@@ -37,10 +37,16 @@
<option {% if parm['like_field'] == "pays" %}selected="selected"{% endif %} value="pays">{% trans 'Push::filter on countries' %}</option>
<option {% if parm['like_field'] == "societe" %}selected="selected"{% endif %} value="societe">{% trans 'Push::filter on companies' %}</option>
<option {% if parm['like_field'] == "usr_mail" %}selected="selected"{% endif %} value="usr_mail">{% trans 'Push::filter on emails' %}</option>
<option {% if parm['like_field'] == "lastModel" %}selected="selected"{% endif %} value="lastModel">{% trans 'Push::filter on templates' %}</option>
</select>
<span>{% trans 'Push::filter starts' %}</span>
<input type="text" value="{{parm['like_value']}}" name="like_value" class="input-medium">
<span>{% trans 'Last applied template' %}</span>
<select name="last_model" class="input-medium">
<option value="">{% trans 'Any template' %}</option>
{% for template in templates %}
<option {% if parm['last_model'] == template.get_login() %}selected="selected"{% endif %} value="{{ template.get_login() }}">{{ template.get_login() }}</option>
{% endfor %}
</select>
<button type="submit" class="btn">{% trans 'boutton::chercher' %}</button>
</p>
</form>
@@ -161,6 +167,7 @@
{% endif %}
<input name="like_value" value="{{parm.like_value}}" type="hidden" />
<input name="like_field" value="{{parm.like_field}}" type="hidden" />
<input name="last_model" value="{{parm.last_model}}" type="hidden" />
<input name="inactives" value="{{parm.inactives}}" type="hidden" />
</form>