Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1232

Přidáno uživatelem Michal Kliment před asi 13 roky(ů)

Vylepsena prace s VLANy. Pridana podpora automatickeho ziskavani GPS souradnice pomoci Googlu API. Rada dalsich zmen.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'assign user' => 'Přiřadit uživatele',
'assigning of transfer' => 'Přiřazení platby',
'assigning of unidentified payment' => 'Přiřazení neidentifikované platby',
'association' => 'Sdružení',
'association has not got credit account' => 'Sdružení nemá kreditní účet.',
'association information' => 'Informace o sdružení',
'association members' => 'Členové sdružení',
......
'august' => 'Srpen',
'author' => 'Autor',
'author fee' => 'Autorský poplatek',
'autocomplete of gps coords' => 'Automatické doplnění GPS souřadnic',
'automatically import admins' => 'Automaticky přidat správce oblastí',
'avarage day download' => 'Průměrní denní download',
'avarage day upload' => 'Průměrní denní upload',
......
'device type' => 'Typ zařízení',
'device_name' => 'Název zařízení',
'device_type' => 'Typ zařízení',
'devices count' => 'Počet zařízení',
'devices list' => 'Seznam zařízení',
'devices' => 'Zařízení',
'devices on this address' => 'Zařízení na této adrese',
......
'ip_address' => 'IP adresa',
'is' => 'je',
'is empty' => 'je prázdný',
'it has been autocompleted %s gps coords' => 'Bylo automaticky doplněno %s GPS souřadnic.',
'is in' => 'je v',
'is not' => 'není',
'is not empty' => 'není prázdný',
......
'port number already exist' => 'Číslo portu již existuje.',
'ports list' => 'Seznam portů',
'ports' => 'Porty',
'ports count' => 'Počet portů',
'possibility of canceling redirection to all ip addresses of member' => 'Možnost zrušení přesměrování všem IP adresám člena',
'possibility of canceling redirection to only current ip address' => 'Možnost zrušení přesměrování jen aktuální IP adrese',
'postpaid' => 'Paušální',
......
'system variables havent been updated' => 'Systémové proměnné nebyly úspěšně aktualizovány',
'table' => 'Tabulka',
'table prefix' => 'Prefix tabulek',
'tag_802_1q' => 'tag 802.1Q',
'tag_802_1q' => 'Tag 802.1Q',
'target website' => 'Cílový web pro přesměrování',
'tariff' => 'tarif',
'tariffs' => 'Tarify',
......
'this member has default system member fee %d %s' => 'Tento člen má výchozí systémový členský příspěvek %d %s.',
'this month has been already deducted!' => 'Tento měsíc už byl stržen!',
'this month traffic' => 'Provoz za tento měsíc',
'this operation can take a long time' => 'Tato operace může chvíli trvat.',
'this report is your concept, you can edit it till you think that it is ready for approval' => 'Tento výkaz je váš koncept, můžete jej editovat dokud si nemyslíte, že je připraven na hlasování o schválení.',
'this subnet is disabled' => 'Tato podsíť je zakázána.',
'this subnet is enabled' => 'Tato podsíť je povolena.',
freenetis/branches/testing/application/helpers/callback.php
*/
public static function subnet_field($item, $name)
{
if ($item->subnet_id)
if (isset($item->subnet_id) && $item->subnet_id)
echo html::anchor(url_lang::base()."subnets/show/$item->subnet_id", $item->subnet_name);
else
echo '&nbsp';
echo $item->subnet_name;
}
/**
......
{
echo Wireless_iface_Model::get_mode($item->wmode);
}
/**
* Callback function to print count of ports and grouped ports as title
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function ports_field ($item, $name)
{
if ($item->ports_count)
echo '<span class="help" title="'.$item->ports.'">'.$item->ports_count.'</span>';
else
echo $item->ports_count;
}
/**
* Callback function to print count of ports and grouped ports as title
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function devices_field ($item, $name)
{
if ($item->devices_count)
echo '<span class="help" title="'.$item->devices.'">'.$item->devices_count.'</span>';
else
echo $item->devices_count;
}
}
freenetis/branches/testing/application/models/subnet.php
return $this->db->query("
SELECT * FROM
(
SELECT s.id AS subnet_id, s.redirect, s.name AS subnet_name,
SELECT s.id, s.id AS subnet_id, s.redirect, s.name AS subnet_name,
CONCAT(network_address,'/', 32-log2((~inet_aton(netmask) & 0xffffffff) + 1)) AS cidr_address,
INET_ATON(network_address) AS cidr,
network_address, netmask,
freenetis/branches/testing/application/models/vlan_iface.php
LEFT JOIN vlans v ON vi.vlan_id = v.id
LEFT JOIN ifaces i ON vi.iface_id = i.id
WHERE i.device_id = ?
ORDER BY tag_802_1q
", array($device_id));
}
......
LEFT JOIN ip_addresses ip ON vi.id = ip.vlan_iface_id
LEFT JOIN subnets s ON ip.subnet_id = s.id
WHERE i.device_id = ?
ORDER BY INET_ATON(ip.ip_address)
ORDER BY tag_802_1q
", array ($device_id));
}
freenetis/branches/testing/application/models/user.php
'users' => 'private_phone_contacts', 'users_keys', 'device_admins'
);
protected $has_and_belongs_to_many = array('users_contacts' => 'contacts', 'clouds');
const ASSOCIATION = 1;
public static $arr_sql = array
(
......
*/
public function select_list_grouped()
{
$concat = "CONCAT(
COALESCE(surname, ''), ' ',
COALESCE(name, ''), ' - ',
COALESCE(login, '')
)";
$list = array();
return $this->select_list('id', $concat);
$assoc_user = $this->where('id', self::ASSOCIATION)->find();
$list[__('Association')][$assoc_user->id] = $assoc_user->member->name;
$users = $this->where('id !=', self::ASSOCIATION)
->orderby('surname')
->find_all();
foreach ($users as $user)
$list[__('users')][$user->id] = $user->surname.' '.$user->name;
return $list;
}
freenetis/branches/testing/application/models/address_point.php
ap.street_number,
t.town, t.quarter,
t.zip_code,
CONCAT(X(ap.gps), ' ', Y(ap.gps)) AS gps,
IFNULL(CONCAT(X(ap.gps), ' ', Y(ap.gps)),'') AS gps,
c.country_name,
COUNT(ap.id) AS items_count,
GROUP_CONCAT(item_name SEPARATOR ', \n') AS items_count_title
......
ap.street_number,
t.town, t.quarter,
t.zip_code,
CONCAT(X(ap.gps), ' ', Y(ap.gps)) AS gps,
IFNULL(CONCAT(X(ap.gps), ' ', Y(ap.gps)),'') AS gps,
c.country_name,
COUNT(ap.id) AS items_count
FROM
......
else
return NULL;
}
/**
* Returns all address point with empty GPS coords
*
* @author Michal Kliment
* @return MySQL Iterator object
*/
public function get_all_address_points_with_empty_gps ()
{
return $this->db->query("
SELECT ap.id, s.street, ap.street_number, t.town, t.quarter,
t.zip_code, c.country_name
FROM address_points ap
JOIN streets s ON ap.street_id = s.id
JOIN towns t ON ap.town_id = t.id
JOIN countries c ON ap.country_id = c.id
WHERE country_id IS NOT NULL
AND town_id IS NOT NULL
AND street_id IS NOT NULL
AND street_number IS NOT NULL
AND X(ap.gps) IS NULL
AND Y(ap.gps) IS NULL
");
}
}
freenetis/branches/testing/application/models/vlan.php
* @return unknown_type
*/
public function get_all_vlans($limit_from = 0, $limit_results = 50,
$order_by = 'vlans.id', $order_by_direction = 'ASC')
$order_by = 'tag_802_1q', $order_by_direction = 'ASC')
{
// order by check
if (!$this->has_column($order_by))
{
$order_by = 'vlans.id';
}
// order by direction check
$order_by_direction = strtolower($order_by_direction);
if ($order_by_direction != 'desc')
......
}
// query
return $this->db->query("
SELECT IFNULL(vlan_ifaces.vlan_ifaces_count,0) AS vlan_ifaces_count,
IFNULL(ports_vlans.ports_count,0) AS ports_count, vlans.*
FROM vlans
LEFT JOIN (
SELECT COUNT(*) as vlan_ifaces_count,vlan_id
FROM vlan_ifaces
GROUP BY vlan_id
) vlan_ifaces ON vlan_ifaces.vlan_id = vlans.id
LEFT JOIN (
SELECT COUNT(*) as ports_count,vlan_id
FROM ports_vlans
GROUP BY vlan_id
) ports_vlans ON ports_vlans.vlan_id=vlans.id
SELECT v.*, COUNT(d.id) AS devices_count,
GROUP_CONCAT(d.name SEPARATOR ', \n') AS devices
FROM vlans v
LEFT JOIN
(
SELECT i.device_id, vi.vlan_id
FROM vlan_ifaces vi
JOIN ifaces i ON vi.iface_id = i.id
UNION
SELECT p.device_id, pv.vlan_id
FROM ports_vlans pv
JOIN ports p ON pv.port_id = p.id
) i ON i.vlan_id = v.id
LEFT JOIN devices d ON i.device_id = d.id
GROUP BY v.id
ORDER BY $order_by $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) ."
");
......
return $arr_vlans;
}
/**
* Returns all devices which belong to VLAN
* @param type $vlan_id
* @return type
*/
public function get_devices_of_vlan ($vlan_id = NULL)
{
if (!$vlan_id && isset($this))
$vlan_id = $this->id;
return $this->db->query("
SELECT
d.id, d.name, IFNULL(p.ports_count,0) AS ports_count, p.ports,
IFNULL(d.ip_address, IFNULL(ip1.ip_address,ip2.ip_address)) AS ip_address,
IFNULL(d.ip_address_id, IFNULL(ip1.id,ip2.id)) AS ip_address_id
FROM
(
SELECT d.*,
IFNULL(ip1.ip_address,ip2.ip_address) AS ip_address,
IFNULL(ip1.id,ip2.id) AS ip_address_id
FROM devices d
LEFT JOIN ifaces i ON i.device_id = d.id
LEFT JOIN vlan_ifaces vi ON vi.iface_id = i.id
LEFT JOIN ip_addresses ip1 ON ip1.vlan_iface_id = vi.id
LEFT JOIN ip_addresses ip2 ON ip2.iface_id = i.id
LEFT JOIN ports p ON p.device_id = d.id
LEFT JOIN ports_vlans pv ON pv.port_id = p.id
WHERE vi.vlan_id = ? OR pv.vlan_id = ?
GROUP BY d.id
) d
LEFT JOIN ifaces i ON i.device_id = d.id
LEFT JOIN vlan_ifaces vi ON vi.iface_id = i.id
LEFT JOIN ip_addresses ip1 ON ip1.iface_id = i.id
LEFT JOIN ip_addresses ip2 ON ip2.vlan_iface_id = vi.id
LEFT JOIN
(
SELECT
p.device_id, COUNT(*) AS ports_count,
GROUP_CONCAT(IF(p.port_nr IS NOT NULL, CONCAT(?, p.port_nr), p.name) ORDER BY p.port_nr SEPARATOR ', \n') AS ports
FROM ports p
JOIN ports_vlans pv ON pv.port_id = p.id
WHERE pv.vlan_id = ?
GROUP BY p.device_id
) p ON p.device_id = d.id
GROUP BY d.id
ORDER BY INET_ATON(IFNULL(d.ip_address, IFNULL(ip1.ip_address,ip2.ip_address)))
", array($vlan_id, $vlan_id, __('Port').' ', $vlan_id));
}
}
freenetis/branches/testing/application/models/member.php
const TYPE_NON = 5;
const TYPE_FORMER = 15;
const ASSOCIATION = 1;
/**
* Gets joined values of member for members fees
*
freenetis/branches/testing/application/controllers/address_points.php
class Address_points_Controller extends Controller
{
const METHOD_GOOGLE = 1;
/**
* Index redirects to show all
*/
......
url_lang::base().'address_points/add',
__('Add address point')
);
$grid->add_new_button(
url_lang::base().'address_points/autocomplete_gps',
__('Automaticky doplnit GPS souřadnice')
);
$grid->order_field('id')
->label('ID');
......
echo gps::real2degrees($gps[1], FALSE);
}
}
/**
* Helper function to get geocode data from Google Map API
*
* @author Michal Kliment
* @param type $street
* @param type $street_number
* @param type $town
* @param type $country
* @return type
*/
private function get_geocode_from_google($street, $street_number, $town, $country)
{
$address = $street." ".$street_number.",".$town.",".$country;
$URL = "http://maps.googleapis.com/maps/api/geocode/json?address="
.urlencode($address)."&sensor=false";
$json = @file_get_contents($URL);
$data = json_decode($json);
if (!$data || !is_object($data) || $data->status != 'OK' || !isset($data->results[0]))
return FALSE;
return $data;
}
/**
* AJAX function to return GPS coords for given street, street number,
* town and country
*
* @author Michal Kliment
*/
public function get_gps_by_address_from_google()
{
$street = $this->input->get('street');
$street_number = (int) $this->input->get('street_number');
$town = $this->input->get('town');
$country = $this->input->get('country');
if ($street == '' || $street_number == '' || $town == '' || $country == '')
return;
$data = self::get_geocode_from_google ($street, $street_number, $town, $country);
if (!$data)
return;
echo num::decimal_point($data->results[0]->geometry->location->lat)." ".num::decimal_point($data->results[0]->geometry->location->lng);
}
/**
* Function to autocomplete empty GPS coords
*
* @author Michal Kliment
*/
public function autocomplete_gps()
{
$headline = __('Autocomplete of GPS coords');
// creates new form
$form = new Forge(
url_lang::base().'address_points/autocomplete_gps', '',
'POST', array('id' => 'article_form')
);
$form->dropdown('method')
->options(array
(
self::METHOD_GOOGLE => __('Google API')
));
$form->submit('submit')
->value(__('Update'));
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
// Google method
switch ($form_data['method'])
{
case self::METHOD_GOOGLE:
$address_point_model = new Address_point_Model();
// finds all address points with empty GPS coords
$address_points = $address_point_model
->get_all_address_points_with_empty_gps();
$updated = 0;
foreach ($address_points as $address_point)
{
$town = $address_point->town;
if ($address_point->quarter != '')
$town .= ', '.$address_point->quarter;
$town .= ', '.$address_point->zip_code;
// finds gps from google
$data = self::get_geocode_from_google (
$address_point->street,
$address_point->street_number,
$town,
$address_point->country_name
);
if (!$data)
continue;
// updates GPS coords
$address_point_model->update_gps_coordinates(
$address_point->id,
num::decimal_point($data->results[0]->geometry->location->lat),
num::decimal_point($data->results[0]->geometry->location->lng)
);
$updated++;
}
status::success(__('It has been autocompleted %s GPS coords.', $updated), FALSE);
url::redirect(url_lang::base().'address_points/show_all');
break;
}
}
$view = new View('main');
$view->title = $headline;
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->form = $form;
$view->content->aditional_info = '<b>!!! '.__('Warning').': '.__('This operation can take a long time').' !!!</b>';
$view->render(TRUE);
}
}
freenetis/branches/testing/application/controllers/subnets.php
);
}
$grid->order_field('id')
->label(__('ID'));
$grid->order_callback_field('subnet_name')
->label(__('Name'))
->callback('callback::subnet_field');
......
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller', 'subnet'))
{
$actions->add_action('id')
->icon_action('show')
->url('subnets/show');
}
if ($this->acl_check_edit('Devices_Controller', 'subnet'))
{
$actions->add_action('subnet_id')
$actions->add_action('id')
->icon_action('edit')
->url('subnets/edit');
}
if ($this->acl_check_delete('Devices_Controller', 'subnet'))
{
$actions->add_action('subnet_id')
$actions->add_action('id')
->icon_action('delete')
->url('subnets/delete')
->class('delete_link');
freenetis/branches/testing/application/controllers/segments.php
$segments = $segment_model->get_all_segments(
$sql_offset, (int)$limit_results, $order_by,
$order_by_direction, $filter_form->as_sql()
);
);
$grid = new Grid(url_lang::base().'segments', null, array
(
freenetis/branches/testing/application/controllers/json.php
echo json_encode($arr_ssids);
}
/**
* Callback AJAX function to get only devices of choosen user to dropdown
*
* @author Michal Kliment
*/
public function get_devices_by_user()
{
$user_id = $this->input->get('user_id');
$device_model = new Device_Model();
if ($user_id && is_numeric($user_id))
{
$devices = $device_model->where('user_id',$user_id)
->orderby('name')
->find_all();
}
else
{
$devices = $device_model->orderby('name')
->find_all();
}
$arr_devices = array();
foreach ($devices as $device)
$arr_devices[] = array('id' => $device->id, 'name' => $device->name);
echo json_encode($arr_devices);
}
}
freenetis/branches/testing/application/controllers/vlans.php
* @param integer $page
*/
public function show_all(
$limit_results = 50, $order_by = 'id', $order_by_direction = 'asc',
$limit_results = 50, $order_by = 'tag_802_1q', $order_by_direction = 'asc',
$page_word = null, $page = 1)
{
......
'base_url' => Config::get('lang') . '/vlans/show_all/'
. $limit_results . '/' . $order_by
. '/' . $order_by_direction,
'uri_vlan' => 'page',
'uri_segment' => 'page',
'total_items' => $total_vlans,
'items_per_page' => $limit_results,
'style' => 'classic',
......
$grid->order_field('tag_802_1q')
->label(__('tag_802_1q'));
$grid->order_field('vlan_ifaces_count')
->label(__('Vlan ifaces'))
->class('center');
$grid->order_callback_field('devices_count')
->label(__('Devices count'))
->callback('callback::devices_field');
$grid->order_field('ports_count')
->label(__('Ports'))
->class('center');
$grid->order_field('comment')
->label(__('comment'));
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller', 'vlan'))
......
->url('vlans/edit');
}
if ($this->acl_check_delete('Devices_Controller', 'vlan'))
{
$actions->add_action()
->icon_action('delete')
->url('vlans/delete');
}
$grid->datasource($query);
$this->template->content = $grid;
......
{
Controller::error(ACCESS);
}
// list of PORTS
$ports = new Port_Model();
$query = $ports->select(array
(
'ports_vlans.id as port_id', 'ports.*'
))->join('ports_vlans', 'ports_vlans.port_id', 'ports.id')
->orderby('id', 'ASC')
->find_all();
$grid_ports = new Grid(url_lang::base() . 'vlans', null, array
$grid = new Grid(url_lang::base() . 'vlans', null, array
(
'separator' => '',
'use_paginator' => false,
'use_selector' => false
));
$grid_ports->field('id')
$grid->field('id')
->label('ID')
->class('center');
$grid_ports->field('name')
->label(__('Port name'));
$grid->field('name')
->label(__('Device name'));
$grid_ports->datasource($query);
$grid->callback_field('ports_count')
->label(__('Ports count'))
->callback('callback::ports_field');
$grid->callback_field('ip_address')
->callback('callback::ip_address_field');
$grid->datasource($vlan->get_devices_of_vlan());
$actions = $grid->grouped_action_field();
if ($this->acl_check_view('Devices_Controller','devices'))
{
$actions->add_action('id')
->icon_action('show')
->url('devices/show');
}
if ($this->acl_check_edit('Devices_Controller','devices'))
{
$actions->add_action('id')
->icon_action('edit')
->url('devices/edit');
}
if ($this->acl_check_delete('Devices_Controller', 'devices'))
{
$actions->add_action('id')
->icon_action('delete')
->url('devices/delete')
->class('delete_link');
}
$breadcrumbs = breadcrumbs::add()
->link('vlans/show_all', 'VLANs')
->disable_translation()
......
$view = new View('main');
$view->title = __('Vlan detail') . ' - ' . $vlan->name;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('show_vlan');
$view->content = new View('vlan_show');
$view->content->vlan = $vlan;
$view->content->table_ports = $grid_ports;
$view->content->grid = $grid;
$view->content->headline = __('Vlan detail') . ' - ' . $vlan->name;
$view->render(TRUE);
}
......
$view->content->headline = __('Edit vlan') . ' - ' . $vlan->name;
$view->render(TRUE);
}
/**
* Deletes VLAN
*
* @author Michal Kliment
* @param integer $vlan_id
*/
public function delete ($vlan_id = NULL)
{
// bad parameter
if (!$vlan_id || !is_numeric($vlan_id))
Controller::warning(PARAMETER);
$vlan = new Vlan_Model($vlan_id);
// record doesn't exist
if (!$vlan->id)
Controller::error(RECORD);
// access control
if (!$this->acl_check_delete('Devices_Controller', 'vlan'))
Controller::error(ACCESS);
foreach ($vlan->vlan_ifaces as $vlan_iface)
$vlan_iface->delete();
$ports = ORM::factory('ports_vlan')->where('vlan_id', $vlan->id)
->find_all();
foreach ($ports as $port)
$port->delete();
if ($vlan->delete())
status::success ('Vlan has been successfully deleted.');
else
status::error ('Vlan hasn\t been deleted');
url::redirect (url_lang::base().'vlans/show_all');
}
}
freenetis/branches/testing/application/libraries/Form_Input.php
public function __construct($name)
{
$this->data['name'] = $name;
$this->data['label'] = url_lang::lang('texts.'.utf8::ucwords(inflector::humanize($name))).':';
}
/**
freenetis/branches/testing/application/views/show_vlan.php
<h2><?php echo $headline ?></h2>
<?php if (isset($submenu))
echo '<div class="submenu">' . $submenu . '</div>'; ?>
<?php
if ($this->acl_check_edit('Devices_Controller', 'vlan'))
echo html::anchor(url_lang::base() . 'vlans/edit/' . $vlan->id, __('Edit'))
?><br /><br />
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('ID') ?></th>
<td><?php echo $vlan->id ?></td>
</tr>
<tr>
<th><?php echo __('Vlan name') ?></th>
<td><?php echo $vlan->name ?></td>
</tr>
<tr>
<th><?php echo __('tag_802_1q') ?></th>
<td><?php echo $vlan->tag_802_1q ?></td>
</tr>
<tr>
<th><?php echo __('Comment') ?></th>
<td><?php echo $vlan->comment ?></td>
</tr>
</table><br /><br />
<h3><?php echo __('Ports') ?></h3><br />
<?php echo $table_ports ?>
<br />
freenetis/branches/testing/application/views/vlan_show.php
<h2><?php echo $headline ?></h2>
<?php if (isset($submenu))
echo '<div class="submenu">' . $submenu . '</div>'; ?>
<?php
if ($this->acl_check_edit('Devices_Controller', 'vlan'))
echo html::anchor(url_lang::base() . 'vlans/edit/' . $vlan->id, __('Edit'))
?>
<?php
if ($this->acl_check_delete('Devices_Controller', 'vlan'))
echo ' | '.html::anchor(url_lang::base() . 'vlans/delete/' . $vlan->id, __('Delete'))
?><br /><br />
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('ID') ?></th>
<td><?php echo $vlan->id ?></td>
</tr>
<tr>
<th><?php echo __('Vlan name') ?></th>
<td><?php echo $vlan->name ?></td>
</tr>
<tr>
<th><?php echo __('tag_802_1q') ?></th>
<td><?php echo $vlan->tag_802_1q ?></td>
</tr>
<tr>
<th><?php echo __('Comment') ?></th>
<td><?php echo $vlan->comment ?></td>
</tr>
</table><br /><br />
<h3><?php echo __('Devices') ?></h3><br />
<?php echo $grid ?>
<br />
freenetis/branches/testing/application/views/js/devices_add.php
$("#itype").trigger('change');
}
});
$("#_user_id").change(function (){
$("#device_id").html('<option value=""><?php echo __('Loading data, please wait') ?>...</option>');
$.getJSON("<?php echo url_lang::base() ?>json/get_devices_by_user/", {user_id: $(this).val()}, function(data)
{
var options = '';
$.each(data, function(key, val)
{
options += '<option value="' + val.id + '">' + val.name + '</option>';
});
$("#device_id").html(options);
})
});
freenetis/branches/testing/application/views/js/__pieces/gps.php
"country_id": $("#country_id").val()
}, function(data)
{
var s = data.split(" ");
$("#gpsx").val(s[0]);
$("#gpsy").val(s[1]);
if (data != '')
{
var s = data.split(" ");
$("#gpsx").val(s[0]);
$("#gpsy").val(s[1]);
}
else
{
$.get("<?php echo url_lang::base() ?>address_points/get_gps_by_address_from_google/",
{
"street": $("#street_id option:selected").text(),
"street_number": $("#street_number").val(),
"town": $("#town_id option:selected").text(),
"country": $("#country_id option:selected").text()
}, function(data)
{
var s = data.split(" ");
$("#gpsx").val(s[0]);
$("#gpsy").val(s[1]);
});
}
});
});
freenetis/branches/testing/application/views/js/address_points_edit.php
<?php
/**
* GPS javascript view.
* During adding of address point, try to add GPS for selected country,
* street, street number and town and set it to GPS fields.
*
* @author Michal Kliment, Ondřej Fibich
*/
// IDE complementation
if (FALSE): ?><script type="text/javascript"><?php endif
?>
$(document).ready(function(){
$("#gpsx, #gpsy").keyup(function (){
if ($("#gpsx").val() == '' || $("#gpsy").val() == '')
{
$.get("<?php echo url_lang::base() ?>address_points/get_gps_by_address_from_google/",
{
"street": $("#street_id option:selected").text(),
"street_number": $("#street_number").val(),
"town": $("#town_id option:selected").text(),
"country": $("#country_id option:selected").text()
}, function(data)
{
var s = data.split(" ");
$("#gpsx").val(s[0]);
$("#gpsy").val(s[1]);
});
}
});
$("#gpsx, #gpsy").trigger("keyup");
});
freenetis/branches/testing/application/views/form.php
<?php
if (isset($aditional_info))
{
if (!is_array($aditional_info))
$aditional_info = array($aditional_info);
foreach ($aditional_info as $row)
{
echo $row . '<br />';

Také k dispozici: Unified diff