Exemplo n.º 1
0
 public function body($params2 = array(), $def_account_id = null)
 {
     $accounts = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user()));
     $def = null;
     $user_def = null;
     $def_id = $this->get_module_variable('default', $def_account_id);
     foreach ($accounts as $a) {
         if ($def === null) {
             $def = $a;
         }
         if ($a['default_account']) {
             $user_def = $a;
         }
         if ($def_id === null && $a['default_account']) {
             $def = $a;
             break;
         } elseif ($a['id'] == $def_id) {
             $def = $a;
             break;
         }
     }
     foreach ($accounts as $a) {
         Base_ActionBarCommon::add('add', $a == $def ? '<b><u>' . $a['account_name'] . '</u></b>' : $a['account_name'], $this->create_callback_href(array($this, 'account'), $a['id']), $a['email'], $a == $user_def ? -1 : 0);
     }
     if ($def === null) {
         print '<h1><a ' . $this->create_callback_href(array($this, 'push_settings'), array(__('E-mail Accounts'))) . '>Please set your e-mail account</a></h1>';
         return;
     }
     $params = array('_autologin_id' => $def['id']) + $params2;
     //        if($params2) $params['_url'] = http_build_query($params2);
     print '<div style="background:transparent url(images/loader-0.gif) no-repeat 50% 50%;"><iframe style="border:0" border="0" src="modules/CRM/Roundcube/RC/index.php?' . http_build_query($params) . '" width="100%" height="300px" id="rc_frame"></iframe></div>';
     eval_js('var dim=document.viewport.getDimensions();var rc=$("rc_frame");rc.style.height=(Math.max(dim.height,document.documentElement.clientHeight)-130)+"px";');
 }
Exemplo n.º 2
0
 public function body()
 {
     $t = $this->pack_module('Base/Theme');
     //caption
     $box_module = ModuleManager::get_instance('/Base_Box|0');
     if ($box_module) {
         $active_module = $box_module->get_main_module();
     }
     if ($active_module && is_callable(array($active_module, 'caption'))) {
         $caption = $active_module->caption();
         if (Variable::get('show_module_indicator')) {
             $t->assign('text', $caption);
         } else {
             $t->assign('text', '');
         }
         $show_caption = Variable::get('show_caption_in_title');
         $maintenance_mode = MaintenanceMode::is_on() ? ' (Maintenance mode)' : '';
         $base_title = Variable::get('base_page_title') . $maintenance_mode;
         if ($show_caption || strlen($base_title) > 0) {
             if ($show_caption && strlen($base_title) > 0) {
                 $caption = $base_title . ' - ' . $caption;
             } elseif (strlen($base_title) > 0) {
                 $caption = $base_title;
             }
             eval_js('document.title=\'' . addslashes($caption) . '\'');
         }
     } else {
         $t->assign('text', '');
         eval_js('document.title=\'' . addslashes(Variable::get('base_page_title')) . '\'');
     }
     $t->display();
 }
Exemplo n.º 3
0
 public static function autohide_fields($field, $field_type, $hide_mapping)
 {
     $allowed_modes = array('hide', 'show');
     $groups = array();
     foreach ($hide_mapping as $map) {
         if (!isset($map['fields']) || !isset($map['values'])) {
             continue;
         }
         $map['mode'] = isset($map['mode']) ? $map['mode'] : reset($allowed_modes);
         if (!in_array($map['mode'], $allowed_modes)) {
             continue;
         }
         $map['fields'] = is_array($map['fields']) ? $map['fields'] : array($map['fields']);
         $map['fields'] = array_map(function ($f) {
             return "#{$f}, #_{$f}__data";
         }, $map['fields']);
         $map['fields'] = implode(', ', $map['fields']);
         $map['values'] = is_array($map['values']) ? $map['values'] : array($map['values']);
         $map['values'] = array_map(function ($v) {
             if (is_bool($v)) {
                 $v = intval($v);
             }
             return strval($v);
         }, $map['values']);
         $groups[] = $map;
     }
     if (empty($groups)) {
         return;
     }
     load_js('modules/Libs/QuickForm/autohide_fields.js');
     $js_groups = json_encode($groups);
     eval_js("\n\t\t\t\tjq(function(){\n\t\t\t\t\tvar hide_ctrl = jq('#{$field}');\n\t\t\t\t\tLibs_QuickForm__hide_groups['{$field}']={$js_groups};\n\t\t\t\t\thide_ctrl.change(Libs_QuickForm__autohide).trigger('change');\n\t\t\t\t});");
 }
Exemplo n.º 4
0
	function toHtml() {
		if(count($this->_cd)>1) {
			load_js('modules/Utils/CommonData/qf.js');
			$id=$this->getAttribute('id');
			if(!isset($id)) {
				$id = $this->getName();
				$this->updateAttributes(array('id'=>$id));
			}
			$val = $this->getValue();
			$val = $val[0];
			if($this->_flagFrozen) {
				eval_js('new Utils_CommonData_freeze(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\')');
				$html = '<span id="'.$id.'_label">&nbsp;</span>';
				$name = $this->getPrivateName();
				// Only use id attribute if doing single hidden input
				$html .= '<input' . $this->_getAttrString(array(
					     'type'  => 'hidden',
					     'name'  => $name,
					     'value' => $val,
					     'id'    => $id
					 )) . ' />';
				return $html;
			}
			eval_js('new Utils_CommonData(\''.Epesi::escapeJS($id,false).'\', \''.Epesi::escapeJS($val,false).'\', \''.Epesi::escapeJS(json_encode($this->_cd),false).'\', '.($this->_add_empty_fields?1:0).')');
		}
	        return parent::toHtml();
	}
Exemplo n.º 5
0
 function toHtml()
 {
     $str = "";
     if ($this->_flagFrozen) {
         $str .= $this->getFrozenHtml();
     } else {
         $value = $this->getAttribute('value');
         if (is_numeric($value)) {
             $value = date('Y-m-d', $value);
         }
         $id = $this->getAttribute('id');
         $name = $this->getAttribute('name');
         if ($value) {
             $this->setAttribute('value', Base_RegionalSettingsCommon::time2reg($value, false, true, false));
         }
         if (!isset($id)) {
             $id = 'datepicker_field_' . $name;
             $this->updateAttributes(array('id' => $id));
         }
         $ex_date = Base_RegionalSettingsCommon::time2reg(null, false, true, false);
         $date_format = Base_RegionalSettingsCommon::date_format();
         $this->setType('text');
         if (!$this->getAttribute('placeholder')) {
             $this->setAttribute('placeholder', __('Click to select date'));
         }
         $js = Utils_PopupCalendarCommon::create_href(md5($id), 'new Ajax.Request(\'modules/Utils/PopupCalendar/up.php\',' . '{method:\'post\', parameters:{date: __YEAR__+\'-\'+__MONTH__+\'-\'+__DAY__},' . 'onSuccess:function(t){e=$(\'' . Epesi::escapeJS($id, false) . '\');if(e) {e.value=t.responseText;jq(e).change();}}})', null, null, 'popup.clonePosition(\'' . $id . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $id . '\').getHeight()})', $value, $id);
         $str .= $this->_getTabs() . '<input ' . $js . ' ' . $this->_getAttrString($this->_attributes) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Example date: %s', array($ex_date)), false) . ' />';
         eval_js('Event.observe(\'' . $id . '\',\'keypress\',Utils_PopupCalendarDatePicker.validate.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))');
         eval_js('Event.observe(\'' . $id . '\',\'blur\',Utils_PopupCalendarDatePicker.validate_blur.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))');
     }
     return $str;
 }
