/**
 * Returns switch edit form for some existing device ID
 * 
 * @param int $switchid
 * @return string
 */
function web_SwitchEditForm($switchid)
{
    global $ubillingConfig;
    $switchid = vf($switchid, 3);
    $altCfg = $ubillingConfig->getAlter();
    $result = '';
    $allswitchmodels = zb_SwitchModelsGetAllTag();
    $switchdata = zb_SwitchGetData($switchid);
    $editinputs = wf_Selector('editmodel', $allswitchmodels, 'Model', $switchdata['modelid'], true);
    $editinputs .= wf_TextInput('editip', 'IP', $switchdata['ip'], true, 20);
    $editinputs .= wf_TextInput('editlocation', 'Location', $switchdata['location'], true, 30);
    $editinputs .= wf_TextInput('editdesc', 'Description', $switchdata['desc'], true, 30);
    $editinputs .= wf_TextInput('editsnmp', 'SNMP community', $switchdata['snmp'], true, 20);
    $editinputs .= wf_TextInput('editgeo', 'Geo location', $switchdata['geo'], true, 20);
    $editinputs .= web_SwitchUplinkSelector('editparentid', __('Uplink switch'), $switchdata['parentid']);
    $editinputs .= wf_tag('br');
    $editinputs .= wf_Submit('Save');
    $result .= wf_Form('', 'POST', $editinputs, 'glamour');
    $result .= wf_tag('div', false, '', 'style="clear:both;"') . wf_tag('div', true);
    $result .= wf_delimiter();
    $result .= wf_Link('?module=switches', __('Back'), false, 'ubButton');
    if (cfr('SWITCHPOLL')) {
        $fdbCacheName = 'exports/' . $switchdata['ip'] . '_fdb';
        if (file_exists($fdbCacheName)) {
            $result .= wf_Link('?module=switchpoller&fdbfor=' . $switchdata['ip'], wf_img('skins/menuicons/switchpoller.png') . ' ' . __('Current FDB cache'), false, 'ubButton');
        }
        if (!empty($switchdata['snmp'])) {
            $result .= wf_Link('?module=switchpoller&switchid=' . $switchid, wf_img('skins/snmp.png') . ' ' . __('SNMP query'), false, 'ubButton');
        }
    }
    if (!empty($switchdata['ip'])) {
        $result .= wf_AjaxLink('?module=switches&backgroundicmpping=' . $switchdata['ip'], wf_img('skins/ping_icon.png') . ' ' . __('ICMP ping'), 'icmppingcontainer', false, 'ubButton');
    }
    if (isset($altCfg['SW_WEBNAV'])) {
        if ($altCfg['SW_WEBNAV']) {
            $result .= ' ' . wf_tag('a', false, 'ubButton', 'href="http://' . $switchdata['ip'] . '" target="_BLANK"') . wf_img('skins/ymaps/globe.png') . ' ' . __('Go to the web interface') . wf_tag('a', true) . ' ';
        }
    }
    if (cfr('SWITCHEDIT')) {
        if (!ispos($switchdata['desc'], 'NP')) {
            $result .= wf_JSAlertStyled('?module=switchreplace&switchid=' . $switchid, wf_img('skins/duplicate_icon.gif') . ' ' . __('Replacement'), __('Are you serious'), 'ubButton') . ' ';
        }
    }
    if (cfr('SWITCHESEDIT')) {
        $result .= wf_JSAlertStyled('?module=switches&switchdelete=' . $switchid, web_delete_icon() . ' ' . __('Delete'), 'Removing this may lead to irreparable results', 'ubButton');
    }
    if (!empty($switchdata['ip'])) {
        $result .= wf_AjaxLoader();
        $result .= wf_AjaxContainer('icmppingcontainer');
    }
    return $result;
}
 /**
  * Renders task creation form
  * 
  * @return string
  */
 public function renderCreateForm($login)
 {
     $result = '';
     $result .= wf_AjaxLoader();
     $inputs = wf_HiddenInput('newschedlogin', $login);
     $inputs .= wf_DatePickerPreset('newscheddate', curdate()) . ' ' . __('Target date') . wf_tag('br');
     $inputs .= wf_AjaxSelectorAC('ajparamcontainer', $this->actions, __('Task'), '', true);
     $inputs .= wf_AjaxContainer('ajparamcontainer');
     $result .= wf_Form('', 'POST', $inputs, 'glamour');
     return $result;
 }
