Exemple #1
0
/**
 * Return Ajax street selection box
 *  @param $cityid - city id
 * 
 * @return string
 */
function ajax_StreetSelector($cityid)
{
    $cityid = vf($cityid, 3);
    $allstreets = zb_AddressGetStreetAllDataByCity($cityid);
    $streetbox = __('Street') . '<select id="streetbox" name="streetbox" onchange="var valuest = document.getElementById(\'streetbox\').value; goajax(\'?module=expresscard&ajaxbuild=\'+valuest,\'dbuildbox\');">';
    $streetbox .= '<option value="99999">-</option>';
    if (!empty($allstreets)) {
        foreach ($allstreets as $io => $each) {
            $streetbox .= '<option value="' . $each['id'] . '">' . $each['streetname'] . '</option>';
        }
    }
    $streetbox .= '</select>';
    die($streetbox);
}
Exemple #2
0
/**
 * Returns auto-clicking selector of available streets
 * 
 * @param int $cityid
 * @return string
 */
function web_StreetSelectorAc($cityid)
{
    $allstreets = array();
    $tmpStreets = zb_AddressGetStreetAllDataByCity($cityid);
    $allstreets['-'] = '-';
    // placeholder
    if (!empty($tmpStreets)) {
        foreach ($tmpStreets as $io => $each) {
            $allstreets[$each['id']] = $each['streetname'];
        }
    }
    $selector = wf_SelectorAC('streetsel', $allstreets, '', '', false);
    $selector .= wf_tag('a', false, '', 'href="?module=streets&citypreset=' . $cityid . '" target="_BLANK"') . web_street_icon() . wf_tag('a', true);
    return $selector;
}
Exemple #3
0
<?php

// check for right of current admin on this module
if (cfr('STREETS')) {
    if (isset($_POST['newstreetname'])) {
        $newstreetname = trim($_POST['newstreetname']);
        $newstreetname = zb_AddressFilterStreet($newstreetname);
        $newstreetcityid = $_POST['citysel'];
        if (isset($_POST['newstreetalias'])) {
            $newstreetalias = trim($_POST['newstreetalias']);
        } else {
            $newstreetalias = '';
        }
        if (!empty($newstreetname)) {
            //check for existing same street in city
            $existingStreets_raw = zb_AddressGetStreetAllDataByCity($newstreetcityid);
            $existingStreets = array();
            if (!empty($existingStreets_raw)) {
                foreach ($existingStreets_raw as $ix => $eachstreetdata) {
                    $existingStreets[] = strtolower_utf8($eachstreetdata['streetname']);
                }
            }
            if (!in_array(strtolower_utf8($newstreetname), $existingStreets)) {
                zb_AddressCreateStreet($newstreetcityid, $newstreetname, $newstreetalias);
            } else {
                show_error(__('The same street already exists'));
            }
        } else {
            show_error(__('Empty street name'));
        }
    }