Exemplo n.º 6
0
 public static function open($group, $params = array())
 {
     Libs_LeightboxCommon::open($group . '_prompt_leightbox');
     if (!empty($params)) {
         eval_js('f' . $group . '_set_params(\'' . implode('\',\'', $params) . '\');');
     }
 }
Exemplo n.º 7
0
 public function submit_admin($data)
 {
     Variable::set('default_theme', $data['theme']);
     Base_ThemeCommon::create_cache();
     Base_StatusBarCommon::message('Theme changed - reloading page');
     eval_js('setTimeout(\'document.location=\\\'index.php\\\'\',\'3000\')');
     return true;
 }
Exemplo n.º 8
0
 public static function add($keys, $func, $opts = array())
 {
     if (isset($_REQUEST['__location']) && self::$clean !== $_REQUEST['__location'] || self::$clean === false) {
         self::$clean = isset($_REQUEST['__location']) ? $_REQUEST['__location'] : true;
         eval_js('shortcut.remove_all();');
     }
     $js = 'shortcut.add("' . implode('+', $keys) . '",' . $func . ',{';
     $js .= '\'type\':\'' . (isset($opts['type']) ? $opts['type'] : 'keydown') . '\',';
     $js .= '\'propagate\':' . (isset($opts['propagate']) ? $opts['propagate'] : 'false') . ',';
     $js .= '\'disable_in_input\':' . (isset($opts['disable_in_input']) ? $opts['disable_in_input'] : 'false') . ',';
     $js .= '\'target\':' . (isset($opts['target']) ? $opts['target'] : 'document');
     $js .= '});';
     eval_js($js);
 }
Exemplo n.º 9
0
 public static function create_href($name, $function = '', $mode = null, $first_day_of_week = null, $pos_js = null, $default = null, $id = null)
 {
     Base_ThemeCommon::load_css('Utils_PopupCalendar');
     load_js('modules/Utils/PopupCalendar/js/main2.js');
     load_js('modules/Utils/PopupCalendar/datepicker.js');
     if (!isset($mode)) {
         $mode = 'day';
     }
     if (!isset($first_day_of_week)) {
         if (Acl::is_user()) {
             $first_day_of_week = self::get_first_day_of_week();
         } else {
             $first_day_of_week = 0;
         }
     } elseif (!is_numeric($first_day_of_week)) {
         trigger_error('Invalid first day of week', E_USER_ERROR);
     }
     $calendar = '<div id="Utils_PopupCalendar">' . '<table cellspacing="0" cellpadding="0" border="0"><tr><td id="datepicker_' . $name . '_header">error</td></tr>' . '<tr><td id="datepicker_' . $name . '_view">calendar not loaded</td></tr></table></div>';
     $entry = 'datepicker_' . $name . '_calendar';
     $butt = $id === null ? 'datepicker_' . $name . '_button' : $id;
     $smarty = Base_ThemeCommon::init_smarty();
     $smarty->assign('calendar', $calendar);
     ob_start();
     Base_ThemeCommon::display_smarty($smarty, 'Utils_PopupCalendar');
     $cal_out = ob_get_clean();
     print '<div id="' . $entry . '" class="utils_popupcalendar_popup" style="display:none;z-index:2050;width:1px;">' . $cal_out . '</div>';
     if (!isset($pos_js)) {
         $pos_js = 'popup.clonePosition(\'' . $butt . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $butt . '\').getHeight()});';
     }
     eval_js('if(Epesi.ie)$(\'' . $entry . '\').style.position="fixed";else $(\'' . $entry . '\').absolutize();');
     $ret = 'onClick="var popup=$(\'' . $entry . '\');' . $pos_js . ';$(\'' . $entry . '\').toggle()" href="javascript:void(0)" id="' . $butt . '"';
     $function .= ';$(\'' . $entry . '\').hide()';
     if ($default) {
         if (!is_numeric($default)) {
             $default = strtotime($default);
         }
         $args = date('Y', $default) . ',' . (date('n', $default) - 1) . ',' . date('d', $default);
     } else {
         $args = '';
     }
     $js = 'var datepicker_' . $name . ' = new Utils_PopupCalendar("' . Epesi::escapeJS($function, true, false) . '", \'' . $name . '\',\'' . $mode . '\',\'' . $first_day_of_week . '\',';
     $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December'));
     $days = array(__('Sun'), __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat'));
     $js .= 'new Array(\'' . implode('\',\'', $months) . '\'),';
     $js .= 'new Array(\'' . implode('\',\'', $days) . '\')';
     $js .= ');' . 'datepicker_' . $name . '.show(' . $args . ')';
     eval_js($js);
     //		eval_js('$(\''.$entry.'\').absolutize();');
     return $ret;
 }
Exemplo n.º 10
0
 public function body()
 {
     load_js('modules/Base/Help/js/canvasutilities.js');
     load_js('modules/Base/Help/js/main.js');
     eval_js('Helper.stop_tutorial_message = "' . Epesi::escapeJS('Tutorial was stopped') . '";');
     eval_js('setTimeout("Helper.get_all_help_hooks();", 500);');
     $theme = $this->init_module('Base_Theme');
     $theme->assign('href', 'href="javascript:void(0);" onclick="Helper.menu()"');
     $theme->assign('search_placeholder', __('Start typing to search help topics'));
     $theme->assign('label', __('Help'));
     Utils_ShortcutCommon::add(array('esc'), 'function(){Helper.escape();}');
     Utils_ShortcutCommon::add(array('f1'), 'function(){Helper.menu();}');
     $theme->display();
 }
Exemplo n.º 11
0
 protected function generate_query_builder()
 {
     $this->load_libs();
     $this->init_form();
     $this->options['filters'] = $this->filters;
     if ($this->plugins) {
         $this->options['plugins'] = $this->plugins;
     }
     $options_json = json_encode($this->options);
     $rules_json = $this->rules ? json_encode($this->rules) : json_encode(self::$empty_rules);
     $error_msg = __('Please fix query builder rules');
     $error_msg = json_encode($error_msg);
     eval_js("Utils_QueryBuilder('{$this->form->get_name()}', '{$this->form_element_id}', '{$this->instance_id}', {$options_json}, {$rules_json}, {$error_msg});");
 }
Exemplo n.º 12
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     Base_ThemeCommon::load_css('Applets_Weather');
     $opts['title'] = __('Weather');
     $rssfeed = $values['rssfeed'] . '?p=' . $values['zipcode'] . '&u=' . $values['temperature'];
     $name = md5($this->get_path() . $rssfeed);
     //div for updating
     print '<div id="Applets_Weather"><div id="rssfeed_' . $name . '"><span>' . __('Loading Weather...') . '</span></div></div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/Weather/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($rssfeed, false) . '\\\' , 2 , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($rssfeed, false) . '\' , 2 , 1)');
 }
