Код: Выделить всё
{% partial 'companies' %}
jQuery( document ).ready(function() {
jQuery('body').on('click', '#create_new', function(){
jQuery('form').request('onAllocate');
});
jQuery( "#tabs" ).tabs() ;
jQuery('body').on('click', '.block_user', function(){
if(confirm('Are you sure you want to block this user?'))
{
var alt = jQuery(this).attr("alt");
jQuery('form').request('onUserBlock', {data: {alt: alt},});
}
});
});
Код: Выделить всё
Name
Email address
{% for id, row in companies %}
{{ row.name }}
{{ row.email }}
[url=javascript:;][Block][/url]
{% endfor %}
Код: Выделить всё
public function prepareVars()
{
$this->page['user'] = $this->user();
$this->page['canRegister'] = $this->canRegister();
$this->page['loginAttribute'] = $this->loginAttribute();
$this->page['loginAttributeLabel'] = $this->loginAttributeLabel();
$this->page['updateRequiresPassword'] = $this->updateRequiresPassword();
$this->page['rememberLoginMode'] = $this->rememberLoginMode();
#Log::info(json_encode($this->post_id));
if($this->page->id == 'users' && $this->user())
{
$this->onCompanies();
}
}
public function onCompanies()
{
$usr = Auth::User()->getAttributes();
$list = Array();
$all = Db::select('select * from users_allocation where slave_id = ? and blocked < 1', [$usr['id']]);
if (count($all) > 0) {
foreach ($all as $a) {
$company = Db::select('select * from users where id = ?', [$a->owner_id]);
if (count($company) > 0) {
foreach ($company as $cp) {
$cid = md5($cp->id);
$list[$cid]['user_id'] = md5($a->owner_id);
$list[$cid]['name'] = $cp->name;
$list[$cid]['email'] = $cp->email;
}
}
}
}
$this->page['companies'] = $list;
return [
'#tabs-1' => $this->renderPartial('companies')
];
}
Код: Выделить всё
public function onUserBlock()
{
$data = post();
$id = $data['alt'];
$usr = Auth::User()->getAttributes();
$company = Db::select('select * from users_allocation where md5(owner_id) = ? and slave_id = ? and blocked = 1', [$id, $usr['id']]);
if (count($company) > 0) {
Flash::error('This company already blocked.');
return false;
}
else
{
Db::update('update users_allocation set blocked = 1 where md5(owner_id) = ? and slave_id = ?', [$id, $usr['id']]);
$this->onCompanies();
Flash::success(Lang::get(/**/'Company successfully blocked and will not able to send you invitation.'));
}
}
Я пытался поместить $this->onCompanies(); до и после Flash::успех, но безуспешно.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ry-request
Мобильная версия