Revize 122
Přidáno uživatelem Michal Kliment před téměř 16 roky(ů)
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
unset($url_array);
|
||
$query = $device_model->get_all_by_member($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $member_id);
|
||
$total_devices=$device_model->count_last_query();
|
||
$grid = new Grid(url_lang::base().'devices', null,array(
|
||
$grid = new Grid(url_lang::base().'devices/show_by_member', null,array(
|
||
//'separator' => '<br />-----------',
|
||
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
... | ... | |
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'variables' => $member_id.'/',
|
||
'url_array_ofset' => 1
|
||
'limit_results' => $limit_results
|
||
));
|
||
|
||
$grid->order_field('id')->label('ID')->class('center');
|
||
... | ... | |
|
||
if (!isset($device_id) || $device->id == 0) {
|
||
Controller::error();
|
||
}
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
|
||
}
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
|
||
$device_type = $enum_type_model->get_value($device->type);
|
||
|
||
$this->session->set('ssDevice_id',$device->id);
|
||
... | ... | |
$user_model = new User_Model;
|
||
$iface_model = new Iface_Model;
|
||
$ip_model = new Ip_address_Model;
|
||
$subnet_model = new Subnet_Model;
|
||
$subnet_model = new Subnet_Model;
|
||
$device_engineer_model = new Device_engineer_Model();
|
||
|
||
$engineers = $device_engineer_model->find_all_by_device_id($device->id);
|
||
$ifaces = $iface_model ->find_all_by_device_id($device->id);
|
||
|
||
$arr_engineers = array();
|
||
|
||
foreach($engineers as $engineer) {
|
||
|
||
$arr_engineers[] = $engineer->user->name . ' ' . $engineer->user->surname;
|
||
|
||
$ifaces = $iface_model ->find_all_by_device_id($device->id);
|
||
|
||
$arr_engineers = array();
|
||
|
||
foreach($engineers as $engineer) {
|
||
|
||
$arr_engineers[] = $engineer->user->name . ' ' . $engineer->user->surname;
|
||
|
||
}
|
||
|
||
|
||
... | ... | |
$arr_ip[$i]['netmask'] = $subnet->netmask;
|
||
$i++;
|
||
}
|
||
}
|
||
|
||
$device_admin_model = new Device_admin_Model();
|
||
$query = $device_admin_model->select(array('device_admins.id as id', 'users.id as user_id', 'users.name', 'users.surname', 'users.login'))
|
||
->join('users','users.id = device_admins.user_id')
|
||
->orderby('id','ASC')
|
||
->find_all_by_device_id($device_id);
|
||
|
||
$grid = new Grid(url_lang::base().'devices', null, array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
}
|
||
|
||
$device_admin_model = new Device_admin_Model();
|
||
$query = $device_admin_model->select(array('device_admins.id as id', 'users.id as user_id', 'users.name', 'users.surname', 'users.login'))
|
||
->join('users','users.id = device_admins.user_id')
|
||
->orderby('id','ASC')
|
||
->find_all_by_device_id($device_id);
|
||
|
||
$grid = new Grid(url_lang::base().'devices', null, array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
$grid->add_new_button(url_lang::base().'device_admins/add', url_lang::lang('texts.Add new device admin'));
|
||
$grid->field('id')->label('ID')->class('center');
|
||
$grid->field('name')->label(url_lang::lang('texts.name'));
|
||
$grid->field('surname')->label(url_lang::lang('texts.surname'));
|
||
$grid->field('surname')->label(url_lang::lang('texts.surname'));
|
||
$grid->field('login')->label(url_lang::lang('texts.username'));
|
||
$grid->action_field('user_id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'users/show') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'device_admins/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
|
||
... | ... | |
$view->content = new View('show_device');
|
||
//$view->content->submenu = $submenu;
|
||
$view->content->headline = url_lang::lang('texts.Device detail').' - '.$device->name;
|
||
$view->content->device = $device;
|
||
$view->content->device = $device;
|
||
$view->content->device_type = $device_type;
|
||
$view->content->engineers = $arr_engineers;
|
||
$view->content->count_iface = $iface_model->count_ifaces_of_device($device->id);
|
||
$view->content->ifaces = $ifaces;
|
||
$view->content->ip_iface = $ip_iface;
|
||
$view->content->set('arr_ip',$arr_ip);
|
||
$view->content->set('arr_ip',$arr_ip);
|
||
$view->content->table_device_admins = $grid_device_admins;
|
||
$view->content->table_ifaces = $grid_ifaces;
|
||
$view->content->table_ports = $grid_ports;
|
||
... | ... | |
foreach ($users as $user) {
|
||
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
|
||
}
|
||
asort($arr_users);
|
||
asort($arr_users);
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::id_type_of_device);
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::id_type_of_device);
|
||
|
||
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required');
|
||
|
||
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[3,250]');
|
||
... | ... | |
{
|
||
$form_data = $form->as_array();
|
||
|
||
$device_model = new Device_Model();
|
||
$device_model = new Device_Model();
|
||
$device_engineer_model = new Device_engineer_Model();
|
||
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$device_model->$key = htmlspecialchars($value);
|
||
}
|
||
$device_model->engineer_id = $this->session->get('user_id');
|
||
//foreach($form_data as $key => $value)
|
||
//{
|
||
// $device_model->$key = htmlspecialchars($value);
|
||
//}
|
||
|
||
$device_model->user_id = htmlspecialchars($form_data["user_id"]);
|
||
$device_model->name = htmlspecialchars($form_data["name"]);
|
||
$device_model->type = htmlspecialchars($form_data["type"]);
|
||
// $device_model->description = htmlspecialchars($form_data["description"]);
|
||
$device_model->PPPoE_logging_in = htmlspecialchars($form_data["PPPoE_logging_in"]);
|
||
$device_model->login = htmlspecialchars($form_data["login"]);
|
||
$device_model->password = htmlspecialchars($form_data["password"]);
|
||
$device_model->GPS = htmlspecialchars($form_data["GPS"]);
|
||
$device_model->location_address = htmlspecialchars($form_data["location_address"]);
|
||
$device_model->location_details = htmlspecialchars($form_data["location_details"]);
|
||
$device_model->comment = htmlspecialchars($form_data["comment"]);
|
||
|
||
$device_saved = $device_model->save();
|
||
|
||
$device_engineer_model->device_id = $device_model->id;
|
||
$device_engineer_model->user_id = $this->session->get('user_id');
|
||
|
||
$device_engineer_saved = $device_engineer_model->save();
|
||
|
||
unset($form_data);
|
||
//$device_model->save()
|
||
if ($device_model->save()) {
|
||
if ($device_saved && $device_engineer_saved) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Device is successfully saved.'));
|
||
//url::redirect(url_lang::base().'devices/show_all');
|
||
url::redirect(url_lang::base().'devices/show/'.$device_model->id);
|
||
... | ... | |
foreach ($users as $user) {
|
||
$arr_users[$user->id] = $user->surname.' '.$user->name.' - '.$user->login;
|
||
}
|
||
asort($arr_users);
|
||
asort($arr_users);
|
||
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::id_type_of_device);
|
||
|
||
|
||
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::id_type_of_device);
|
||
|
||
|
||
$form->dropdown('user_id')->label(url_lang::lang('texts.user'))->options($arr_users)->rules('required')->selected($device->user_id);
|
||
|
||
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[3,250]')->value($device->name);
|
||
$form->input('name')->label(url_lang::lang('texts.Device name').':')->rules('required|length[3,250]')->value($device->name);
|
||
$form->dropdown('type')->label(url_lang::lang('texts.type'))->options($types)->rules('required')->selected($device->type);
|
||
$form->checkbox('PPPoE_logging_in')->label(url_lang::lang('texts.PPPoE'))->value('1')->checked($device->PPPoE_logging_in);
|
||
$form->input('login')->label(url_lang::lang('texts.username').':')->rules('length[0,250]')->value($device->login);
|
||
... | ... | |
//----- end EDIT --------------------------------------------------------------
|
||
//=============================================================================
|
||
}
|
||
?>
|
||
?>
|
Také k dispozici: Unified diff
Opravena chyba - pri pridani noveho zarizeni se neulozil novy radek do
tabulky device_engineers. Duvodem byla absence volani metody save().