Exemplo n.º 13
0
 public function body($skin, $size = 200)
 {
     print '<center' . ($skin == 'chunkySwissOnBlack' ? ' style="background-color:black; color:white;"' : '') . '>';
     $browser = stripos($_SERVER['HTTP_USER_AGENT'], 'msie');
     if ($browser !== false || $skin == 'flash') {
         $size *= 2;
         //clock taken from http://www.kirupa.com/developer/actionscript/clock.htm
         $clock = $this->get_module_dir() . 'clock.swf';
         print '<center><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="' . $size . '" width="' . $size . '">' . '<param name="movie" value="' . $clock . '">' . '<param name="quality" value="high">' . '<param name="wmode" value="transparent">' . '<param name="menu" value="false">' . '<embed src="' . $clock . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" height="' . $size . '" width="' . $size . '">' . '</object></center>';
     } else {
         load_js($this->get_module_dir() . 'coolclock.js');
         eval_js('CoolClock.findAndCreateClocks()');
         print '<canvas id="' . $this->get_path() . 'canvas" class="CoolClock:' . $skin . ':' . $size . '"></canvas>';
     }
     print '<BR>' . Base_RegionalSettingsCommon::time2reg(null, false) . '</center>';
 }
Exemplo n.º 14
0
 private function load_image_cache()
 {
     if (isset($_SESSION['client']['image_cache'])) {
         return;
     }
     $_SESSION['client']['image_cache'] = true;
     $imgs = array();
     if (Variable::get('preload_image_cache_selected') && file_exists($this->get_data_dir() . 'templates/' . self::$theme . '/__cache.images')) {
         $imgs = explode("\n", file_get_contents($this->get_data_dir() . 'templates/' . self::$theme . '/__cache.images'));
     }
     if (Variable::get('preload_image_cache_default') && self::$theme != 'default' && file_exists($this->get_data_dir() . 'templates/' . 'default/__cache.images')) {
         $imgs = array_merge($imgs, explode("\n", file_get_contents($this->get_data_dir() . 'templates/' . 'default/__cache.images')));
     }
     if (!empty($imgs)) {
         eval_js("var cache = document.createElement('div');" . "cache.style.display='none';" . "document.body.appendChild(cache);" . "var current_image = null;" . "var cache_pause = false;" . "var images_list = Array('" . implode("','", $imgs) . "');" . "cache_images = function() {" . "if(!cache_pause && (current_image==null || current_image.complete)) {" . "current_image = document.createElement('img');" . "current_image.src = images_list.shift();" . "cache.appendChild(current_image);" . "}" . "if(images_list.length)" . "setTimeout('cache_images()',500);" . "};" . "cache_images();", false);
     }
 }
Exemplo n.º 15
0
 public function applet($values, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     if (!$values['title']) {
         $values['title'] = __('RSS Feed');
     }
     $opts['title'] = $values['title'];
     $name = md5($this->get_path() . $values['rssfeed']);
     //div for updating
     print '<div id="rssfeed_' . $name . '" style="width: 270px; padding: 5px 5px 5px 20px;">' . __('Loading RSS...') . '</div>';
     //interval execution
     eval_js_once('var rssfeedcache = Array();' . 'rssfeedfunc = function(name,fee,num,cache){' . 'if(!$(\'rssfeed_\'+name)) return;' . 'if(cache && typeof rssfeedcache[name] != \'undefined\')' . '$(\'rssfeed_\'+name).innerHTML = rssfeedcache[name];' . 'else ' . 'new Ajax.Updater(\'rssfeed_\'+name,\'modules/Applets/RssFeed/refresh.php\',{' . 'method:\'post\',' . 'onComplete:function(r){rssfeedcache[name]=r.responseText},' . 'parameters:{feed:fee, number:num, cid: Epesi.client_id}});' . '}');
     eval_js_once('setInterval(\'rssfeedfunc(\\\'' . $name . '\\\',\\\'' . Epesi::escapeJS($values['rssfeed'], false) . '\\\' ,' . $values['rssnumber'] . ' , 0)\',1799993)');
     //29 minutes and 53 seconds
     //get rss now!
     eval_js('rssfeedfunc(\'' . $name . '\',\'' . Epesi::escapeJS($values['rssfeed'], false) . '\' ,' . $values['rssnumber'] . ' , 1)');
 }
Exemplo n.º 16
0
 public static function create($dest_id, array $prev_ids, $req_url, array $params = null, $default_val = null)
 {
     load_js('modules/Utils/ChainedSelect/cs.js');
     if (empty($prev_ids)) {
         trigger_error('Chained select can exists only with previous selects', E_USER_ERROR);
     }
     if ($params === null) {
         $params = array();
     }
     if ($default_val === null) {
         $default_val = '';
     }
     $js = 'var params = new Hash();';
     $_SESSION['client']['utils_chainedselect'][$dest_id] = $req_url;
     foreach ($params as $k => $v) {
         $js .= 'params.set("' . $k . '","' . $v . '");';
     }
     eval_js($js . 'new ChainedSelect("' . $dest_id . '",new Array("' . implode('","', $prev_ids) . '"),params, "' . $default_val . '")');
 }
