/** * Return Ajax build selection box * @param $streetid - street id * * @return string */ function ajax_BuildSelector($streetid) { $streetid = vf($streetid, 3); $allbuild = zb_AddressGetBuildAllDataByStreet($streetid); $buildbox = __('Build') . '<select id="buildbox" name="buildbox" onchange="var valueb = document.getElementById(\'buildbox\').value; goajax(\'?module=expresscard&ajaxapt=\'+valueb,\'daptbox\');">'; $buildbox .= '<option value="99999">-</option>'; if (!empty($allbuild)) { foreach ($allbuild as $io => $each) { $buildbox .= '<option value="' . $each['id'] . '">' . $each['buildnum'] . '</option>'; } } $buildbox .= '</select>'; die($buildbox); }
/** * Returns build lister with controls for some streetID * * @global array $ubillingConfig * @param int $streetid * @return string */ function web_BuildLister($streetid) { global $ubillingConfig; $altcfg = $ubillingConfig->getAlter(); $allbuilds = zb_AddressGetBuildAllDataByStreet($streetid); $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('Building number')); $cells .= wf_TableCell(__('Geo location')); $cells .= wf_TableCell(__('Actions')); $rows = wf_TableRow($cells, 'row1'); if (!empty($allbuilds)) { //build passport data processing if ($altcfg['BUILD_EXTENDED']) { $buildPassport = new BuildPassport(); } foreach ($allbuilds as $io => $eachbuild) { $cells = wf_TableCell($eachbuild['id']); $cells .= wf_TableCell($eachbuild['buildnum']); $cells .= wf_TableCell($eachbuild['geo']); $acts = wf_JSAlert('?module=builds&action=delete&streetid=' . $streetid . '&buildid=' . $eachbuild['id'], web_delete_icon(), 'Removing this may lead to irreparable results'); $acts .= '' . wf_JSAlert('?module=builds&action=editbuild&streetid=' . $streetid . '&buildid=' . $eachbuild['id'], web_edit_icon(), 'Are you serious'); if (!empty($eachbuild['geo'])) { $acts .= ' ' . wf_Link("?module=usersmap&findbuild=" . $eachbuild['geo'], wf_img('skins/icon_search_small.gif', __('Find on map')), false); } if ($altcfg['BUILD_EXTENDED']) { $acts .= ' ' . wf_modal(wf_img('skins/icon_passport.gif', __('Build passport')), __('Build passport'), $buildPassport->renderEditForm($eachbuild['id']), '', '600', '450'); } $cells .= wf_TableCell($acts); $rows .= wf_TableRow($cells, 'row3'); } } $result = wf_TableBody($rows, '100%', 0, 'sortable'); return $result; }
<?php // check for right of current admin on this module if (cfr('BUILDS')) { if (!isset($_GET['action'])) { show_window(__('Builds editor'), web_StreetListerBuildsEdit()); } else { if (isset($_GET['streetid'])) { $streetid = vf($_GET['streetid']); if ($_GET['action'] == 'edit') { if (isset($_POST['newbuildnum'])) { if (!empty($_POST['newbuildnum'])) { //check for exist of same build at this street $existingBuilds_raw = zb_AddressGetBuildAllDataByStreet($streetid); $existingBuilds = array(); if (!empty($existingBuilds_raw)) { foreach ($existingBuilds_raw as $ix => $eachbuilddata) { $existingBuilds[] = strtolower_utf8($eachbuilddata['buildnum']); } } if (!in_array(strtolower_utf8($_POST['newbuildnum']), $existingBuilds)) { zb_AddressCreateBuild($streetid, $_POST['newbuildnum']); } else { show_error(__('The same build already exists')); } } else { show_error(__('Empty building number')); } } $streetname = zb_AddressGetStreetData($streetid); $streetname = $streetname['streetname'];