Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 408

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

Opraveny chyby u funkce add_whole u kontroleru zarizeni.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'add new vlan interface' => 'Přidat nové VLAN rozhraní',
'add new vlan' => 'Přidat nový VLAN',
'add new whole device' => 'Přidat nové celé zařízení',
'add new whole device for member' => 'Přidat nové celé zařízení pro člena',
'add new whole device for user' => 'Přidat nové celé zařízení pro uživatele',
'add new work' => 'Přidat novou práci',
'add wireless setting' => 'Přidat bezdrátové nastavení',
'additional_contacts_infotext' => 'Další kontaktní informace',
freenetis/trunk/kohana/application/controllers/devices.php
* and new ip address assigned to this interface.
* @return unknown_type
*/
function add_whole($member_id = null)
function add_whole($user_id = null)
{
$this->user = new User_Model($user_id);
// access rights
if (!$this->acl_check_new(get_class($this),'devices',$member_id))
if (!$this->acl_check_new(get_class($this),'devices',$this->user->member_id))
Controller::error(ACCESS);
// enum types for device
$enum_type_model = new Enum_type_Model();
......
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->group('')->label(url_lang::lang('texts.Device'));
$user_model = new User_Model;
// javascript is on
if ($this->setting->use_javascript)
// finding user
if($this->user->id)
{
$username = '';
// finding member
if(isset($member_id))
{
$user = $user_model->where('member_id',$member_id)->find();
if ($user->id == 0)
Controller::error(RECORD);
$username = $user->surname.' '.$user->name.' - '.$user->login;
}
$form->input('user')->label(url_lang::lang('texts.user').':')->rules('required')->callback(array($this,'exist_user'))->value($username);
$arr_users[$this->user->id] = $this->user->surname.' '.$this->user->name.' - '.$this->user->login;
}
else
{
// javascript is off
// finding member
if(isset($member_id))
{
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all_by_member_id($member_id);
if ($users->id == 0)
Controller::error(RECORD);
}
else
{
$users = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
$arr_users[0] = '----- '.url_lang::lang('texts.select user').' -----';
}
foreach ($users as $user)
{
$arr_users[$user->surname.' '.$user->name.' - '.$user->login] = $user->surname.' '.$user->name.' - '.$user->login;
}
asort($arr_users, SORT_LOCALE_STRING);
$form->dropdown('user')->label(url_lang::lang('texts.user').':')->rules('required')->options($arr_users);
$users = $user_model->find_all();
foreach ($users as $user)
{
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
}
asort($arr_users, SORT_LOCALE_STRING);
$arr_users = array_merge(array(0 => '----- '.url_lang::lang('texts.select user').' -----'), $arr_users);
}
$form->dropdown('user_id')->label(url_lang::lang('texts.user').':')->rules('required')->options($arr_users);
$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');
......
$form->input('location_address')->label(url_lang::lang('texts.location address').':')->rules('length[3,254]');
$form->input('location_details')->label(url_lang::lang('texts.location details').':')->rules('length[3,254]');
$form->textarea('comment')->label(url_lang::lang('texts.comment').':')->rules('length[0,254]');
// javascript is on
if ($this->setting->use_javascript)
$engineers = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
foreach ($engineers as $engineer)
{
$engineer_name = $this->session->get('user_surname').' '.$this->session->get('user_name').' - '.$this->session->get('member_login');
$form->input('first_engineer')->label(url_lang::lang('texts.engineer').':')->rules('required')->callback(array($this,'exist_user'))->value($engineer_name);
$arr_engineers[$engineer->id] = $engineer->surname.' '.$engineer->name.' - '.$engineer->login;
}
else
{
// javascript is off
$engineers = $user_model->select('id','name','surname','login')->orderby('id')->find_all();
foreach ($engineers as $engineer)
{
$arr_engineers[$engineer->surname.' '.$engineer->name.' - '.$engineer->login] = $engineer->surname.' '.$engineer->name.' - '.$engineer->login;
}
$arr_engineers[0] = '----- '.url_lang::lang('texts.select user').' -----';
asort($arr_engineers, SORT_LOCALE_STRING);
$form->dropdown('first_engineer')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($this->session->get('user_surname').' '.$this->session->get('user_name').' - '.$this->session->get('member_login'));
}
asort($arr_engineers, SORT_LOCALE_STRING);
$arr_engineers = array_merge(array(0 => '----- '.url_lang::lang('texts.select user').' -----'), $arr_engineers);
$form->dropdown('first_engineer_id')->label(url_lang::lang('texts.engineer').':')->options($arr_engineers)->rules('required')->selected($this->session->get('user_surname').' '.$this->session->get('user_name').' - '.$this->session->get('member_login'));
// adding interface
$form->group('')->label(url_lang::lang('texts.Interface'));
$form->input('MAC')->label(url_lang::lang('texts.MAC').':')->rules('required|length[3,250]');
......
// device model
$device_model = new Device_Model();
$user_model = new User_Model();
$user = $user_model->get_users(htmlspecialchars($form_data["user"]))->current();
$device_model->user_id = $user->id;
$device_model->user_id = $form_data["user_id"];
$device_model->name = htmlspecialchars($form_data["name"]);
$device_model->type = htmlspecialchars($form_data["type"]);
$device_model->PPPoE_logging_in = htmlspecialchars($form_data["PPPoE_logging_in"]);
......
// device engineer model
$device_engineer = new Device_engineer_Model();
$device_engineer->device_id = $device_model->id;
$user = $user_model->get_users($form_data['first_engineer'])->current();
$device_engineer->user_id = $user->id;
$device_engineer->user_id = $form_data["first_engineer_id"];
$device_engineer_saved = $device_engineer->save();
// interface model
......
$view->header = new View('base/header');
$view->content = new View('form');
$view->content->form = $form->html();
if(isset($member_id))
if($this->user->id)
{
$view->content->link_back = html::anchor(url_lang::base().'devices/show_by_member/'.$member_id, url_lang::lang('texts.Back to devices list of this member'));
$member = new Member_Model($member_id);
$view->content->headline = url_lang::lang('texts.Add new whole device for member').' '.$member->name;
$view->content->link_back = html::anchor(url_lang::base().'devices/show_by_user/'.$this->user->id, url_lang::lang('texts.Back to devices of user'));
$view->content->headline = url_lang::lang('texts.Add new whole device for user').' '.$this->user->name.' '.$this->user->surname;
}
else
{

Také k dispozici: Unified diff