Exemple #3
0
 /**
  * Renders debtors notifications by address selection
  * 
  * 
  * @return void
  */
 public function reportDebtStreets()
 {
     if (wf_CheckGet(array('aj_rdabuildsel'))) {
         if (!empty($_GET['aj_rdabuildsel'])) {
             $streetId = base64_decode($_GET['aj_rdabuildsel']);
             $buildInputs = wf_HiddenInput('streetsel', $streetId);
             $buildInputs .= wf_TextInput('debtcash', __('The threshold at which the money considered user debtor'), '0', true, 4);
             $buildInputs .= wf_Submit(__('Print'));
             die($buildInputs);
         } else {
             die('');
         }
     }
     if (!wf_CheckPost(array('streetsel'))) {
         $streetData = array();
         if (!empty($this->streets)) {
             foreach ($this->streets as $streetId => $eachStreetName) {
                 $streetId = base64_encode($eachStreetName);
                 $streetData[self::URL_REPORTS_MGMT . 'reportDebtStreets' . '&aj_rdabuildsel=' . $streetId] = $eachStreetName;
             }
         }
         $inputs = wf_AjaxLoader();
         $inputs .= wf_AjaxSelectorAC('aj_buildcontainer', $streetData, __('Street'), '', false);
         $inputs .= wf_AjaxContainer('aj_buildcontainer');
         $form = wf_Form('', 'POST', $inputs, 'glamour');
         show_window(__('Current debtors for delivery by streets'), $form);
     } else {
         $searchStreet = mysql_real_escape_string($_POST['streetsel']);
         $debtCash = wf_CheckPost(array('debtcash')) ? '-' . vf($_POST['debtcash'], 3) : 0;
         $query = "SELECT * from `ukv_users` WHERE `cash`<'" . $debtCash . "' AND `street`='" . $searchStreet . "'  AND `active`='1' ORDER BY `build`";
         $allDebtors = simple_queryall($query);
         $rawTemplate = file_get_contents(CONFIG_PATH . "catv_debtors.tpl");
         $printableTemplate = '';
         if (!empty($allDebtors)) {
             foreach ($allDebtors as $io => $each) {
                 $rowtemplate = $rawTemplate;
                 $rowtemplate = str_ireplace('{REALNAME}', $each['realname'], $rowtemplate);
                 $rowtemplate = str_ireplace('{STREET}', $each['street'], $rowtemplate);
                 $rowtemplate = str_ireplace('{BUILD}', $each['build'], $rowtemplate);
                 $rowtemplate = str_ireplace('{APT}', $each['apt'], $rowtemplate);
                 $rowtemplate = str_ireplace('{DEBT}', $each['cash'], $rowtemplate);
                 $rowtemplate = str_ireplace('{CURDATE}', curdate(), $rowtemplate);
                 $rowtemplate = str_ireplace('{PAYDAY}', date("Y-m-") . '01', $rowtemplate);
                 $printableTemplate .= $rowtemplate;
             }
             $printableTemplate = wf_TableBody($printableTemplate, '100%', 0, 'sortable');
             $printableTemplate = $this->reportPrintable(__('Current debtors for delivery by streets'), $printableTemplate);
         } else {
             show_window('', $this->messages->getStyledMessage(__('Nothing found'), 'info'));
         }
     }
 }
 /**
  * Returns outcoming operation creation form
  * 
  * @param int $storageid
  * @param int $itemtypeid
  * 
  * @return string
  */
 public function outcomingCreateForm($storageid, $itemtypeid)
 {
     $result = '';
     $storageid = vf($storageid, 3);
     $itemtypeid = vf($itemtypeid, 3);
     $tmpDests = array();
     if (isset($this->allStorages[$storageid]) and isset($this->allItemTypes[$itemtypeid])) {
         $itemData = $this->allItemTypes[$itemtypeid];
         $itemUnit = $this->unitTypes[$itemData['unit']];
         $storageRemains = $this->remainsOnStorage($storageid);
         $allRemains = $this->remainsAll();
         if (isset($storageRemains[$itemtypeid])) {
             $itemRemainsStorage = $storageRemains[$itemtypeid];
         } else {
             $itemRemainsStorage = 0;
         }
         if (isset($allRemains[$itemtypeid])) {
             $itemRemainsTotal = $allRemains[$itemtypeid];
         } else {
             $itemRemainsTotal = 0;
         }
         $isReserved = $this->reserveGet($storageid, $itemtypeid);
         foreach ($this->outDests as $destMark => $destName) {
             $tmpDests[self::URL_ME . '&' . self::URL_OUT . '&' . self::URL_AJODSELECTOR . $destMark] = $destName;
         }
         //form construct
         $inputs = wf_AjaxLoader();
         $inputs .= wf_HiddenInput('newoutdate', curdate());
         $inputs .= wf_AjaxSelectorAC('ajoutdestselcontainer', $tmpDests, __('Destination'), '', false);
         $inputs .= wf_AjaxContainer('ajoutdestselcontainer', '', $this->outcomindAjaxDestSelector('task'));
         $inputs .= wf_HiddenInput('newoutitemtypeid', $itemtypeid);
         $inputs .= wf_HiddenInput('newoutstorageid', $storageid);
         $inputs .= wf_TextInput('newoutcount', $itemUnit . ' (' . ($itemRemainsStorage - $isReserved) . ' ' . __('maximum') . ')', '', true, '4');
         $inputs .= wf_TextInput('newoutprice', __('Price') . ' (' . __('middle price') . ': ' . $this->getIncomeMiddlePrice($itemtypeid) . ')', '', true, '4');
         $inputs .= wf_TextInput('newoutnotes', __('Notes'), '', true, 25);
         $inputs .= wf_tag('br');
         $inputs .= wf_Submit(__('Create'));
         $form = wf_Form('', 'POST', $inputs, 'glamour');
         //notifications
         if ($itemRemainsTotal < $itemData['reserve']) {
             $remainsAlert = __('The balance of goods and materials in stock is less than the amount') . ' ' . $itemData['reserve'] . ' ' . $itemUnit;
         } else {
             $remainsAlert = '';
         }
         $remainsNotification = __('At storage') . ' ' . @$this->allStorages[$storageid] . ' ' . __('remains') . ' ' . $itemRemainsStorage . ' ' . $itemUnit . ' ' . $itemData['name'];
         $notifications = $this->messages->getStyledMessage($remainsNotification, 'success');
         if ($isReserved) {
             $notifications .= $this->messages->getStyledMessage(__('Reserved') . ' ' . $isReserved . ' ' . $itemUnit, 'info');
         }
         if ($remainsAlert) {
             $notifications .= $this->messages->getStyledMessage($remainsAlert, 'warning');
         }
         $notifications .= wf_CleanDiv();
         if (cfr('WAREHOUSERESERVE')) {
             $reserveLink = self::URL_ME . '&' . self::URL_RESERVE . '&itemtypeid=' . $itemtypeid . '&storageid=' . $storageid;
             $notifications .= wf_tag('div', false, '', 'style="margin: 20px 3% 0 3%;"') . wf_Link($reserveLink, wf_img('skins/whreservation.png') . ' ' . __('Reservation'), false, 'ubButton') . wf_tag('div', true);
             $notifications .= wf_CleanDiv();
         }
         $cells = wf_TableCell($form, '40%');
         $cells .= wf_TableCell($notifications, '', '', 'valign="top"');
         $rows = wf_TableRow($cells);
         $result = wf_TableBody($rows, '100%', 0, '');
         //photostorage integration
         if ($this->altCfg['PHOTOSTORAGE_ENABLED']) {
             $photostorage = new PhotoStorage(self::PHOTOSTORAGE_SCOPE, $itemtypeid);
             $result .= $photostorage->renderImagesRaw();
         }
     } else {
         $result = $this->messages->getStyledMessage(__('Strange exeption'), 'error');
     }
     return $result;
 }
Exemple #5
0
 /**
  * Renders service and IP selection dialog 
  * 
  * @return string
  */
 public function renderMainForm()
 {
     $result = '';
     $servSelector = array();
     if (!empty($this->allServices)) {
         foreach ($this->allServices as $serviceId => $serviceName) {
             $servSelector[self::URL_ME . '&ajserviceid=' . $serviceId] = $serviceName;
         }
         //getting firs service ID
         reset($this->allServices);
         $defaultService = key($this->allServices);
         $result = wf_AjaxLoader();
         $inputs = wf_AjaxSelectorAC('ajcontainer', $servSelector, __('Select User new service'), '', false);
         $inputs .= wf_tag('br') . wf_tag('br');
         $inputs .= wf_AjaxContainer('ajcontainer', '', $this->ajIpSelector($defaultService));
         $inputs .= wf_delimiter();
         $inputs .= wf_Submit(__('Save'));
         $result .= wf_Form("", 'POST', $inputs, 'floatpanels');
     } else {
         $result = $this->messages->getStyledMessage(__('No available services'), 'error');
     }
     return $result;
 }