Exemplo n.º 17
0
	function toHtml() {
		$str = "";
		if ($this->_flagFrozen) {
			$str .= $this->getFrozenHtml();
		} else {
			$id = $this->getAttribute('id');
			$name = $this->getAttribute('name');
			if(!isset($id)) {
				$id = 'currency_field_'.$name;
				$this->updateAttributes(array('id'=>$id));
			}
			
			$this->dec_digits = DB::GetOne('SELECT MAX(decimals) FROM utils_currency');

			$str .= $this->_getTabs() . '<div style="position: relative;">';

			$str .= $this->_getTabs() .
					'<div style="margin-right:45px;" class="currency_amount"><input ' . $this->_getAttrString($this->_attributes) . ' '.
					Utils_TooltipCommon::open_tag_attrs(__('Example value: %s',array('123'.Utils_CurrencyFieldCommon::get_decimal_point().implode('',range(4,3+$this->dec_digits)))), false ).
					' /></div>';

			$str .= $this->_getTabs() .
					'<div style="margin-right:5px; width:40px; position:absolute;top:0px;right:0px;"><select style="width:40px;" name="__'.str_replace(array('[',']'),'',$name).'__currency" id="__'.$id.'__currency">';

			$curs = DB::GetAll('SELECT id, symbol, active FROM utils_currency ORDER BY code');
			foreach ($curs as $v) {
				if ($v['id']!=$this->currency && !$v['active']) continue;
				$str .= '<option value="'.$v['id'].'"';
				if ($v['id']==$this->currency) $str .= ' selected="1"';
				$str .= '>'.$v['symbol'].'</option>';
			}
			$str .= '</select></div>';

			$str .= $this->_getTabs() . '</div>';

			load_js('modules/Utils/CurrencyField/currency.js');
			$curr_format = '-?([0-9]*)\\'.Utils_CurrencyFieldCommon::get_decimal_point().'?[0-9]{0,'.$this->dec_digits.'}';
			eval_js('Event.observe(\''.$id.'\',\'keypress\',Utils_CurrencyField.validate.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))');
			eval_js('Event.observe(\''.$id.'\',\'blur\',Utils_CurrencyField.validate_blur.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))');
		}
		return $str;
	} //end func toHtml
Exemplo n.º 18
0
 function toHtml()
 {
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     } else {
         $name = $this->getAttribute('name');
         $id = $this->getAttribute('id');
         if (!$id) {
             $id = '__autocomplete_id_' . $name;
             $this->setAttribute('id', $id);
         }
         $key = md5(serialize($this->callback) . $id);
         $_SESSION['client']['quickform']['autocomplete'][$key] = array('callback' => $this->callback, 'field' => $name, 'args' => $this->args);
         eval_js('var epesi_autocompleter = new Ajax.Autocompleter(\'' . $id . '\', \'' . $id . '_suggestbox\', \'modules/Libs/QuickForm/FieldTypes/autocomplete/autocomplete_update.php?' . http_build_query(array('cid' => CID, 'key' => $key)) . '\', {frequency: 0.6});');
         // TODO: not really neat, need to extend the function automatically
         if ($this->on_hide_js_code) {
             eval_js('epesi_autocompleter.hide=function(){' . 'this.stopIndicator();' . 'if (Element.getStyle(this.update, "display") != "none") {' . '    this.options.onHide(this.element, this.update);' . '}' . 'if (this.iefix) {' . '    Element.hide(this.iefix);' . '}' . $this->on_hide_js_code . '}');
         }
         return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />' . '<div id="' . $id . '_suggestbox" class="autocomplete">&nbsp;</div>';
     }
 }
Exemplo n.º 19
0
    public function body($file = null, $callback = null)
    {
        if (!isset($file)) {
            if (!isset($this->file)) {
                trigger_error('You have to specify file to download', E_USER_ERROR);
            }
            $file = $this->file;
        }
        if (!isset($callback)) {
            if (!isset($this->callback)) {
                trigger_error('You have to specify callback to call on download complete', E_USER_ERROR);
            }
            $callback = $this->callback;
        }
        if (isset($_REQUEST['download_complete_' . $this->get_path()])) {
            $did = $this->get_module_variable('download_id');
            $dd = $this->get_data_dir();
            if (!isset($did) || !file_exists($dd . $did . '.tmp')) {
                print 'Download error.';
            } else {
                DB::Execute('DELETE FROM utils_filedownload_files WHERE id=%d', array($did));
                $tf = $dd . $did . '.tmp';
                call_user_func($callback, $tf, basename($file));
                @unlink($tf);
            }
            return;
        }
        $path = $this->get_path();
        $id = $this->create_unique_key('stat');
        print '<div id="' . $id . '"></div>';
        eval_js_once('utils_filedownload_refresh = function(id,path){var stat=$(id);if(!stat || stat.innerHTML==\'Processing downloaded file\') return;' . 'new Ajax.Updater(id,\'' . $this->get_module_dir() . 'refresh.php\',{method:\'post\', parameters:{path: path}});' . 'setTimeout("utils_filedownload_refresh(\'"+id+"\',\'"+path+"\')",3000);}');
        eval_js_once('utils_filedownload_check_completed = function(id){stat=document.getElementById(id);' . 'if(stat && stat.innerHTML==\'Finished\'){
					stat.innerHTML=\'Processing downloaded file\';' . $this->create_href_js(array('download_complete_' . $this->get_path() => 1), __('Download finished'), 'queue') . '}setTimeout(\'utils_filedownload_check_completed("\'+id+\'")\',500);}');
        DB::Execute('INSERT INTO utils_filedownload_files(path,size) VALUES (%s,-1)', array($file));
        $this->set_module_variable('download_id', DB::Insert_ID('utils_downloadfile_files', 'id'));
        print '<iframe src="' . $this->get_module_dir() . 'download.php?' . http_build_query(array('client_id' => CID, 'path' => $path)) . '"  width=0 height=0 frameborder=0>';
        eval_js('utils_filedownload_refresh("' . $id . '","' . $path . '");utils_filedownload_check_completed("' . $id . '")');
    }
Exemplo n.º 20
0
 /**
  * For internal use only.
  */
 public function browse($name = '', $root = true)
 {
     if ($this->is_back()) {
         return false;
     }
     if (isset($_REQUEST['node_position'])) {
         list($node_id, $position) = $_REQUEST['node_position'];
         Utils_CommonDataCommon::change_node_position($node_id, $position);
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'browse' . md5($name));
     $gb->set_table_columns(array(array('name' => __('Position'), 'width' => 5, 'order' => 'position'), array('name' => __('Key'), 'width' => 20, 'order' => 'akey', 'search' => 1, 'quickjump' => 'akey'), array('name' => __('Value'), 'width' => 20, 'order' => 'value', 'search' => 1)));
     print '<h2>' . $name . '</h2><br>';
     $ret = Utils_CommonDataCommon::get_translated_array($name, true, true);
     foreach ($ret as $k => $v) {
         $gb_row = $gb->get_new_row();
         $gb_row->add_data($v['position'], $k, $v['value']);
         // ****** CommonData value translation
         $gb_row->add_action($this->create_callback_href(array($this, 'browse'), array($name . '/' . $k, false)), 'View');
         if (!$v['readonly']) {
             $gb_row->add_action($this->create_callback_href(array($this, 'edit'), array($name, $k)), 'Edit');
             $gb_row->add_action($this->create_confirm_callback_href(__('Delete array') . ' \'' . Epesi::escapeJS($name . '/' . $k, false) . '\'?', array('Utils_CommonData', 'remove_array'), array($name . '/' . $k)), 'Delete');
         }
         $node_id = $v['id'];
         $gb_row->add_action('class="move-handle"', 'Move', __('Drag to change node order'), 'move-up-down');
         $gb_row->set_attrs("node=\"{$node_id}\" class=\"sortable\"");
     }
     $gb->set_default_order(array(__('Position') => 'ASC'));
     //$this->display_module($gb);
     $this->display_module($gb, array(true), 'automatic_display');
     // sorting
     load_js($this->get_module_dir() . 'sort_nodes.js');
     $table_md5 = md5($gb->get_path());
     eval_js("utils_commondata_sort_nodes_init(\"{$table_md5}\")");
     Base_ActionBarCommon::add('settings', __('Reset Order By Key'), $this->create_callback_href(array('Utils_CommonDataCommon', 'reset_array_positions'), $name));
     Base_ActionBarCommon::add('add', __('Add array'), $this->create_callback_href(array($this, 'edit'), $name));
     if (!$root) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     }
     return true;
 }
