Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 383

Přidáno uživatelem Michal Kliment před více než 15 roky(ů)

Zmena selectboxu na klasicky input s naseptavacem u vyberu uzivatele u pridavani noveho celeho zarizeni, prvni vlatovka - zatim vicemene test...

Zobrazit rozdíly:

freenetis/trunk/kohana/application/models/user.php
if (isset($user_id)) return (bool) self::$db->where(array('email' => $email, 'id!=' => $user_id))->count_records('users');
else return (bool) self::$db->where('email', $email)->count_records('users');
}
public function get_users($user)
{
return self::$db->query("SELECT id, CONCAT(surname,' ',name,' - ',login) as user FROM users WHERE CONCAT(surname,' ',name,' - ',login) LIKE '" . $user . "%' GROUP BY CONCAT(surname,' ',name,' - ',login)");
}
}
?>
freenetis/trunk/kohana/application/controllers/users.php
} // end of change password function
function get_users()
{
$q = strtolower($this->input->get('q'));
if (!$q) return;
$user_model = new User_Model();
$users = $user_model->get_users($q);
foreach ($users as $user) echo $user->user."\n";
}
/********************************************
*********** CALLBACK FUNCTIONS **************
*********************************************/
freenetis/trunk/kohana/application/controllers/devices.php
$form->group('')->label(url_lang::lang('texts.Basic data'));
$model_user = new User_Model;
$user_model = new User_Model;
if($ssMember_id)
{
$member = new Member_Model($ssMember_id);
$users = $model_user->select('id','name','surname','login')->orderby('id')->find_all_by_member_id($ssMember_id);
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all_by_member_id($ssMember_id);
}
else
{
$users = $model_user->select('id','name','surname','login')->orderby('id')->find_all();
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.select user').' -----';
}
......
}
asort($arr_users);
$engineers = $model_user->select('id','name','surname','login')->orderby('id')->find_all();
$engineers = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_engineers[0] = '----- '.url_lang::lang('texts.select user').' -----';
foreach ($engineers as $engineer) {
......
$form->group('')->label(url_lang::lang('texts.Basic data'));
$model_user = new User_Model;
$users = $model_user->select('id','name','surname','login')->orderby('id')->find_all();
$user_model = new User_Model;
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
foreach ($users as $user) {
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
}
......
$form->group('')->label(url_lang::lang('texts.Device'));
$model_user = new User_Model;
$user_model = new User_Model;
$username = '';
// finding member
if($ssMember_id)
{
$member = new Member_Model($ssMember_id);
$users = $model_user->select('id','name','surname','login')->orderby('id')->find_all_by_member_id($ssMember_id);
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all_by_member_id($ssMember_id);
$user = $user_model->where('member_id',$ssMember_id)->find();
$username = $user->surname.' '.$user->name.' - '.$user->login;
}
else
{
$users = $model_user->select('id','name','surname','login')->orderby('id')->find_all();
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.select user').' -----';
}
......
}
asort($arr_users, SORT_LOCALE_STRING);
$engineers = $model_user->select('id','name','surname','login')->orderby('id')->find_all();
$engineers = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
foreach ($engineers as $engineer)
{
......
// form
// adding device
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required');
$form->input('user')->label(url_lang::lang('texts.user'))->rules('required')->callback(array($this,'exist_user'))->value($username);
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[2,250]');
$form->dropdown('type')->label(url_lang::lang('texts.Type'))->options($types)->rules('required');
$form->checkbox('PPPoE_logging_in')->label(url_lang::lang('texts.PPPoE'))->value('1');
......
$engineers_data[] = $form_data["first_engineer_id"];
if($form_data["second_engineer_id"] > 0)
$engineers_data[] = $form_data["second_engineer_id"];
$device_model->user_id = htmlspecialchars($form_data["user_id"]);
$user_model = new User_Model();
$user = $user_model->get_users(htmlspecialchars($form_data["user"]))->current();
$device_model->user_id = $user->id;
$device_model->name = htmlspecialchars($form_data["name"]);
$device_model->type = htmlspecialchars($form_data["type"]);
//$device_model->description = htmlspecialchars($form_data["description"]);
......
$view->header->title = url_lang::lang('texts.Add new whole device');
$view->header->menu = Controller::render_menu();
$view->render(TRUE);
} // end of function add_whole
} // end of function add_whole
function exist_user($input)
{
$user_model = new User_Model();
$users = $user_model->get_users($input->value);
if (count($users)==0)
{
$input->add_error('required', url_lang::lang('texts.User not found.'));
}
else if (count($users)>1)
{
$input->add_error('required', url_lang::lang('texts.You must specify user\'s name.'));
}
}
/**
* Function checks validity of ip address.
* @param $input ip address to validate
freenetis/trunk/kohana/application/views/base/header.php
$('#town').autocomplete('<?php echo url_lang::base() ?>members/get_towns/');
$('#zip_code').autocomplete('<?php echo url_lang::base() ?>members/get_ZIP_codes/');
$('#quarter').autocomplete('<?php echo url_lang::base() ?>members/get_quarters/');
$('#user').autocomplete('<?php echo url_lang::base() ?>users/get_users/');
});
</script>
</head>

Také k dispozici: Unified diff