Revize 1576
Přidáno uživatelem David Raška před více než 12 roky(ů)
freenetis/branches/testing/media/css/style.css | ||
---|---|---|
}
|
||
|
||
.rbg {
|
||
background-color: red;
|
||
background-color: #FF5C00;
|
||
color: white;
|
||
}
|
||
|
freenetis/branches/testing/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'add comment to financial state of member' => 'Přidat komentář k finančnímu stavu člena',
|
||
'add comment to work' => 'Přidat komentář k práci',
|
||
'add contact' => 'Přidat kontakt',
|
||
'add device' => 'Přidat zařízení',
|
||
'add device template' => 'Přidat šablonu zařízení',
|
||
'add details to ip address' => 'Přidat detaily k IP adrese',
|
||
'add details to interface' => 'Přidat detaily k rozhraní',
|
freenetis/branches/testing/application/controllers/ifaces.php | ||
---|---|---|
$c_form = $form->group('Link');
|
||
|
||
$c_form->dropdown('connected_to')
|
||
->style('width: 620px')
|
||
->options($devices);
|
||
->style('width: 600px')
|
||
->options($devices)
|
||
->add_button('devices', 'add_simple', $device->user_id);
|
||
|
||
$c_form->dropdown('connected_to_interface')
|
||
->style('width: 600px')
|
||
... | ... | |
$headline = __('Add new interface');
|
||
$view = new View('main');
|
||
$view->breadcrumbs = $breadcrumbs;
|
||
$view->title = $headline;
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->headline = $headline;
|
freenetis/branches/testing/application/controllers/links.php | ||
---|---|---|
|
||
status::success('Link has been successfully saved.');
|
||
|
||
$this->redirect('show', $link_model->id);
|
||
$this->redirect('links/show/', $link_model->id);
|
||
}
|
||
else
|
||
{
|
freenetis/branches/testing/application/controllers/devices.php | ||
---|---|---|
$view->render(TRUE);
|
||
} // end of function add
|
||
|
||
/**
|
||
* Function adds simple device without any interfaces, IP addresses ...
|
||
*
|
||
* @author David Raška
|
||
* @param int $user_id
|
||
*/
|
||
public function add_simple($user_id = null)
|
||
{
|
||
if (!$this->acl_check_new(get_class($this), 'devices'))
|
||
{
|
||
Controller::error(ACCESS);
|
||
}
|
||
|
||
$selected_engineer = $this->session->get('user_id');
|
||
|
||
$gpsx = '';
|
||
$gpsy = '';
|
||
|
||
if (isset($user_id))
|
||
{
|
||
$um = new User_Model($user_id);
|
||
|
||
if (!$um->id)
|
||
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
$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)
|
||
{
|
||
$gpsx = gps::real2degrees($gps->gpsx, FALSE);
|
||
$gpsy = gps::real2degrees($gps->gpsy, FALSE);
|
||
}
|
||
|
||
$found_engineer = ORM::factory('device_engineer')->get_engineer_of_user($um->id);
|
||
|
||
if ($found_engineer)
|
||
{
|
||
$selected_engineer = $found_engineer->id;
|
||
}
|
||
|
||
$arr_users[$um->id] = $um->get_name_with_login();
|
||
}
|
||
else
|
||
{
|
||
$um = new User_Model();
|
||
$selected = 0;
|
||
$selected_country_id = Settings::get('default_country');
|
||
$selected_street_id = 0;
|
||
$selected_street_number = '';
|
||
$selected_town_id = 0;
|
||
|
||
$arr_users = array
|
||
(
|
||
NULL => '----- '.__('select user').' -----'
|
||
) + $um->select_list_grouped();
|
||
}
|
||
|
||
// enum types for device
|
||
$enum_type_model = new Enum_type_Model();
|
||
$types = $enum_type_model->get_values(Enum_type_Model::DEVICE_TYPE_ID);
|
||
$types[NULL] = '----- '.__('select type').' -----';
|
||
asort($types);
|
||
|
||
// country
|
||
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
|
||
|
||
// streets
|
||
$arr_streets = array
|
||
(
|
||
NULL => '----- '.__('without street').' -----'
|
||
) + ORM::factory('street')->select_list('id', 'street');
|
||
|
||
// towns
|
||
$arr_towns = array
|
||
(
|
||
NULL => '----- '.__('select town').' -----'
|
||
) + ORM::factory('town')->select_list_with_quater();
|
||
|
||
// list of engineers
|
||
if ($this->acl_check_edit('Devices_Controller', 'main_engineer'))
|
||
{
|
||
$arr_engineers = $um->select_list_grouped();
|
||
}
|
||
else
|
||
{
|
||
$engineer = new User_Model($this->session->get('user_id'));
|
||
$arr_engineers[$engineer->id] = $engineer->get_full_name_with_login();
|
||
}
|
||
|
||
// forge form
|
||
$form = new Forge('devices/add_simple');
|
||
|
||
$form->set_attr('id', 'device_add_form');
|
||
|
||
$group_device = $form->group('Device');
|
||
|
||
$group_device->input('device_name')
|
||
->value(($user_id) ? $um->surname : '')
|
||
->rules('required|length[2,200]')
|
||
->style('width: 520px');
|
||
|
||
$group_device->input('trade_name')
|
||
->style('width: 520px');
|
||
|
||
$group_device->dropdown('user_id')
|
||
->label('User')
|
||
->rules('required')
|
||
->options($arr_users)
|
||
->selected($selected)
|
||
->style('width: 200px');
|
||
|
||
$group_device->dropdown('device_type')
|
||
->options($types)
|
||
->rules('required')
|
||
->style('width: 200px');
|
||
|
||
$group_device_details = $form->group('Device detail')->visible(FALSE);
|
||
|
||
$group_device_details->dropdown('PPPoE_logging_in')
|
||
->label('PPPoE')
|
||
->options(arr::rbool());
|
||
|
||
if ($this->acl_check_new(get_class($this), 'login'))
|
||
{
|
||
$group_device_details->input('login')
|
||
->label('Username')
|
||
->rules('length[0,30]')
|
||
->autocomplete('json/device_login');
|
||
}
|
||
|
||
if ($this->acl_check_new(get_class($this), 'password'))
|
||
{
|
||
$group_device_details->input('login_password')
|
||
->label('Password')
|
||
->rules('length[0,30]')
|
||
->autocomplete('json/device_password');
|
||
}
|
||
|
||
$group_device_details->dropdown('first_engineer_id')
|
||
->label('Engineer')
|
||
->options($arr_engineers)
|
||
->rules('required')
|
||
->selected($selected_engineer)
|
||
->style('width: 200px');
|
||
|
||
$group_device_details->textarea('device_comment')
|
||
->label('Comment')
|
||
->rules('length[0,254]')
|
||
->style('width: 520px');
|
||
|
||
$group_payment = $form->group('Device repayments')->visible(FALSE);
|
||
|
||
$group_payment->input('price')
|
||
->rules('valid_numeric');
|
||
|
||
$group_payment->input('payment_rate')
|
||
->label('Monthly payment rate')
|
||
->rules('valid_numeric');
|
||
|
||
$group_payment->date('buy_date')
|
||
->label('Buy date')
|
||
->years(date('Y')-100, date('Y'));
|
||
|
||
$group_address = $form->group('Address');
|
||
|
||
if (!empty($user_id))
|
||
{
|
||
$group_address->visible(!$um->id);
|
||
}
|
||
|
||
$group_address->dropdown('town_id')
|
||
->label('Town')
|
||
->rules('required')
|
||
->options($arr_towns)
|
||
->selected($selected_town_id)
|
||
->style('width: 200px')
|
||
->add_button('towns');
|
||
|
||
$group_address->dropdown('street_id')
|
||
->label('Street')
|
||
->options($arr_streets)
|
||
->selected($selected_street_id)
|
||
->add_button('streets')
|
||
->style('width: 200px');
|
||
|
||
$group_address->input('street_number')
|
||
->rules('length[1,50]')
|
||
->value($selected_street_number);
|
||
|
||
$group_address->dropdown('country_id')
|
||
->label('Country')
|
||
->rules('required')
|
||
->options($arr_countries)
|
||
->selected(Settings::get('default_country'))
|
||
->style('width: 200px');
|
||
|
||
$group_address->input('gpsx')
|
||
->label(__('GPS').' X: '.help::hint('gps_coordinates'))
|
||
->rules('gps')
|
||
->value($gpsx);
|
||
|
||
$group_address->input('gpsy')
|
||
->label(__('GPS').' Y: '.help::hint('gps_coordinates'))
|
||
->rules('gps')
|
||
->value($gpsy);
|
||
|
||
$form->submit('Send');
|
||
|
||
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
$dm = new Device_Model();
|
||
|
||
try
|
||
{
|
||
$dm->transaction_start();
|
||
// gps
|
||
$gpsx = NULL;
|
||
$gpsy = NULL;
|
||
|
||
if (!empty($form_data['gpsx']) && !empty($form_data['gpsy']))
|
||
{
|
||
$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']);
|
||
}
|
||
}
|
||
|
||
$dm->user_id = $form_data['user_id'];
|
||
$dm->name = $form_data['device_name'];
|
||
$dm->type = $form_data['device_type'];
|
||
$dm->trade_name = $form_data['trade_name'];
|
||
$dm->PPPoE_logging_in = $form_data['PPPoE_logging_in'];
|
||
|
||
if ($this->acl_check_new(get_class($this), 'login'))
|
||
{
|
||
$dm->login = $form_data['login'];
|
||
}
|
||
|
||
if ($this->acl_check_new(get_class($this), 'password'))
|
||
{
|
||
$dm->password = $form_data['login_password'];
|
||
}
|
||
|
||
$dm->comment = $form_data['device_comment'];
|
||
$dm->price = $form_data['price'];
|
||
$dm->payment_rate = $form_data['payment_rate'];
|
||
$dm->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
|
||
);
|
||
|
||
$dm->save_throwable();
|
||
|
||
// add address point if there is no such
|
||
if (!$ap->id)
|
||
{
|
||
// save
|
||
$ap->save_throwable();
|
||
}
|
||
// new addresspoint
|
||
if ($ap->id != $dm->address_point_id)
|
||
{
|
||
// delete old?
|
||
$addr_id = $dm->address_point->id;
|
||
// add to device
|
||
$dm->address_point_id = $ap->id;
|
||
$dm->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();
|
||
}
|
||
|
||
unset($form_data);
|
||
|
||
$dm->transaction_commit();
|
||
|
||
$this->redirect('devices/show/', $dm->id);
|
||
}
|
||
catch (Exception $e)
|
||
{
|
||
$dm->transaction_rollback();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (isset($user_id))
|
||
{
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('members/show_all', 'Members',
|
||
$this->acl_check_view('Members_Controller', 'members'))
|
||
->disable_translation()
|
||
->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/' . $um->member_id, 'Users',
|
||
$this->acl_check_view('Users_Controller', 'users', $um->member_id))
|
||
->disable_translation()
|
||
->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/' . $um->id, 'Devices',
|
||
$this->acl_check_view('Devices_Controller', 'devices', $um->member_id))
|
||
->text('Add new whole device');
|
||
}
|
||
else
|
||
{
|
||
// breadcrumbs navigation
|
||
$breadcrumbs = breadcrumbs::add()
|
||
->link('devices/show_all', 'Devices',
|
||
$this->acl_check_view('Devices_Controller','devices'))
|
||
->text('Add new whole device');
|
||
}
|
||
|
||
$headline = __('Add new device');
|
||
|
||
// view
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->breadcrumbs = $breadcrumbs->html();
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->headline = $headline;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Function edits device.
|
freenetis/branches/testing/application/views/js/ifaces_add.php | ||
---|---|---|
}
|
||
|
||
$.getJSON('<?php echo url_lang::base() ?>json/get_ifaces', {
|
||
data: val, itype: '<?php echo $itype ?>', wmode: wmode
|
||
data: val, itype: '<?php echo intval($itype) ? $itype : $connect_type ?>', wmode: wmode
|
||
}, function (data)
|
||
{
|
||
var options = ['<option value="">---- <?php echo __('Select interface') ?> ---</option>'];
|
||
... | ... | |
// if mid-step form opened dialog, on select, just open detailed form
|
||
$('#type').live('change', function ()
|
||
{
|
||
var device_id = parseInt($('#device_id').val());
|
||
var device_id = parseInt($('#device_id', context).val());
|
||
var type = parseInt($(this).val());
|
||
|
||
if (type && device_id)
|
freenetis/branches/testing/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', context);
|
||
var img = 'add';
|
||
var title = '<?php echo __('Show form items') ?>';
|
||
|
Také k dispozici: Unified diff
Opravy:
- Opravy problemu s aktualizaci select boxu
Upravy:
- Uprava stylu pocitadla v menu do oranzove barvy FreenetISu
- #243: Moznost pridani jednoducheho zarizeni v dialogu