Exemplo n.º 21
0
 public function body()
 {
     if (!Acl::is_user()) {
         return;
     }
     $th = $this->init_module('Base/Theme');
     eval_js_once('crm_filters_deactivate = function(){leightbox_deactivate(\'crm_filters\');}');
     $th->assign('my', '<a ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), 'my') . ' id="crm_filters_my">' . __('My records') . '</a>');
     eval_js('Event.observe(\'crm_filters_my\',\'click\', crm_filters_deactivate)');
     /*$th->assign('all','<a '.$this->create_callback_href(array('CRM_FiltersCommon','set_profile'),'all').' id="crm_filters_all">'.__('All records').'</a>');
     		eval_js('Event.observe(\'crm_filters_all\',\'click\', crm_filters_deactivate)');*/
     $th->assign('manage', '<a ' . $this->create_callback_href(array($this, 'manage_filters')) . ' id="crm_filters_manage">' . __('Manage presets') . '</a>');
     eval_js('Event.observe(\'crm_filters_manage\',\'click\', crm_filters_deactivate)');
     $ret = DB::Execute('SELECT id,name,description FROM crm_filters_group WHERE user_login_id=%d', array(Acl::get_user()));
     $filters = array();
     while ($row = $ret->FetchRow()) {
         $filters[] = array('title' => $row['name'], 'description' => '', 'open' => '<a ' . Utils_TooltipCommon::open_tag_attrs($row['description'], false) . ' ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), $row['id']) . ' id="crm_filters_' . $row['id'] . '">', 'close' => '</a>');
         eval_js('Event.observe(\'crm_filters_' . $row['id'] . '\',\'click\', crm_filters_deactivate)');
     }
     $th->assign('filters', $filters);
     $qf = $this->init_module('Libs/QuickForm');
     $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company');
     $recent_crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $recent_crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     if (Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')) {
         $recent_crits['!login'] = '';
     }
     $contacts = CRM_ContactsCommon::get_contacts($recent_crits, array(), array(), 15);
     $cont = array();
     foreach ($contacts as $v) {
         $cont[$v['id']] = call_user_func($fcallback, $v, true);
     }
     asort($cont);
     $crits = array();
     if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) {
         $crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company()));
     }
     $qf->addElement('autoselect', 'crm_filter_contact', __('Records of'), $cont, array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback, false)), $fcallback);
     if (isset($_SESSION['client']['filter_' . Acl::get_user()]['value'])) {
         $qf->setDefaults(array('crm_filter_contact' => explode(',', $_SESSION['client']['filter_' . Acl::get_user()]['value'])));
     }
     $qf->addElement('submit', 'submit', __('Show'), array('onclick' => 'crm_filters_deactivate()'));
     if ($qf->validate()) {
         $c = $qf->exportValue('crm_filter_contact');
         CRM_FiltersCommon::set_profile('c' . $c);
         location(array());
     }
     $th->assign('saved_filters', __('Saved Presets'));
     $qf->assign_theme('contacts', $th);
     //$th->assign('contacts',$qf->toHtml());
     ob_start();
     $th->display();
     $profiles_out = ob_get_clean();
     Libs_LeightboxCommon::display('crm_filters', $profiles_out, __('Perspective'), true);
     if (!isset($_SESSION['client']['filter_' . Acl::get_user()]['desc'])) {
         CRM_FiltersCommon::set_profile('my');
     }
     //Base_ActionBarCommon::add('folder',__('Filters'),'class="lbOn" rel="crm_filters"',$this->get_module_variable('profile_desc',__('My records')));
     if (isset($_REQUEST['__location'])) {
         $in_use = CRM_FiltersCommon::$in_use === $_REQUEST['__location'];
     } else {
         $in_use = CRM_FiltersCommon::$in_use;
     }
     print '<a class="lbOn' . ($in_use ? '' : ' disabled') . ' button" rel="crm_filters">' . __('Perspective') . ': ' . '<b>' . $_SESSION['client']['filter_' . Acl::get_user()]['desc'] . '</b><div class="filter_icon_img"></div></a>';
 }
Exemplo n.º 22
0
 public static function post_install_refresh_by_ajax()
 {
     $show_processing = "Epesi.procOn++;Epesi.updateIndicatorText('" . Epesi::escapeJS(__('Running post download procedures')) . "');Epesi.updateIndicator();";
     $success_text = Epesi::escapeJS(__("Success. Restart EPESI to ensure proper operation."));
     $failure_text = Epesi::escapeJS(__("Patch apply error. See patches log for more information (EPESI_DIR/data/logs/patches.log)"));
     $ajax_req = "new Ajax.Request('modules/Base/EpesiStore/runpatches.php'," . "{ method: 'post', " . "onComplete: function(t) {Epesi.procOn--;" . "if (t.responseText == '1') statusbar_message('<div class=\"message normal\">" . $success_text . "</div>');" . "else if (t.responseText == '0') alert('{$failure_text}');" . "else alert('Error: '+t.responseText);" . "Epesi.updateIndicator();" . "}});";
     eval_js($show_processing . $ajax_req);
 }
Exemplo n.º 23
0
	public static function hide_tooltip() {
		eval_js('Utils_Tooltip__hideTip()');
	}
