Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1455

Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)

Upravy:
- upraven formular pro upravu zarizeni (#185)
- upraven pohled na zarizeni (#185)
- vylepsen prevod address pointu na retezec

Opravy:
- zrychleni skryvani skupiny formulare

Zobrazit rozdíly:

freenetis/branches/network/application/models/address_point.php
if (!$this->id)
return '';
return (
$this->country->country_name . ', ' .
$this->town->town . ($this->town->quarter ? ' - ' . $this->town->quarter : '') . ', ' .
$this->street->street . ', ' . $this->street_number
);
$str = '';
if ($this->name)
{
$str .= '„' . $this->name . '“, ';
}
if ($this->street_id && $this->street_number)
{
$str .= $this->street->street.' '.$this->street_number.', ';
}
else if ($this->street_id)
{
$str .= $this->street->street.', ';
}
else if ($this->street_number)
{
$str .= $this->street_number.', ';
}
$str .= $this->town->town;
$str .= ($this->town->quarter!='') ? '-'.$this->town->quarter.', ' : ', ';
$str .= $this->town->zip_code;
$str .= ', ' . $this->country->country_name;
return $str;
}
/**
freenetis/branches/network/application/controllers/devices.php
if (Settings::get('monitoring_enabled') && server::query_string() != '')
{
$grid->add_new_button('monitoring/action'.server::query_string(),
'Monitoring', array
(
'title' => __('Monitoring'),
'class' => 'popup_link'
)
);
$grid->add_new_button('monitoring/action'.server::query_string(), 'Monitoring', array
(
'title' => __('Monitoring'),
'class' => 'popup_link'
));
}
$grid->order_field('device_id')
......
Controller::error(ACCESS);
}
$enum_type_model = new Enum_type_Model();
$device_type = $enum_type_model->get_value($device->type);
$ifaces = $device->ifaces;
$i = 0;
$ip_ifaces = '';
$arr_ip = array();
foreach ($ifaces as $iface)
{
$ip_ifaces = $iface->ip_addresses;
foreach ($ip_ifaces as $ip)
{
$arr_ip[$i]['iface_id'] = $iface->id;
$arr_ip[$i]['ip_address'] = $ip->ip_address;
$arr_ip[$i]['name'] = $ip->subnet->name;
$arr_ip[$i]['network_address'] = $ip->subnet->network_address;
$arr_ip[$i++]['netmask'] = $ip->subnet->netmask;
}
}
$device_type = ORM::factory('enum_type')->get_value($device->type);
// device engineers
$device_engineer_model = new Device_engineer_Model();
$de = $device_engineer_model->get_device_engineers($device_id);
$de = ORM::factory('device_engineer')->get_device_engineers($device_id);
$grid_device_engineers = new Grid('devices', null, array
(
......
// iface grids
$grids = $this->create_device_grids($device);
$gps = "";
$gps = '';
if (!empty($device->address_point->gps))
{
......
$gps = gps::degrees($gps_result->gpsx, $gps_result->gpsy, true);
}
}
$sections = array
(
'interfaces' => __('Interfaces'),
'vlan_interfaces' => __('Vlan interfaces'),
'ip_addresses' => __('IP addresses'),
'ports' => __('Ports'),
'engineers' => __('Engineers'),
'admins' => __('Admins'),
);
$sec_links = array();
foreach ($sections as $anchor => $label)
{
$sec_links[] = html::anchor(url::base(TRUE).url::current(TRUE).'#'.$anchor, $label);
}
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
......
$view->content->device_type = $device_type;
$view->content->count_engineers = count($de);
$view->content->count_admins = count($da);
$view->content->ifaces = $ifaces;
$view->content->ip_iface = $ip_ifaces;
$view->content->ifaces = $device->ifaces;
$view->content->table_device_engineers = $grid_device_engineers;
$view->content->table_device_admins = $grid_device_admins;
$view->content->table_ip_addresses = $grids['ip_addresses'];
......
$view->content->gpsx = !empty($gps) ? $gps_result->gpsx : '';
$view->content->gpsy = !empty($gps) ? $gps_result->gpsy : '';
$view->content->lang = Config::get('lang');
$view->content->sec_links = implode(' | ', $sec_links);
$view->render(TRUE);
} // end of show
......
if (isset($user_id))
{
$user_model = new User_Model($user_id);
$um = new User_Model($user_id);
if (!$user_model->id)
if (!$um->id)
{
Controller::error(RECORD);
}
$selected = $user_model->id;
$selected_country_id = $user_model->member->address_point->country_id;
$selected_street_id = $user_model->member->address_point->street_id;
$selected_street_number = $user_model->member->address_point->street_number;
$selected_town_id = $user_model->member->address_point->town_id;
$gps = $user_model->member->address_point->get_gps_coordinates();
$selected = $um->id;
$selected_country_id = $um->member->address_point->country_id;
$selected_street_id = $um->member->address_point->street_id;
$selected_street_number = $um->member->address_point->street_number;
$selected_town_id = $um->member->address_point->town_id;
$gps = $um->member->address_point->get_gps_coordinates();
if ($gps)
{
......
$gpsy = gps::real2degrees($gps->gpsy, FALSE);
}
$found_engineer = ORM::factory('device_engineer')->get_engineer_of_user($user_model->id);
$found_engineer = ORM::factory('device_engineer')->get_engineer_of_user($um->id);
if ($found_engineer)
{
$selected_engineer = $found_engineer->id;
}
$arr_users[$user_model->id] = $user_model->get_name_with_login();
$arr_users[$um->id] = $um->get_name_with_login();
}
else
{
$user_model = new User_Model();
$um = new User_Model();
$selected = 0;
$selected_country_id = Settings::get('default_country');
$selected_street_id = 0;
......
$arr_users = array
(
NULL => '----- '.__('select user').' -----'
) + $user_model->select_list_grouped();
) + $um->select_list_grouped();
}
// enum types for device
......
);
// wireless modes
$wirelessmodes = array
$arr_wireless_modes = array
(
NULL => '----- '.__('Select mode').' -----'
) + Iface_Model::get_wireless_modes();
// wireless antenna types
$wirelessantennas = array
$arr_wireless_antennas = array
(
NULL => '----- '.__('Select antenna').' -----'
) + Iface_Model::get_wireless_antennas();
// all device templates
$device_templates = array
$arr_device_templates = array
(
NULL => '----- '.__('Select template').' -----'
) + ORM::factory('device_template')->select_list();
......
) + ORM::factory('town')->select_list_with_quater();
// wireless norms
$wirelessnorms = Link_Model::get_wireless_norms();
$arr_wireless_norms = Link_Model::get_wireless_norms();
// wireless polarizations
$wirelesspolarizations = Link_Model::get_wireless_polarizations();
$arr_wireless_polarizations = Link_Model::get_wireless_polarizations();
// ports
$port_modes = array
......
// list of engineers
if ($this->acl_check_edit('Devices_Controller', 'main_engineer'))
{
$arr_engineers = $user_model->select_list_grouped();
$arr_engineers = $um->select_list_grouped();
}
else
{
......
$group_device = $form->group('Device');
// name is not required, it is useful to name routers, access points, etc. only
$group_device->input('device_name')
->label('Device name')
->value(($user_id) ? $user_model->surname : '')
->value(($user_id) ? $um->surname : '')
->rules('required|length[2,200]')
->style('width: 520px');
......
->style('width: 250px');
$group_device->dropdown('device_template_id')
->options($device_templates)
->options($arr_device_templates)
->label('Device template')
->rules('required')
->style('width: 250px')
......
if (!empty($user_id))
{
$group_address->visible(!$user_model->id);
$group_address->visible(!$um->id);
}
$group_address->dropdown('town_id')
......
if (!isset($user_id))
{
$user_model = new User_Model($dm->user_id);
$um = new User_Model($dm->user_id);
}
if (empty($form_data['device_name']))
{
$dm->name = $user_model->login.'_'.$types[$form_data['device_type']];
$dm->name = $um->login.'_'.$types[$form_data['device_type']];
}
else
{
......
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller', 'members'))
->disable_translation()
->link('members/show/' . $user_model->member->id,
'ID ' . $user_model->member->id . ' - ' . $user_model->member->name,
$this->acl_check_view('Members_Controller', 'members', $user_model->member->id))
->link('members/show/' . $um->member->id,
'ID ' . $um->member->id . ' - ' . $um->member->name,
$this->acl_check_view('Members_Controller', 'members', $um->member->id))
->enable_translation()
->link('users/show_by_member/' . $user_model->member_id, 'Users',
$this->acl_check_view('Users_Controller', 'users', $user_model->member_id))
->link('users/show_by_member/' . $um->member_id, 'Users',
$this->acl_check_view('Users_Controller', 'users', $um->member_id))
->disable_translation()
->link('users/show/' . $user_model->id,
$user_model->name . ' ' . $user_model->surname . ' (' . $user_model->login . ')',
$this->acl_check_view('Users_Controller', 'users', $user_model->member_id))
->link('users/show/' . $um->id,
$um->name . ' ' . $um->surname . ' (' . $um->login . ')',
$this->acl_check_view('Users_Controller', 'users', $um->member_id))
->enable_translation()
->link('devices/show_by_user/' . $user_model->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $user_model->member_id))
->link('devices/show_by_user/' . $um->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $um->member_id))
->text('Add new whole device');
}
else
......
$view->content->headline = __('Add new whole device');
$view->content->yes_no_option = $yes_no_option;
$view->content->port_modes = $port_modes;
$view->content->wireless_modes = $wirelessmodes;
$view->content->wireless_antennas = $wirelessantennas;
$view->content->norms = $wirelessnorms;
$view->content->polarizations = $wirelesspolarizations;
$view->content->wireless_modes = $arr_wireless_modes;
$view->content->wireless_antennas = $arr_wireless_antennas;
$view->content->norms = $arr_wireless_norms;
$view->content->polarizations = $arr_wireless_polarizations;
$view->content->bit_units = $arr_unit;
$view->content->eth_mediums = $eth_mediums;
$view->content->wl_mediums = $wl_mediums;
......
public function edit($device_id = null)
{
if (!isset($device_id) || !is_numeric($device_id))
{
Controller::warning(PARAMETER);
}
$device = new Device_Model($device_id);
if ($device->id == 0)
{
Controller::error(RECORD);
}
if (!$this->acl_check_edit(get_class($this), 'devices', $device->user->member_id))
$member_id = $device->user->member_id;
if (!$this->acl_check_edit(get_class($this), 'devices', $member_id))
{
Controller::error(ACCESS);
}
// gps
$gpsx = "";
$gpsy = "";
$gpsx = '';
$gpsy = '';
if (!empty($device->address_point->gps))
{
$gps_result = $device->address_point->get_gps_coordinates($device->address_point->id);
$gps_result = $device->address_point->get_gps_coordinates();
if (!empty($gps_result))
{
......
}
// users
$user_model = new User_Model;
$arr_users = $user_model->select_list_grouped();
$arr_users = ORM::factory('user')->select_list_grouped();
// types
$enum_type_model = new Enum_type_Model();
$types = $enum_type_model->get_values(Enum_type_Model::DEVICE_TYPE_ID);
$arr_types = ORM::factory('enum_type')->get_values(Enum_type_Model::DEVICE_TYPE_ID);
// country
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
......
) + $device->address_point->town->streets->select_list('id', 'street');
// towns
$town_model = new Town_Model();
$arr_towns = array
(
NULL => '----- '.__('select town').' -----'
) + $town_model->select_list_with_quater();
) + ORM::factory('town')->select_list_with_quater();
$form = new Forge('devices/edit/'.$device_id);
$yes_no_option = array(0 => __('no'), 1 => __('yes'));
$form->group('Basic data');
// form
$form = new Forge('devices/edit/' . $device_id);
$form->dropdown('user_id')
$group_device = $form->group('Basic data');
$group_device->input('device_name')
->label('Device name')
->rules('length[2,200]')
->value($device->name)
->style('width: 520px');
$group_device->dropdown('user_id')
->label('User')
->options($arr_users)
->rules('required')
->selected($device->user_id);
->selected($device->user_id)
->style('width: 250px');
$form->input('name')
->label('Device name')
->rules('length[1,200]')
->value($device->name)
->style('width: 500px');
$form->dropdown('type')
$group_device->dropdown('type')
->label('Type')
->options($types)
->options($arr_types)
->rules('required')
->selected($device->type);
->selected($device->type)
->style('width: 250px');
$form->checkbox('PPPoE_logging_in')
$group_device_details = $form->group('Device detail');
$group_device_details->input('trade_name')
->label('Trade name')
->rules('length[1,200]')
->value($device->trade_name)
->style('width: 520px');
$group_device_details->dropdown('PPPoE_logging_in')
->label('PPPoE')
->value('1')
->checked($device->PPPoE_logging_in);
->options($yes_no_option)
->selected($device->PPPoE_logging_in);
if ($this->acl_check_edit(get_class($this),'login'))
if ($this->acl_check_edit(get_class($this), 'login'))
{
$form->input('login')
$group_device_details->input('login')
->label('Username')
->rules('length[0,30]')
->value($device->login)
->autocomplete('json/device_login');
->autocomplete('json/device_login')
->style('width: 250px');
}
if ($this->acl_check_edit(get_class($this),'password'))
if ($this->acl_check_edit(get_class($this), 'password'))
{
$form->input('login_password')
$group_device_details->input('login_password')
->label('Password')
->rules('length[0,30]')
->value($device->password)
->autocomplete('json/device_password');
->autocomplete('json/device_password')
->style('width: 250px');
}
$form->textarea('comment')
$group_device_details->textarea('comment')
->rules('length[0,254]')
->value($device->comment);
->value($device->comment)
->style('width: 520px');
$form->group('Device repayments');
$group_payment = $form->group('Device repayments')->visible($device->price > 0);
$form->input('price')
$group_payment->input('price')
->rules('valid_numeric')
->value($device->price);
->value($device->price ? $device->price : '')
->style('width: 250px');
$form->input('payment_rate')
$group_payment->input('payment_rate')
->label('Monthly payment rate')
->rules('valid_numeric')
->value($device->payment_rate);
->value($device->payment_rate ? $device->payment_rate : '')
->style('width: 250px');
$form->date('buy_date')
$group_payment->date('buy_date')
->label('Buy date')
->years(date('Y')-100, date('Y'))
->value(strtotime($device->buy_date));
$form->group('Address');
$group_address = $form->group('Address');
$form->dropdown('town_id')
$group_address->dropdown('town_id')
->label('Town')
->rules('required')
->options($arr_towns)
->selected($device->address_point->town_id)
->add_button('towns');
->add_button('towns')
->style('width: 250px');
$form->dropdown('street_id')
$group_address->dropdown('street_id')
->label('Street')
->options($arr_streets)
->selected($device->address_point->street_id)
->add_button('streets');
->add_button('streets')
->style('width: 250px');
$form->input('street_number')
$group_address->input('street_number')
->rules('length[1,50]')
->value($device->address_point->street_number);
->value($device->address_point->street_number)
->style('width: 250px');
$form->dropdown('country_id')
$group_address->dropdown('country_id')
->label('country')
->rules('required')
->options($arr_countries)
->selected($device->address_point->country_id);
->selected($device->address_point->country_id)
->style('width: 250px');
$form->input('gpsx')
$group_address->input('gpsx')
->label(__('GPS').' X: '.help::hint('gps_coordinates'))
->value($gpsx)
->rules('gps');
->rules('gps')
->style('width: 250px');
$form->input('gpsy')
$group_address->input('gpsy')
->label(__('GPS').' Y: '.help::hint('gps_coordinates'))
->value($gpsy)
->rules('gps');
->rules('gps')
->style('width: 250px');
$form->submit('Edit');
special::required_forge_style($form, ' *', 'required');
// validation
if($form->validate())
{
$form_data = $form->as_array();
// saves device changes
$device = new Device_Model($device_id);
// gps
$gpsx = NULL;
$gpsy = NULL;
if (!empty($form_data['gpsx']) && !empty($form_data['gpsy']))
try
{
$gpsx = doubleval($form_data["gpsx"]);
$gpsy = doubleval($form_data["gpsy"]);
$device->transaction_start();
// gps
$gpsx = NULL;
$gpsy = NULL;
if (gps::is_valid_degrees_coordinate($form->gpsx->value))
if (!empty($form_data['gpsx']) && !empty($form_data['gpsy']))
{
$gpsx = gps::degrees2real($form->gpsx->value);
$gpsx = doubleval($form_data['gpsx']);
$gpsy = doubleval($form_data['gpsy']);
if (gps::is_valid_degrees_coordinate($form_data['gpsx']))
{
$gpsx = gps::degrees2real($form_data['gpsx']);
}
if (gps::is_valid_degrees_coordinate($form_data['gpsy']))
{
$gpsy = gps::degrees2real($form_data['gpsy']);
}
}
if (gps::is_valid_degrees_coordinate($form->gpsy->value))
$old_user_id = $device->user_id;
$device->user_id = $form_data['user_id'];
$device->name = $form_data['device_name'];
$device->type = $form_data['type'];
$device->trade_name = $form_data['trade_name'];
$device->PPPoE_logging_in = $form_data['PPPoE_logging_in'];
if ($this->acl_check_new(get_class($this), 'login'))
{
$gpsy = gps::degrees2real($form->gpsy->value);
$device->login = $form_data['login'];
}
}
$old_user_id = $device->user_id;
$device->user_id = $form_data["user_id"];
$device->name = $form_data["name"];
$device->type = $form_data["type"];
$device->trade_name = $form_data["trade_name"];
$device->PPPoE_logging_in = $form_data["PPPoE_logging_in"];
if ($this->acl_check_new(get_class($this),'login'))
{
$device->login = $form_data["login"];
}
if ($this->acl_check_new(get_class($this),'password'))
{
$device->password = $form_data["login_password"];
}
$device->comment = $form_data["comment"];
$device->price = $form_data["price"];
$device->payment_rate = $form_data["payment_rate"];
$device->buy_date = date('Y-m-d', $form_data["buy_date"]);
$ap = ORM::factory('address_point')->get_address_point(
$form_data["country_id"], $form_data["town_id"],
$form_data["street_id"], $form_data["street_number"],
$gpsx, $gpsy
);
$device_saved = $device->save();
if ($this->acl_check_new(get_class($this), 'password'))
{
$device->password = $form_data['login_password'];
}
// add address point if there is no such
if (!$ap->id)
{
// save
$ap->save();
}
// new addresspoint
if ($ap->id != $device->address_point_id)
{
// delete old?
$addr_id = $device->address_point->id;
// add to device
$device->address_point_id = $ap->id;
$device_saved = $device->save();
// change just for this device?
if ($ap->count_all_items_by_address_point_id($addr_id) < 1)
$device->comment = $form_data['comment'];
$device->price = $form_data['price'];
$device->payment_rate = $form_data['payment_rate'];
$device->buy_date = date('Y-m-d', $form_data['buy_date']);
$ap = ORM::factory('address_point')->get_address_point(
$form_data['country_id'], $form_data['town_id'],
$form_data['street_id'], $form_data['street_number'],
$gpsx, $gpsy
);
$device->save_throwable();
// add address point if there is no such
if (!$ap->id)
{
$addr = new Address_point_Model($addr_id);
$addr->delete();
// save
$ap->save_throwable();
}
}
// add GPS
if (!empty($gpsx) && !empty($gpsy))
{ // save
$ap->update_gps_coordinates($ap->id, $gpsx, $gpsy);
}
else
{ // delete gps
$ap->gps = '';
$ap->save();
}
if ($old_user_id != $device->user_id)
{
$old_user = new User_Model($old_user_id);
$ip_address_model = new Ip_address_Model();
$ip_addresses = $ip_address_model->get_ip_addresses_of_device($device_id);
foreach ($ip_addresses as $ip_address)
// new addresspoint
if ($ap->id != $device->address_point_id)
{
// ip address was the only one of this member
// from this subnet -> deletes subnet from allowed subnets of member
if (!$ip_address_model->count_all_ip_addresses_by_member_and_subnet(
$old_user->member_id, $ip_address->subnet_id))
// delete old?
$addr_id = $device->address_point->id;
// add to device
$device->address_point_id = $ap->id;
$device->save_throwable();
// change just for this device?
if ($ap->count_all_items_by_address_point_id($addr_id) < 1)
{
$addr = new Address_point_Model($addr_id);
$addr->delete();
}
}
// add GPS
if (!empty($gpsx) && !empty($gpsy))
{ // save
$ap->update_gps_coordinates($ap->id, $gpsx, $gpsy);
}
else
{ // delete gps
$ap->gps = '';
$ap->save_throwable();
}
if ($old_user_id != $device->user_id)
{
$old_user = new User_Model($old_user_id);
$ip_address_model = new Ip_address_Model();
$ip_addresses = $ip_address_model->get_ip_addresses_of_device($device_id);
foreach ($ip_addresses as $ip_address)
{
// ip address was the only one of this member
// from this subnet -> deletes subnet from allowed subnets of member
if (!$ip_address_model->count_all_ip_addresses_by_member_and_subnet(
$old_user->member_id, $ip_address->subnet_id
))
{
Allowed_subnets_Controller::update_enabled(
$old_user->member_id, NULL, NULL, array($ip_address->subnet_id)
);
}
Allowed_subnets_Controller::update_enabled(
$old_user->member_id, NULL, NULL, array($ip_address->subnet_id)
$device->user->member_id, array($ip_address->subnet_id)
);
}
Allowed_subnets_Controller::update_enabled(
$device->user->member_id, array($ip_address->subnet_id)
);
}
unset($form_data);
$device->transaction_commit();
status::success('Device has been successfully updated.');
url::redirect(Path::instance()->previous());
}
unset($form_data);
if ($device_saved)
catch (Exception $e)
{
status::success('Device has been successfully updated.');
url::redirect(Path::instance()->previous());
$device->transaction_rollback();
status::error('Device has not been updated.');
}
} // end of validation
......
else
{
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller', 'members'))
->disable_translation()
->link('members/show/' . $device->user->member->id,
'ID ' . $device->user->member->id . ' - ' . $device->user->member->name,
$this->acl_check_view('Members_Controller', 'members', $device->user->member->id))
->enable_translation()
->link('users/show_by_member/' . $device->user->member_id, 'Users',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->disable_translation()
->link('users/show/' . $device->user->id,
$device->user->name . ' ' . $device->user->surname . ' (' . $device->user->login . ')',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->enable_translation()
->link('devices/show_by_user/' . $device->user->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $device->user->member_id))
->disable_translation()
->link('devices/show/' . $device->id . '#device_' . $device_id . '_link',
$device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $device->user->member_id))
->enable_translation()
->text('Export of device');
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view('Members_Controller', 'members'))
->disable_translation()
->link('members/show/' . $device->user->member->id,
'ID ' . $device->user->member->id . ' - ' . $device->user->member->name,
$this->acl_check_view('Members_Controller', 'members', $device->user->member->id))
->enable_translation()
->link('users/show_by_member/' . $device->user->member_id, 'Users',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->disable_translation()
->link('users/show/' . $device->user->id,
$device->user->name . ' ' . $device->user->surname . ' (' . $device->user->login . ')',
$this->acl_check_view('Users_Controller', 'users', $device->user->member_id))
->enable_translation()
->link('devices/show_by_user/' . $device->user->id, 'Devices',
$this->acl_check_view('Devices_Controller', 'devices', $device->user->member_id))
->disable_translation()
->link('devices/show/' . $device->id . '#device_' . $device_id . '_link',
$device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $device->user->member_id))
->enable_translation()
->text('Export of device');
$view = new View('main');
$view->breadcrumbs = $breadcrumbs->html();
......
->link('devices/show_all/', 'Devices',
$this->acl_check_view('Devices_Controller', 'devices'))
->disable_translation()
->link('devices/show/' . $device_id,
$device->name,
->link('devices/show/' . $device_id, $device->name,
$this->acl_check_edit('Devices_Controller', 'devices', $device->user->member_id))
->enable_translation()
->text('Map');
......
$children = array();
foreach ($dependent_devices as $dependent_device_id => $dependent_device_name)
{
$child = $this->_dependent_device($dependent_device_id,$depth-1);
$child = $this->_dependent_device($dependent_device_id, $depth-1);
array_push($children, $child);
}
freenetis/branches/network/application/libraries/Path.php
* This is library for path = history of urls
* It works as iterarator
*
* @author Michal Kliment
* @author Michal Kliment, David Raška
* @version 1.0
*/
class Path
freenetis/branches/network/application/libraries/Forge.php
foreach(array_merge($object->hidden, $object->inputs) as $input)
{
if ($input->inputs)
$this->load_inputs ($input);
{
$this->load_inputs($input);
}
if ($name = $input->name)
{
$name = str_replace('[]','', $name);
freenetis/branches/network/application/views/devices/show.php
<h2><?php echo __('Device'). ' '.$device->name ?></h2>
<h2><?php echo __('Device') ?> <?php echo $device->name ?></h2>
<br />
<?php
$links = array();
if ($this->acl_check_edit(get_class($this), 'devices'))
$links[] = html::anchor('devices/edit/'.$device->id, __('Edit'));
......
if (Settings::get('monitoring_enabled'))
{
$links[] = html::anchor(
'monitoring/action/'.$device->id, __('Monitoring'),
array
(
'title' => __('Monitoring'),
'class' => 'popup_link'
)
);
$links[] = html::anchor('monitoring/action/'.$device->id, __('Monitoring'), array
(
'title' => __('Monitoring'),
'class' => 'popup_link'
));
}
echo implode(' | ', $links)
......
<table class="extended" cellspacing="0" style="float:left; width: 400px; word-wrap: break-word;">
<tr>
<th><?php echo __('Device ID') ?></th>
<td><?php echo $device->id ?></td>
<th><?php echo __('Device ID') ?></th>
<td><?php echo $device->id ?></td>
</tr>
<tr>
<th><?php echo __('Member') ?></th>
<td><?php echo html::anchor('members/show/'.$device->user->member_id, $device->user->member->name.' ('.$device->user->member_id.')'); ?></td>
<th><?php echo __('Member') ?></th>
<td><?php echo html::anchor('members/show/'.$device->user->member_id, $device->user->member->name.' ('.$device->user->member_id.')'); ?></td>
</tr>
<tr>
<th><?php echo __('User') ?></th>
<td><?php echo html::anchor('users/show/'.$device->user_id,$device->user->name.' '.$device->user->surname); ?></td>
<th><?php echo __('User') ?></th>
<td><?php echo html::anchor('users/show/'.$device->user_id, $device->user->get_full_name()); ?></td>
</tr>
<tr>
<th><?php echo __('Trade name') ?></th>
<td><?php echo $device->trade_name ?></td>
<th><?php echo __('Trade name') ?></th>
<td><?php echo $device->trade_name ?></td>
</tr>
<tr>
<th><?php echo __('Type') ?></th>
<td><?php echo $device_type ?></td>
<th><?php echo __('Type') ?></th>
<td><?php echo $device_type ?></td>
</tr>
<?php if ($this->acl_check_view(get_class($this),'login')): ?>
<?php if ($this->acl_check_view(get_class($this), 'login')): ?>
<tr>
<th><?php echo __('Login name') ?></th>
<td><?php echo $device->login ?></td>
<th><?php echo __('Login name') ?></th>
<td><?php echo $device->login ?></td>
</tr>
<?php endif ?>
<?php if ($this->acl_check_view(get_class($this),'password')): ?>
<?php if ($this->acl_check_view(get_class($this), 'password')): ?>
<tr>
<th><?php echo __('Password') ?></th>
<td><?php echo $device->password ?></td>
<th><?php echo __('Password') ?></th>
<td><?php echo $device->password ?></td>
</tr>
<?php endif ?>
<?php if ($device->price) { ?>
<?php if ($device->price): ?>
<tr>
<th><?php echo __('Price') ?></th>
<td><?php echo $device->price ?></td>
<th><?php echo __('Price') ?></th>
<td><?php echo $device->price ?></td>
</tr>
<tr>
<th><?php echo __('Monthly payment rate') ?></th>
<td><?php echo $device->payment_rate ?></td>
<th><?php echo __('Monthly payment rate') ?></th>
<td><?php echo $device->payment_rate ?></td>
</tr>
<?php }
if ($device->buy_date != '' && $device->buy_date != '1970-01-01') { ?>
<?php endif; ?>
<?php if ($device->buy_date != '' && $device->buy_date != '1970-01-01'): ?>
<tr>
<th><?php echo __('Buy date') ?></th>
<td><?php echo $device->buy_date ?></td>
<th><?php echo __('Buy date') ?></th>
<td><?php echo $device->buy_date ?></td>
</tr>
<?php } ?>
<?php endif; ?>
<tr>
<th><?php echo __('Location address') ?></th>
<th><?php echo __('Location address') ?></th>
<td>
<a href="<?php echo url_lang::base() ?>address_points/show/<?php echo $device->address_point->id ?>">
<?php
if ($device->address_point->name)
echo '&bdquo;' . $device->address_point->name . '&ldquo;, ';
if ($device->address_point->street_id && $device->address_point->street_number)
echo $device->address_point->street->street.' '.$device->address_point->street_number.', ';
else if ($device->address_point->street_id)
echo $device->address_point->street->street.', ';
else if ($device->address_point->street_number)
echo $device->address_point->street_number.', ';
echo $device->address_point->town->town;
echo ($device->address_point->town->quarter!='') ? '-'.$device->address_point->town->quarter.', ' : ', ';
echo $device->address_point->town->zip_code;
echo ', ' . $device->address_point->country->country_name;
?>
</a>
<a href="<?php echo url_lang::base() ?>address_points/show/<?php echo $device->address_point->id ?>"><?php echo $device->address_point; ?></a>
</td>
</tr>
<?php if ($gps != ''): ?>
<tr>
<th><?php echo __('GPS') ?></th>
<td><?php echo $gps ?></td>
<th><?php echo __('GPS') ?></th>
<td><?php echo $gps ?></td>
</tr>
<?php endif ?>
<tr>
<th><?php echo __('Comment') ?></th>
<td><?php echo $device->comment ?></td>
<th><?php echo __('Comment') ?></th>
<td><?php echo $device->comment ?></td>
</tr>
</table>
......
</ul>
<!-- interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="interfaces">
<?php echo $ifaces ?>
</div>
<?php } ?>
<!-- internal interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="internal_interfaces">
<?php echo $internal_ifaces ?>
</div>
<?php } ?>
<!-- ethernet interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="ethernet_interfaces">
<?php echo $ethernet_ifaces ?>
</div>
<?php } ?>
<!-- wireless interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="wireless_interfaces">
<?php echo $wireless_ifaces ?>
</div>
<?php } ?>
<!-- vlan interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="vlan_interfaces">
<?php echo $vlan_ifaces ?>
</div>
<?php } ?>
<!-- bridge interfaces -->
<?php if ($this->acl_check_view(get_class($this),'iface',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'iface', $device->user->member_id)) { ?>
<div id="bridge_interfaces">
<?php echo $bridge_ifaces ?>
</div>
<?php } ?>
<!-- ports -->
<?php if ($this->acl_check_view(get_class($this),'port',$device->user->member_id)) { ?>
<?php if ($this->acl_check_view(get_class($this), 'port', $device->user->member_id)) { ?>
<div id="ports">
<?php echo $port_ifaces ?>
</div>
......
<br />
<!-- ip addresses -->
<?php if ($this->acl_check_view(get_class($this),'ip_address',$device->user->member_id)) { ?>
<h3><a id="device_ip_addresses_link" name="ip_addresses"><?php echo __('IP addresses') ?>
<?php if ($this->acl_check_view(get_class($this), 'ip_address', $device->user->member_id)) { ?>
<h3><a id="device_ip_addresses_link" name="ip_addresses"><?php echo __('IP addresses') ?>
<img src="<?php echo url::base() ?>media/images/icons/ico_<?php echo (!$table_ip_addresses) ? 'add' : 'minus' ?>.gif" id="device_ip_addresses_button"></a></h3>
<div id="device_ip_addresses" class="<?php echo (!$table_ip_addresses) ? 'dispNone' : '' ?>">
<?php echo $table_ip_addresses ?><br />
<?php echo $table_ip_addresses ?><br />
</div><br />
<?php } ?>
......
<!-- device engineers -->
<div style="float:left; width: 50%">
<?php //if ($this->acl_check_view(get_class($this),'engineer',$device->user->member_id)) { ?>
<h3><a id="device_engineers_link" name="engineers"><?php echo __('Device engineers') ?>
<h3><a id="device_engineers_link" name="engineers"><?php echo __('Device engineers') ?>
<img src="<?php echo url::base() ?>media/images/icons/ico_<?php echo ($count_engineers == 0) ? 'add' : 'minus' ?>.gif" id="device_engineers_button"></h3></a>
<div id="device_engineers" class="<?php echo ($count_engineers == 0) ? 'dispNone' : '' ?>">
<?php echo $table_device_engineers ?>
<?php echo $table_device_engineers ?>
</div>
<?php //} ?>
</div>
<!-- device admins -->
<div style="float:left; margin-left:0px;">
<?php if ($this->acl_check_view(get_class($this),'admin',$device->user->member_id)) { ?>
<h3><a id="device_admins_link" name="admins"><?php echo __('Device admins') ?>
<?php if ($this->acl_check_view(get_class($this), 'admin', $device->user->member_id)) { ?>
<h3><a id="device_admins_link" name="admins"><?php echo __('Device admins') ?>
<img src="<?php echo url::base() ?>media/images/icons/ico_<?php echo ($count_admins == 0) ? 'add' : 'minus' ?>.gif" id="device_admins_button"></h3></a>
<div id="device_admins" class="<?php echo ($count_admins == 0) ? 'dispNone' : '' ?>">
<?php echo $table_device_admins ?>
<?php echo $table_device_admins ?>
</div>
<?php } ?>
</div>
freenetis/branches/network/application/views/js/devices_add.php
}
}
/**
* After confirming of first step of form, some fields must not be editable
* in second step. This function replace these fields by text elements
* and values of form stores in hidden fields with same names as previous
* fields.
*/
function disable_solid_fields()
{
var fields = [
'device_type', 'user_id', 'device_template_id', 'town_id',
'street_id', 'street_number', 'country_id', 'gpsx', 'gpsy'
];
for (var i in fields)
{
var $el = $('#' + fields[i]);
var text = $el.val();
if ($el[0].nodeName == 'SELECT')
{
text = $el.find('option:selected').text();
}
var $input = $('<input>', {
type: 'hidden',
name: $el.attr('name'),
value: $el.val()
})
$el.after($('<b>').text(text)).after($input).remove();
$input.attr('id', fields[i]);
}
}
/// triggers code //////////////////////////////////////////////////////////
// hide all
......
return false;
}
// disable previous fields
$this.find('input').attr('readonly', true);
$this.find('select').attr('disabled', true);
disable_solid_fields();
// remove add buttons
$this.find('a.popup_link').remove();
// loader
......
{
if ($(this).validate().form())
{
// enable previously disabled fields
$this.find('input').removeAttr('readonly');
$this.find('select').removeAttr('disabled');
// send form
return true;
}
freenetis/branches/network/application/views/js/base.php
// functionality of hiding/showing form group
$('.group-button').live('click', function ()
{
var items = '.' + $(this).parent().parent().attr('id') + '-items';
var $items = $('.' + $(this).parent().parent().attr('id') + '-items');
var img = 'add';
var title = '<?php echo __('Show form items') ?>';
if ($(items).is(':visible'))
if ($items.length && $($items.get(0)).is(':visible'))
{
$(items).hide();
var img = 'add';
var title = '<?php echo __('Show form items') ?>';
$items.hide();
}
else
{
$(items).show();
var img = 'minus';
var title = '<?php echo __('Hide form items') ?>';
$items.show();
img = 'minus';
title = '<?php echo __('Hide form items') ?>';
}
$(this).attr('src', '<?php echo url::base() ?>media/images/icons/ico_'+img+'.gif');
freenetis/branches/network/application/views/js/devices_map.php
<?php
/**
* Devices show javascript view.
* Devices map show javascript view.
*
* @author Michal Kliment, Ondřej Fibich
* @author David Raška
*/
// IDE complementation

Také k dispozici: Unified diff