/** * show phone numbers and dial button if there are phone numbers assigned to this agent * in diallist table * @param extension string extension * @return object xajax response object */ function getPrivateDialListNumber($extension = null) { global $locate, $db; $objResponse = new xajaxResponse(); $count = astercrm::getDialNumCountByAgent($extension); if ($count == 0) { $objResponse->addAssign("spanDialList", "innerHTML", $locate->Translate("no_dial_list")); $objResponse->addAssign("divWork", "innerHTML", ''); $objResponse->addAssign("btnWorkStatus", "value", ""); $objResponse->addAssign("btnWork", "value", $locate->Translate("Start work")); $objResponse->addAssign("btnWork", "disabled", true); $_SESSION['curuser']['WorkStatus'] = ''; } else { // add div $objResponse->addRemove("spanDialListRecords"); $objResponse->addRemove("btnGetAPhoneNumber"); $objResponse->addCreate("spanDialList", "div", "spanDialListRecords"); $objResponse->addAssign("spanDialListRecords", "innerHTML", $locate->Translate("records_in_dial_list_table") . $count); // add start campaign button $objResponse->addCreateInput("spanDialList", "button", "btnGetAPhoneNumber", "btnGetAPhoneNumber"); $objResponse->addAssign("btnGetAPhoneNumber", "value", $locate->Translate("get_a_phone_number")); $objResponse->addEvent("btnGetAPhoneNumber", "onclick", "btnGetAPhoneNumberOnClick();"); if ($_SESSION['curuser']['WorkStatus'] == '') { $objResponse->addAssign("btnWorkStatus", "value", ""); $objResponse->addAssign("btnWork", "value", $locate->Translate("Start work")); $objResponse->addAssign("btnWork", "disabled", false); } } return $objResponse; }
function window_open($window_name, $window = array()) { // Instantiate the xajaxResponse object $response = new xajaxResponse(); if (!$window_name) { return $response->getXML(); } // Variables that might be used in building HTML :: FIXME this is site specific! global $font_family, $color, $style, $images; // Load $window_html and $window_title from an include file $file = window_find_include($window_name); if ($file) { require_once $file; } // Setup a header and footer for the new window if (!$window['header']) { $window['header'] = <<<EOL <!-- This wrapper table is so that internal tables can be set to 100% width and they won't stretch the box too wide. --> <table id="{$window_name}_table" cellspacing="0" border="0" cellpadding="0"> <tr> <td> <!-- Window bar and close button --> <table id="{$window_name}_title_table" class="window_title" style="border-bottom: 1px solid #69A6DE;background-color: {$color['window_title_bg']};" width="100%" cellspacing="0" border="0" cellpadding="0"> <tr> <td id="{$window_name}_title" width="99%" align="left" nowrap="true" onMouseDown="focus_window('{$window_name}'); dragStart(event, '{$window_name}');" style="cursor: move; white-space: nowrap; font-weight: bold; text-align: left; padding: 2px 4px;">{$window['title']}</td> <td id="{$window_name}_title_r" align="right" nowrap="true" style="color: {$color['window_title_font']}; white-space: nowrap; text-align: right; padding: 2px 4px;"><span id="{$window_name}_title_help"></span> <a title="Close window" style="cursor: pointer;" onClick="removeElement('{$window_name}');"><img src="{$images}/icon_close.gif" border="0" /></a></td> </tr> </table> EOL; } if (!$window['footer']) { $window['footer'] = <<<EOL </td> </tr> </table> EOL; } // Create a new div to display the content in $response->addScript("removeElement('{$window_name}');"); $response->addCreate("window_container", "div", $window_name); $response->addScript("initialize_window('{$window_name}');" . "el('{$window_name}').style.display = 'none';" . "el('{$window_name}').style.visibility = 'hidden';" . "el('{$window_name}').onclick = function(ev) { focus_window(this.id); };"); $response->addAssign($window_name, "innerHTML", $window['header'] . $window['html'] . $window['footer']); $response->addScript("toggle_window('{$window_name}');" . $window['js']); // Send an XML response to the web browser return $response->getXML(); }
function ws_draw_block($window_name, $form = '') { global $conf, $self, $ona; global $images, $color, $style; $html = ''; $js = ''; // Instantiate the xajaxResponse object $response = new xajaxResponse(); // If the user supplied an array in a string, build the array and store it in $form $form = parse_options_string($form); // Find out if $ip is valid $ip = ip_mangle($form['ip'], 'numeric'); if ($ip == -1) { $js .= "alert('Invalid IP address!');"; $response->addScript($js); return $response->getXML(); } // Build a few variables $label = ip_mangle($ip, 'dotted'); if (is_ipv4($ip)) { $string_size = 15; } else { $string_size = 20; } $function = "get_{$form['row_type']}_html"; $row_zoom = $form['row_zoom']; $row_height = $form['row_height']; $row_offset = $form['row_offset']; // This is the number of pixels to leave for the label on the left (.45 * row height, * $string_size possible characters) $label_width = round($form['row_height'] * 0.45 * $string_size); $font_height = $form['row_height'] - 2; // Label font-size if ($font_height < 8) { $font_height = 8; } $row_left = $label_width + 10; // Left offset for the block row // Get some html (the html that goes inside the div) $html = $function($ip, $row_zoom, $row_height); $el_name = $ip . '_row'; // Add a row label $response->addCreate("{$window_name}_substrate", "div", $el_name . '_label'); $response->addScript(<<<EOL var _el = el('{$el_name}_label'); _el.style.visibility = 'hidden'; _el.style.position = 'absolute'; _el.style.textAlign = 'right'; _el.style.color = '#000000'; _el.style.fontSize = '{$font_height}px'; _el.style.top = '{$row_offset}px'; _el.style.left = '2px'; _el.style.width = '{$label_width}px'; _el.style.overflow = 'visible'; _el.style.whiteSpace = 'nowrap'; EOL ); // Add the row $response->addCreate("{$window_name}_substrate", "div", $el_name); $response->addScript(<<<EOL var _el = el('{$el_name}'); _el.style.visibility = 'hidden'; _el.style.position = 'absolute'; _el.style.top = '{$row_offset}px'; _el.style.left = '{$row_left}px'; _el.style.borderTop = '1px solid #000000'; _el.style.borderBottom = '1px solid #000000'; _el.style.borderLeft = '1px solid #000000'; if (browser.isIE) _el.style.fontSize = ({$font_height} - 2) + 'px'; EOL ); // Fill the label and row $response->addAssign($el_name, "innerHTML", $html); $response->addAssign($el_name . '_label', "innerHTML", $label); // Javascript to make sure the container (row) div is the exact length to hold it's contents in one row $response->addScript(<<<EOL var nodes = _el.childNodes; var width = 0; for (var counter=0; counter < nodes.length; counter++) if (nodes[counter].nodeType == 1) width += parseInt(nodes[counter].offsetWidth); if (browser.isIE) width += 1; /* for the left border */ _el.style.width = width + 'px'; EOL ); // Display the label and block $response->addScript(<<<EOL el('{$el_name}_label').style.visibility = 'visible'; el('{$el_name}').style.visibility = 'visible'; /* Tell the browser we've sent it this block so it knows it can re-request it if it needs to */ _map_requests_['{$el_name}'] = undefined; EOL ); if ($js) { $response->addScript($js); } return $response->getXML(); }
function addIndexField($field) { $objResponse = new xajaxResponse(); // $objResponse->addAlert($field); // $html = '<li id="idx_fld_list['.$field.']">'.$field.' => descending? <input type="checkbox" name="idx_fld_add['.$field.'][sorting]" value="1" ></li>'; $objResponse->addCreateInput('frm_index', 'hidden', "idx_fld_add[{$field}]", "idx_fld_add_{$field}"); $objResponse->addAssign('idx_fld_add_' . $field, 'value', ''); // $html = "<li id=\"idx_fld_item[{$field}]\">{$field} => descending?</li>"; // $objResponse->addAppend('idx_fields', 'innerHTML', $html); $objResponse->addCreate("idx_fields", 'li', "idx_fld_item[{$field}]"); $objResponse->addAssign("idx_fld_item[{$field}]", 'value', $field); $objResponse->addAssign("idx_fld_item[{$field}]", 'innerHTML', "{$field} => descending?"); $objResponse->addCreateInput("idx_fld_item[{$field}]", 'checkbox', "idx_fld_desc[{$field}]", "idx_fld_desc[{$field}]"); $objResponse->addAssign("idx_fld_desc[{$field}]", 'value', "1"); return $objResponse; }