Exemplo n.º 24
0
 public static function QFfield_recurrence_end(&$form, $field, $label, $mode, $default, $desc)
 {
     if ($mode == 'add' || $mode == 'edit') {
         $form->addElement('datepicker', $field, __('Recurrence End Date'), array('id' => $field));
         eval_js('recurrence_end_switch = function(arg){' . 'reds = $("recurrence_end");' . 'if (arg) reds.disabled="";' . 'else {' . 'reds.disabled="1";' . '$("recurrence_end").value="";' . '}' . '}');
         $form->addElement('checkbox', 'recurrence_end_checkbox', __('Recurrence end'), null, array('id' => 'recurrence_end_checkbox', 'onclick' => 'recurrence_end_switch(this.checked);'));
         eval_js('recurrence_end_switch(' . ($default ? '1' : '0') . ');');
         if ($mode == 'edit') {
             $form->setDefaults(array($field => $default));
             $form->setDefaults(array('recurrence_end_checkbox' => $default ? '1' : '0'));
         }
     } else {
         if (!$default) {
             $form->addElement('checkbox', $field, __('Recurrence End Date'));
         } else {
             $form->addElement('datepicker', $field, __('Recurrence End Date'));
             $form->setDefaults(array($field => $default));
         }
         if (Utils_RecordBrowser::$last_record['recurrence_type'] > 0) {
             $form->addElement('datepicker', 'recurrence_start_date', __('Recurrence Start Date'));
             $form->setDefaults(array('recurrence_start_date' => Utils_RecordBrowser::$last_record['date']));
         }
     }
 }
Exemplo n.º 25
0
 public function display_date_picker($datepicker_defaults = array(), $form = null, $show_dates = true)
 {
     if ($form === null) {
         $form = $this->init_module(Libs_QuickForm::module_name());
     }
     $theme = $this->init_module(Base_Theme::module_name());
     $minyear = date('Y', strtotime('-5 years'));
     $maxyear = date('Y', strtotime('+5 years'));
     if ($show_dates) {
         $display_stuff_js = 'document.getElementById(\'day_elements\').style.display=\'none\';document.getElementById(\'month_elements\').style.display=\'none\';document.getElementById(\'week_elements\').style.display=\'none\';document.getElementById(\'year_elements\').style.display=\'none\';document.getElementById(this.value+\'_elements\').style.display=\'block\';';
         $form->addElement('select', 'date_range_type', __('Display report'), array('day' => __('Days'), 'week' => __('Weeks'), 'month' => __('Months'), 'year' => __('Years')), array('onChange' => $display_stuff_js, 'onKeyUp' => $display_stuff_js));
         $form->addElement('datepicker', 'from_day', __('From Date'));
         $form->addElement('datepicker', 'to_day', __('To Date'));
         $form->addElement('date', 'from_week', __('From week'), array('format' => 'Y W', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_week', __('To week'), array('format' => 'Y W', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'from_month', __('From month'), array('format' => 'Y m', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_month', __('To month'), array('format' => 'Y m', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'from_year', __('From year'), array('format' => 'Y', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->addElement('date', 'to_year', __('To year'), array('format' => 'Y', 'language' => Base_LangCommon::get_lang_code(), 'minYear' => $minyear, 'maxYear' => $maxyear));
         $form->registerRule('check_dates', 'callback', 'check_dates', $this);
         $form->addRule(array('date_range_type', 'from_day', 'to_day', 'from_week', 'to_week', 'from_month', 'to_month', 'from_year', 'to_year'), __('\'From\' date must be earlier than \'To\' date'), 'check_dates');
     }
     if ($this->isset_module_variable('vals')) {
         $vals = $this->get_module_variable('vals');
         unset($vals['submited']);
         $form->setDefaults($vals);
     } else {
         foreach (array('week' => 3, 'day' => 13, 'month' => 5, 'year' => 5) as $v => $k) {
             $form->setDefaults(array('from_' . $v => date('Y-m-d H:i:s', strtotime('-' . $k . ' ' . $v))));
             $form->setDefaults(array('to_' . $v => date('Y-m-d H:i:s')));
         }
         $form->setDefaults(array('date_range_type' => 'month'));
         $form->setDefaults($datepicker_defaults);
     }
     $form->addElement('submit', 'submit', __('Show'));
     //		$failed = false;
     $other = $vals = $form->exportValues();
     $this->set_module_variable('vals', $vals);
     //		if ($vals['submited'] && !$form->validate()) {
     //			$this->date_range = 'error';
     //			$failed = true;
     //		}
     $theme->assign('show_dates', $show_dates);
     $form->assign_theme('form', $theme);
     $theme->display('date_picker');
     if ($show_dates) {
         $type = $vals['date_range_type'];
         foreach (array('week', 'day', 'year', 'month') as $v) {
             if ($v != $type) {
                 eval_js('document.getElementById(\'' . $v . '_elements\').style.display=\'none\';');
             }
         }
         //		if ($failed) {
         //			return array('type'=>'day', 'dates'=>array());
         //		}
         $this->date_range = array();
         foreach (array('date_range_type', 'from_' . $type, 'to_' . $type) as $v) {
             $this->date_range[$v] = $vals[$v];
         }
         $header = array();
         $start_p = $start = $this->get_date($type, $this->date_range['from_' . $type]);
         $end_p = $end = $this->get_date($type, $this->date_range['to_' . $type]);
         $header[] = $start;
         while (true) {
             switch ($type) {
                 case 'day':
                     $start = strtotime(date('Y-m-d 12:00:00', $start + 86400));
                     $start_format = 'Y-m-d';
                     $end_format = 'Y-m-d';
                     break;
                 case 'week':
                     $start = strtotime(date('Y-m-d 12:00:00', $start + 604800));
                     $start_format = 'Y-m-d';
                     $end_format = 'Y-m-d';
                     $fdow = Utils_PopupCalendarCommon::get_first_day_of_week();
                     $start_p -= (4 - $fdow) * 24 * 60 * 60;
                     $end_p += (2 + $fdow) * 24 * 60 * 60;
                     break;
                 case 'month':
                     $start = strtotime(date('Y-m-15 12:00:00', $start + 2592000));
                     $start_format = 'Y-m-01';
                     $end_format = 'Y-m-t';
                     break;
                 case 'year':
                     $start = strtotime(date('Y-06-15 12:00:00', $start + 2592000 * 12));
                     $start_format = 'Y-01-01';
                     $end_format = 'Y-12-31';
                     break;
             }
             if ($start > $end) {
                 break;
             }
             $header[] = $start;
         }
         return array('type' => $type, 'dates' => $header, 'start' => date($start_format, $start_p), 'end' => date($end_format, $end), 'other' => $other);
     } else {
         return array('other' => $other);
     }
 }
Exemplo n.º 26
0
	private function permissions_get_field_values($field, $in_depth=true) {
		static $all_fields = array();
		if (!isset($all_fields[$this->tab]))
			foreach ($this->table_rows as $k=>$v)
				$all_fields[$this->tab][$v['id']] = $k;
		$args = $this->table_rows[$all_fields[$this->tab][$field]];
		$arr = array(''=>'['.__('Empty').']');
		switch (true) {
			case $args['type']=='text' && $args['filter']:
				$arr_add = @DB::GetAssoc('SELECT f_'.$args['id'].', f_'.$args['id'].' FROM '.$this->tab.'_data_1 GROUP BY f_'.$args['id'].' ORDER BY count(*) DESC LIMIT 20');
				if($arr_add) $arr += $arr_add;
				break;
			case $args['commondata']:
				$array_id = is_array($args['param']) ? $args['param']['array_id'] : $args['ref_table'];
				if (strpos($array_id, '::')===false) 
					$arr = $arr + Utils_CommonDataCommon::get_translated_array($array_id, is_array($args['param'])?$args['param']['order_by_key']:false);
				break;
			case $this->tab=='contact' && $field=='login' ||
				 $this->tab=='rc_accounts' && $field=='epesi_user': // just a quickfix, better solution will be needed
				$arr = $arr + array('USER_ID'=>__('User Login'));
				break;
			case $args['type']=='date' || $args['type']=='timestamp':
				$arr = $arr + Utils_RecordBrowserCommon::$date_values;
				break;
			case ($args['type']=='multiselect' || $args['type']=='select') && (!isset($args['ref_table']) || !$args['ref_table']):
				$arr = $arr + array('USER'=>__('User Contact'));
				$arr = $arr + array('USER_COMPANY'=>__('User Company'));
				break;
			case $args['type']=='checkbox':
				$arr = array('1'=>__('Yes'),'0'=>__('No'));
				break;
			case ($args['type']=='select' || $args['type']=='multiselect') && isset($args['ref_table']):
				if ($args['ref_table']=='contact') $arr = $arr + array('USER'=>__('User Contact'));
				if ($args['ref_table']=='company') $arr = $arr + array('USER_COMPANY'=>__('User Company'));
				if (!$in_depth) continue;

				$last_tab = $this->tab;
                $tabs = explode(',', $args['ref_table']);
                if (count($tabs) != 1) break;
                $one_tab = reset($tabs);
                if ($one_tab != '__RECORDSETS__'
                        && Utils_RecordBrowserCommon::check_table_name($one_tab, false, false)) {
                    $this->tab = $one_tab;
                    $this->init();
                    if (!isset($all_fields[$this->tab]))
                        foreach ($this->table_rows as $k=>$v)
                            $all_fields[$this->tab][$v['id']] = $k;


                    foreach ($all_fields[$this->tab] as $k=>$v) {
                        if ($this->table_rows[$v]['type']=='calculated' || $this->table_rows[$v]['type']=='hidden') unset($all_fields[$this->tab][$k]);
                        else {
                            $arr2 = $this->permissions_get_field_values($k, false, $this->tab);
                            foreach ($arr2 as $k2=>$v2)
                                $arr2[$k2] = '"'.$k2.'":"'.$v2.'"';
                            eval_js('utils_recordbrowser__field_sub_values["'.$field.'__'.$k.'"] = {'.implode(',',$arr2).'};');
                        }
                    }
                    foreach ($all_fields[$this->tab] as $k=>$v) {
                        $arr[$k] = __(' records with %s set to ', array(_V($v)));
                    }
                }

				$this->tab = $last_tab;
				$this->init();
				break;
		}
		return $arr;
	}
Exemplo n.º 27
0
 public function recover_pass()
 {
     $form = $this->init_module('Libs/QuickForm', __('Processing request'));
     $form->addElement('header', null, __('Recover password'));
     $form->addElement('hidden', $this->create_unique_key('mail_recover_pass'), '1');
     $form->addElement('text', 'username', __('Username'));
     $form->addElement('text', 'mail', __('E-mail'));
     $ok_b =& HTML_QuickForm::createElement('submit', 'submit_button', __('OK'));
     $cancel_b =& HTML_QuickForm::createElement('button', 'cancel_button', __('Cancel'), $this->create_back_href());
     $form->addGroup(array($ok_b, $cancel_b), 'buttons');
     // require a username
     $form->addRule('username', __('A username must be between 3 and 32 chars'), 'rangelength', array(3, 32));
     // register and add a rule to check if a username and password is ok
     $form->registerRule('check_username', 'callback', 'check_username_mail_valid', 'Base_User_Login');
     $form->addRule('username', __('Username or e-mail invalid'), 'check_username', $form);
     $form->addRule('username', __('Field required'), 'required');
     //require valid e-mail address
     $form->addRule('mail', __('Field required'), 'required');
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     if ($form->validate()) {
         if ($form->process(array(&$this, 'submit_recover'))) {
             $this->theme->assign('message', __('Password reset instructions were sent.') . '<br><a ' . $this->create_back_href() . '>' . __('Login') . '</a>');
         }
     } else {
         $this->theme->assign('mode', 'recover_pass');
         $form->assign_theme('form', $this->theme);
         eval_js("focus_by_id('username')");
     }
     $this->theme->display();
 }
Exemplo n.º 28
0
 public static function drawLeightbox($prefix)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     $meetings = CRM_MeetingInstall::is_installed();
     $tasks = CRM_TasksInstall::is_installed();
     $phonecall = CRM_PhoneCallInstall::is_installed();
     self::check_location();
     if (!isset(self::$leightbox_ready[$prefix])) {
         self::$leightbox_ready[$prefix] = true;
         $theme = Base_ThemeCommon::init_smarty();
         eval_js_once($prefix . '_followups_deactivate = function(){leightbox_deactivate(\'' . $prefix . '_followups_leightbox\');}');
         if ($meetings) {
             $theme->assign('new_meeting', array('open' => '<a id="' . $prefix . '_new_meeting_button" onclick="' . $prefix . '_set_action(\'new_meeting\');' . $prefix . '_submit_form();">', 'text' => __('New Meeting'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_meeting_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($tasks) {
             $theme->assign('new_task', array('open' => '<a id="' . $prefix . '_new_task_button" onclick="' . $prefix . '_set_action(\'new_task\');' . $prefix . '_submit_form();">', 'text' => __('New Task'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_task_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         if ($phonecall) {
             $theme->assign('new_phonecall', array('open' => '<a id="' . $prefix . '_new_phonecall_button" onclick="' . $prefix . '_set_action(\'new_phonecall\');' . $prefix . '_submit_form();">', 'text' => __('New Phonecall'), 'close' => '</a>'));
             eval_js('Event.observe(\'' . $prefix . '_new_phonecall_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         }
         $theme->assign('just_close', array('open' => '<a id="' . $prefix . '_just_close_button" onclick="' . $prefix . '_set_action(\'none\');' . $prefix . '_submit_form();">', 'text' => __('Save'), 'close' => '</a>'));
         eval_js('Event.observe(\'' . $prefix . '_just_close_button\',\'click\', ' . $prefix . '_followups_deactivate)');
         eval_js($prefix . '_submit_form = function () {' . '$(\'' . $prefix . '_follow_up_form\').submited.value=1;Epesi.href($(\'' . $prefix . '_follow_up_form\').serialize(), \'processing...\');$(\'' . $prefix . '_follow_up_form\').submited.value=0;' . '}');
         eval_js($prefix . '_set_action = function (arg) {' . 'document.forms["' . $prefix . '_follow_up_form"].action.value = arg;' . '}');
         eval_js($prefix . '_set_id = function (id) {' . 'document.forms["' . $prefix . '_follow_up_form"].id.value = id;' . '$("' . $prefix . '_closecancel").value=3;' . '$("' . $prefix . '_note").value="";' . '}');
         $theme->assign('form_open', '<form id="' . $prefix . '_follow_up_form" name="' . $prefix . '_follow_up_form" method="POST">' . '<input type="hidden" name="submited" value="0" />' . '<input type="hidden" name="form_name" value="' . $prefix . '_follow_up_form" />' . '<input type="hidden" name="id" value="" />' . '<input type="hidden" name="action" value="" />');
         $status_select_options = '';
         $statuses = Utils_CommonDataCommon::get_translated_array('CRM/Status');
         foreach ($statuses as $key => $value) {
             $status_select_options .= '<option value="' . htmlspecialchars($key) . '"' . ($key == 3 ? ' selected="1"' : '') . '>' . htmlspecialchars($value) . '</option>';
         }
         $theme->assign('form_closecancel', array('label' => __('Status'), 'html' => '<select name="closecancel" id="' . $prefix . '_closecancel" value="0">' . $status_select_options . '</select>'));
         $theme->assign('form_note', array('label' => __('Note'), 'html' => '<textarea name="note" id="' . $prefix . '_note"></textarea>'));
         $theme->assign('form_close', '</form>');
         ob_start();
         Base_ThemeCommon::display_smarty($theme, 'CRM_Followup', 'leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($prefix . '_followups_leightbox', $profiles_out, __('Follow-up'));
     }
 }
Exemplo n.º 29
0
	private function output($applet = false) {
		Base_ThemeCommon::load_css($this->get_type(), 'tray');

		$tray_settings = Utils_TrayCommon::get_trays();

		$tray_def = array();
		$total_pending = 0;
		$displayed = 0;

		foreach ($tray_settings as $module=>$module_settings) {
			foreach ($module_settings as $tab=>$tab_settings) {
				if (!isset($tab_settings['__title__'])) continue;

				$tray = Utils_TrayCommon::get_tray($tab, $tab_settings);

				if (!isset($tray['__slots__']) || count($tray['__slots__'])==0) continue;

				$tray_id = $this->get_type().'__'.Utils_RecordBrowserCommon::get_field_id($tray['__title__']);

				$tray_def += array($tray_id =>array('__title__' => $tray['__title__'], '__weight__'=>isset($tray['__weight__'])?$tray['__weight__']:0));

				foreach ($tray['__slots__'] as $slot_id=>$slot_def) {
					$total_pending += $slot_def['__count__'];
					$displayed += $slot_def['__count__'];

					$tray_def[$tray_id]['__slots__'][$slot_id]['__weight__'] = isset($slot_def['__weight__'])? $slot_def['__weight__']: 0;

					$icon = $this->get_icon($slot_def['__count__']);
					$tray_count_width = ($slot_def['__count__']>99)? 'style="width:28px;"':'';

					$tip_text = __('Click to view %s items from %s<br><br>%d item(s)', array(_V($slot_def['__name__']),_V($tray['__title__']), $slot_def['__count__']));

					$tray_def[$tray_id]['__slots__'][$slot_id]['__html__'] = '<td><a '.$this->create_main_href($module, null, array($tab), null, array('tray_slot'=>$slot_id)).'><div class="Utils_Tray__slot">'.
					Utils_TooltipCommon::create('<img src="'.$icon.'">
					<div class="Utils_Tray__count" '.$tray_count_width.'>'.$slot_def['__count__'].'</div><div>'._V($slot_def['__name__']).'</div>',$tip_text).'</div></a></td>';				
				}
			}
		}

		Utils_TrayCommon::sort_trays($tray_def);

		$trays = array();
		$tray_slots_html = array();
		$current_tray = 0;

		$tray_cols = $applet? 2:$this->get_tray_cols();

		foreach ($tray_def as $tray_id=>$def) {
			$current_tray += 1;
			$current_row = max(array(round($current_tray/$tray_cols), 1));
			$current_col = $current_tray - $tray_cols*($current_row-1);

			if (isset($this->max_trays) && $this->max_trays != '__NULL__') {
				//allow only trays in applet mode as per setting
				if (count($trays) >= $this->max_trays) 	break;
			}

			if (self::get_tray_layout()=='checkered')
			$class = (($current_row+$current_col) % 2)?'Utils_Tray__group_even':'Utils_Tray__group_odd';
			else
			$class = 'Utils_Tray__group_even';

			$trays[] = array(
			'class' => $class,
			'col'=>$current_col,
			'title'=>_V($def['__title__']),
			'id'=>$tray_id);

			foreach ($def['__slots__'] as $slot) {
				$tray_slots_html[$tray_id][] = $slot['__html__'];

				if (isset($this->max_slots) && $this->max_slots != '__NULL__') {
					//allow slots in applet mode as per setting
					if (count($tray_slots_html[$tray_id]) >= $this->max_slots) continue 2;
				}
			}
		}

		eval_js(
		'function Utils_Tray__trays() {
			var trays = '.json_encode($tray_slots_html).';
			return trays;		
		}
		
		jq( document ).ready(function() {
			var resizeId;
			jq(window).resize(function(){
				clearTimeout(resizeId);
				resizeId = setTimeout(Utils_Tray__resize, 300);
			});	
			Utils_Tray__resize();	
		});');

		load_js($this->get_module_dir().'tray.js');

		$theme = $this->init_module('Base/Theme');
		$icon = Base_ThemeCommon::get_template_file($this->get_type(),'pile2.png');

		$theme->assign('main_page', !$applet);
		$theme->assign('caption', Utils_TrayCommon::caption());
		$theme->assign('icon', $icon);
		$theme->assign('trays', $trays);
		$theme->assign('tray_cols', $tray_cols);

		if ($total_pending!=$displayed) {
			print (__('Displaying %d of %d pending', array($displayed, $total_pending)));
		}

		$theme->display('tray');
	}
Exemplo n.º 30
0
 public static function init_overflow_div()
 {
     if (!isset($_SESSION['client']['utils_genericbrowser']['div_exists'])) {
         load_js('modules/Utils/GenericBrowser/js/table_overflow.js');
         eval_js('Utils_GenericBrowser__overflow_div();', false);
         $_SESSION['client']['utils_genericbrowser']['div_exists'] = true;
     }
     on_exit(array('Utils_GenericBrowserCommon', 'hide_overflow_div'), null, false);
 }