public static function get($id, $content, $header = '', $big = 0) { if (MOBILE_DEVICE) { return ''; } static $init = true; if ($init) { Base_ThemeCommon::load_css('Libs/Leightbox', 'default', false); load_js('modules/Libs/Leightbox/leightbox.js'); $init = false; } ob_start(); print '<div id="' . $id . '" big="1" class="leightbox">'; print '<input type="hidden" id="' . $id . '_bigsize" value="' . ($big ? 1 : 0) . '" />'; if ($big) { eval_js('s = $(\'' . $id . '\').style;' . 's.top = \'5%\';' . 's.left = \'5%\';' . 's.width = \'90%\';' . 's.height = \'90%\';' . 's.padding = \'0px\';'); } $smarty = Base_ThemeCommon::init_smarty(); $smarty->assign('close_href', 'href="javascript:leightbox_deactivate(\'' . $id . '\')"'); $smarty->assign('content', $content); $smarty->assign('header', $header); $smarty->assign('close_label', __('Close')); $smarty->assign('resize_label', __('Resize')); $smarty->assign('close_href', 'href="javascript:leightbox_deactivate(\'' . $id . '\')"'); Base_ThemeCommon::display_smarty($smarty, 'Libs_Leightbox'); print '</div>'; return ob_get_clean(); }
public function applet($values, &$opts) { //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments Base_ThemeCommon::load_css($this->get_type()); $opts['title'] = $values['title']; print '<div id="Applets_Note"><div class="note-' . $values['bcolor'] . '">'; print $values['text']; //print (str_replace("\n",'<br>',$values['text'])); print '</div></div>'; }
public function body($arg = null, $rb = null, $uid = null) { if (isset($arg) && isset($rb)) { $this->group = $rb->tab . '/' . $arg['id']; if (Utils_WatchdogCommon::get_category_id($rb->tab) !== null) { $this->watchdog_category = $rb->tab; $this->watchdog_id = $arg['id']; } $this->set_view_func(array('Utils_RecordBrowserCommon', 'create_default_linked_label'), array($rb->tab, $arg['id'])); } if (!isset($this->group) && !$uid) { trigger_error('Key not given to attachment module', E_USER_ERROR); } $_SESSION['client']['utils_attachment_group'] = $this->group; load_js('modules/Utils/Attachment/attachments.js'); Base_ThemeCommon::load_css('Utils_Attachment', 'browse'); $this->rb = $this->init_module(Utils_RecordBrowser::module_name(), 'utils_attachment', 'utils_attachment'); $defaults = array('permission' => Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission'), 'func' => serialize($this->func), 'args' => serialize($this->args)); $rb_cols = array(); $single_group = is_string($this->group) || count($this->group) == 1; if ($this->force_multiple) { $single_group = false; } if ($single_group) { $group = is_string($this->group) ? $this->group : reset($this->group); $defaults['local'] = $group; } else { // force attached to display $rb_cols['attached_to'] = true; $this->rb->set_button(false); } $this->rb->set_defaults($defaults); $this->rb->set_additional_actions_method(array($this, 'add_actions')); $this->rb->set_header_properties(array('sticky' => array('width' => 1, 'display' => false), 'attached_to' => array('width' => "16em"), 'edited_on' => array('width' => "12em"), 'title' => array('width' => "20em"))); if ($uid) { $this->rb->set_button(false); $this->rb->disable_actions(array('delete')); $this->display_module($this->rb, array(array(':Created_by' => $uid), $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } else { $crits = array(); if (!is_array($this->group)) { $this->group = array($this->group); } if (isset($_SESSION['attachment_copy']) && count($this->group) == 1 && $_SESSION['attachment_copy']['group'] != $this->group) { $this->rb->new_button(Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'link.png'), __('Paste'), Utils_TooltipCommon::open_tag_attrs($_SESSION['attachment_copy']['text']) . ' ' . $this->create_callback_href(array($this, 'paste'))); } if ($this->group) { $g = array_map(array('DB', 'qstr'), $this->group); $crits['id'] = DB::GetCol('SELECT attachment FROM utils_attachment_local WHERE local IN (' . implode(',', $g) . ')'); } else { $crits['id'] = 0; } $this->display_module($this->rb, array($crits, $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } }
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; }
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)'); }
public function construct($indicator = null, $action = '', $target = '', $on_submit = null, $form_name = null) { if (!$form_name) { $form_name = 'libs_qf_' . md5($this->get_path()); } if ($target == '' && $action != '') { $target = '_blank'; } if (!isset($on_submit)) { $on_submit = $this->get_submit_form_js_by_name($form_name, true, $indicator, '') . "return false;"; } $this->qf = new HTML_QuickForm($form_name, 'post', $action, $target, array('onSubmit' => $on_submit), true); $this->qf->addElement('hidden', 'submited', 0); $this->qf->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . __('denotes required field') . '</span>'); eval_js_once("set_qf_sub0 = function(fn){var x=\$(fn);if(x)x.submited.value=0}"); eval_js("set_qf_sub0('" . addslashes($form_name) . "')"); Base_ThemeCommon::load_css('Libs_QuickForm'); }
public function applet() { Base_ThemeCommon::load_css($this->get_type()); print '<div id="google">'; print ' <form method="get" action="http://www.google.com/search" target="_blank"> <fieldset style="border: 0px;"> <a href="http://www.google.com/search"><img src="' . Base_ThemeCommon::get_template_file('Applets/Google', 'Logo_40wht.gif') . '" alt="Google" style="border: 0px; width: 128px; height: 53px;" /></a> <center> <table> <tr> <td><input name="q" size="30" maxlength="255" value="" type="text" /></td> <td><input class="button" name="sa" value="' . __('Search') . '" type="submit" /></td> </tr> </table> </center> </fieldset> </form> '; print '</div>'; }
public function applet() { Base_ThemeCommon::load_css($this->get_type()); print '<div id="calc">'; print ' <center> <form name="Calc"> <table border="0"> <tr> <td> <input class="text" type="text" name="Input" Size="16"> <br> </td> </tr> <tr> <td> <input type="button" class="key" name="one" value=" 1 " OnClick="Calc.Input.value += \'1\'"> <input type="button" class="key" name="two" value=" 2 " OnCLick="Calc.Input.value += \'2\'"> <input type="button" class="key" name="three" value=" 3 " OnClick="Calc.Input.value += \'3\'"> <input type="button" class="key" name="plus" value=" + " OnClick="Calc.Input.value += \' + \'"><br> <input type="button" class="key" name="four" value=" 4 " OnClick="Calc.Input.value += \'4\'"> <input type="button" class="key" name="five" value=" 5 " OnCLick="Calc.Input.value += \'5\'"> <input type="button" class="key" name="six" value=" 6 " OnClick="Calc.Input.value += \'6\'"> <input type="button" class="key" name="minus" value=" - " OnClick="Calc.Input.value += \' - \'"><br> <input type="button" class="key" name="seven" value=" 7 " OnClick="Calc.Input.value += \'7\'"> <input type="button" class="key" name="eight" value=" 8 " OnCLick="Calc.Input.value += \'8\'"> <input type="button" class="key" name="nine" value=" 9 " OnClick="Calc.Input.value += \'9\'"> <input type="button" class="key" name="times" value=" x " OnClick="Calc.Input.value += \' * \'"><br> <input type="button" class="key" name="clear" value=" c " OnClick="Calc.Input.value = \'\'"> <input type="button" class="key" name="zero" value=" 0 " OnClick="Calc.Input.value += \'0\'"> <input type="button" class="key" name="DoIt" value=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)"> <input type="button" class="key" name="div" value=" / " OnClick="Calc.Input.value += \' / \'"> </td> </tr> </table> </form> </center> '; print '</div>'; }
public function edit_permissions($permission_name = null) { if ($this->is_back()) { Base_BoxCommon::pop_main(); } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); Base_ThemeCommon::load_css('Base_Acl', 'edit_permissions'); $gb = $this->init_module('Utils_GenericBrowser', 'acl_editor', 'acl_editor'); $gb->set_table_columns(array(array('name' => ' ', 'width' => 20))); $sql = 'SELECT id, name FROM base_acl_permission'; $args = array(); $perm_id = null; if ($permission_name) { $sql .= ' WHERE name=%s'; $args[] = $permission_name; $perm_id = DB::GetOne('SELECT id FROM base_acl_permission WHERE name=%s', array($permission_name)); } $sql .= ' ORDER BY name ASC'; $perms = DB::GetAssoc($sql, $args); Base_ActionBarCommon::add('add', __('Add rule'), $this->create_callback_href(array($this, 'edit_rule'), array(null, $perm_id))); foreach ($perms as $p_id => $p_name) { $gb_row = $gb->get_new_row(); $gb_row->add_data(array('value' => _V($p_name), 'class' => 'Base_Acl__permission', 'attrs' => 'colspan="2"')); $gb_row->no_actions(); $perms = DB::GetAssoc('SELECT id, id FROM base_acl_rules WHERE permission_id=%d', array($p_id)); foreach ($perms as $r_id) { $clearances = DB::GetAssoc('SELECT id, clearance FROM base_acl_rules_clearance WHERE rule_id=%d', array($r_id)); $gb_row = $gb->get_new_row(); $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_rule'), array($r_id)), 'delete', __('Delete Rule')); $gb_row->add_action($this->create_callback_href(array($this, 'edit_rule'), array($r_id, $p_id)), 'edit', __('Edit Rule')); $gb_row->add_data(Base_AclCommon::display_clearances($clearances)); } } $this->display_module($gb); eval_js('base_acl__initialized = false;'); }
public static function tooltip_leightbox_mode() { static $init = null; if (!isset($_REQUEST['__location'])) $loc = true; else $loc = $_REQUEST['__location']; if ($init!==$loc) { Base_ThemeCommon::load_css('Utils/Tooltip','leightbox_mode'); Libs_LeightboxCommon::display('tooltip_leightbox_mode', '<center><span id="tooltip_leightbox_mode_content" /></center>'); $init = $loc; } return Libs_LeightboxCommon::get_open_href('tooltip_leightbox_mode').' onmousedown="Utils_Tooltip__leightbox_mode(this)" '; }
public function body($pdf = false, $charts = false) { if ($this->is_back()) { return false; } if ($this->date_range == 'error') { return; } Base_ThemeCommon::load_css('Utils/RecordBrowser/Reports'); $this->pdf = $pdf || isset($_REQUEST['rb_reports_enable_pdf']); $this->csv = isset($_REQUEST['rb_reports_enable_csv']); unset($_REQUEST['rb_reports_enable_pdf']); $this->charts = $charts; if ($this->pdf) { $this->pdf_ob = $this->init_module(Libs_TCPDF::module_name(), 'L'); $this->pdf_ob->set_title($this->pdf_title); $this->pdf_ob->set_subject($this->pdf_subject); $this->pdf_ob->prepare_header(); $this->pdf_ob->AddPage(); } elseif (!$this->charts && !$this->csv) { Base_ActionBarCommon::add('report', __('Charts'), $this->create_callback_href(array($this, 'body'), array(false, true))); } if ($this->charts) { $this->make_charts(); } else { $this->make_table(); } if ($this->csv) { $this->set_module_variable('csv', $this->csv_ob); } if ($charts) { Base_ActionBarCommon::add('report', __('Table'), $this->create_back_href()); return true; } else { if (!$this->csv) { if ($this->pdf) { Base_ActionBarCommon::add('save', __('Download PDF'), 'target="_blank" href="' . $this->pdf_ob->get_href($this->pdf_filename) . '"'); self::$pdf_ready = 1; } elseif ($this->pdf_title != '' && self::$pdf_ready == 0) { if (count($this->gb_captions) < 20) { Base_ActionBarCommon::add('print', __('Create PDF'), $this->create_href(array('rb_reports_enable_pdf' => 1))); } else { Base_ActionBarCommon::add('print', __('Create PDF'), '', __('Too many columns to prepare printable version - please limit number of columns')); } } } if ($this->pdf_filename && !$this->pdf) { if ($this->csv) { Base_ActionBarCommon::add('save', __('Download CSV'), 'target="_blank" href="' . $this->get_module_dir() . '/csv.php?' . http_build_query(array('p' => $this->get_path(), 'id' => CID, 'filename' => $this->pdf_filename)) . '"'); } else { Base_ActionBarCommon::add('print', __('Create CSV'), $this->create_href(array('rb_reports_enable_csv' => 1))); } } } return false; }
public function manage_permissions() { $this->help('Permissions Editor','permissions'); $this->init(); $gb = $this->init_module('Utils/GenericBrowser','permissions_'.$this->tab, 'permissions_'.$this->tab); $gb->set_table_columns(array( array('name'=>__('Access type'), 'width'=>'100px'), array('name'=>__('Clearance required'), 'width'=>'30'), array('name'=>__('Applies to records'), 'width'=>'60'), array('name'=>__('Fields'), 'width'=>'100px') )); $ret = DB::Execute('SELECT * FROM '.$this->tab.'_access AS acs ORDER BY action DESC'); $tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_clearance AS acs'); $clearance = array(); foreach ($tmp as $t) $clearance[$t['rule_id']][] = $t['clearance']; $tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_fields AS acs'); $fields = array(); foreach ($tmp as $t) $fields[$t['rule_id']][] = $t['block_field']; $all_clearances = array_flip(Base_AclCommon::get_clearance(true)); $all_fields = array(); foreach ($this->table_rows as $v) $all_fields[$v['id']] = $v['name']; $actions = $this->get_permission_actions(); $rules = array(); while ($row = $ret->FetchRow()) { if (!isset($clearance[$row['id']])) $clearance[$row['id']] = array(); if (!isset($fields[$row['id']])) $fields[$row['id']] = array(); $action = $actions[$row['action']]; $crits = Utils_RecordBrowserCommon::parse_access_crits($row['crits'], true); $crits = Utils_RecordBrowserCommon::crits_to_words($this->tab, $crits, false); $crits_text = ''; foreach ($crits as $c) { switch ($c) { case 'and': $crits_text .= '<span class="joint">'.__('and').'</span><br>'; break; case 'or': $crits_text .= '<span class="joint">'.__('or').'</span> '; break; default: $crits_text .= $c.' '; } } foreach ($fields[$row['id']] as $k=>$v) if (isset($all_fields[$v])) $fields[$row['id']][$k] = $all_fields[$v]; else unset($fields[$row['id']][$k]); foreach ($clearance[$row['id']] as $k=>$v) if (isset($all_clearances[$v])) $clearance[$row['id']][$k] = $all_clearances[$v]; else unset($clearance[$row['id']][$k]); $c_all_fields = count($all_fields); $c_fields = count($fields[$row['id']]); $props = $c_all_fields?($c_all_fields-$c_fields)/$c_all_fields:0; $color = dechex(255-68*$props).dechex(187+68*$props).'BB'; $fields_value = ($c_all_fields-$c_fields).' / '.$c_all_fields; if ($props!=1) $fields_value = Utils_TooltipCommon::create($fields_value, '<b>'.__('Excluded fields').':</b><hr>'.implode('<br>',$fields[$row['id']]), false); $rules[$row['action']][$row['id']] = array( $action, '<span class="Utils_RecordBrowser__permissions_crits">'.implode(' <span class="joint">'.__('and').'</span><br>',$clearance[$row['id']]).'</span>', array('value'=>'<span class="Utils_RecordBrowser__permissions_crits">'.$crits_text.'</span>', 'overflow_box'=>false), array('style'=>'background-color:#'.$color, 'value'=>$fields_value) ); } foreach ($actions as $a=>$l) if (isset($rules[$a])) foreach ($rules[$a] as $id=>$vals) { $gb_row = $gb->get_new_row(); $gb_row->add_data_array($vals); if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')==2) { $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id)), 'edit', 'Edit'); $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id, true)), 'copy', __('Clone rule'), Base_ThemeCommon::get_template_file('Utils/Attachment','copy_small.png')); $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_permissions_rule'), array($id)), 'delete', 'Delete'); } } if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')==2) Base_ActionBarCommon::add('add',__('Add new rule'), $this->create_callback_href(array($this, 'edit_permissions_rule'), array(null))); Base_ThemeCommon::load_css('Utils_RecordBrowser', 'edit_permissions'); $this->display_module($gb); eval_js('utils_recordbrowser__crits_initialized = false;'); }
public function applet($conf, &$opts) { $opts['go'] = true; $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agendaX'); $columns = array(array('name' => __('Start'), 'order' => 'e.starts', 'width' => 25, 'wrapmode' => 'nowrap'), array('name' => __('Title'), 'order' => 'e.title', 'width' => 50)); $gb->set_table_columns($columns); $start = date('Y-m-d', time()); $end = date('Y-m-d', time() + $conf['days'] * 24 * 60 * 60); $gb->set_default_order(array(__('Start') => 'ASC')); CRM_Calendar_EventCommon::$filter = '(' . CRM_FiltersCommon::get_my_profile() . ')'; $data = array(); Base_ThemeCommon::load_css('CRM_Calendar', 'agenda'); $custom_events = DB::GetAssoc('SELECT id, handler_callback FROM crm_calendar_custom_events_handlers ORDER BY group_name'); $ret = array(); if (!empty($custom_events)) { $c = 0; foreach ($custom_events as $id => $cb) { if ($conf['events_handlers__' . $id]) { $cb = explode('::', $cb); if (!is_callable($cb)) { continue; } $add = call_user_func($cb, 'get_all', $start, $end, CRM_Calendar_EventCommon::$filter); foreach ($add as $v) { $ret[str_pad($v['start'], 16, '0', STR_PAD_LEFT) . '__' . $c] = $v; $c++; } } } } ksort($ret); foreach ($ret as $row) { if (isset($row['status']) && $row['status'] == 'closed') { continue; } if (!isset($row['view_action'])) { $ex = Utils_CalendarCommon::process_event($row); $view_action = '<a ' . $this->create_callback_href(array($this, 'view_event'), $row['id']) . '>'; $ev_id = explode('_', $row['id'], 2); $ev_id = $ev_id[0]; } else { $tmp = Utils_CalendarCommon::process_event($row); $ex = $row; $ex['start'] = $tmp['start']; $view_action = '<a ' . $row['view_action'] . '>'; } ////////////////////////// // left column $date = $ex['start']; /////////////////// // right column $title = Utils_TooltipCommon::create($row['title'], $row['custom_tooltip']); $day = isset($row['timeless']) && $row['timeless'] ? $row['timeless'] : Base_RegionalSettingsCommon::time2reg($row['start'], false, true, true, false); if ($day < date('Y-m-d')) { $class = 'past'; } elseif ($day == date('Y-m-d')) { $class = 'today'; } elseif ($day == date('Y-m-d', strtotime('+1 day'))) { $class = 'tomorrow'; } else { $class = 'other'; } $gb_row = $gb->get_new_row(); $gb_row->set_attrs('class="CRM_Calendar_applet__' . $class . '"'); $gb_row->add_data(array('value' => $date, 'order_value' => isset($row['timeless']) && $row['timeless'] ? strtotime($row['timeless']) : $row['start']), array('value' => $view_action . $title . '</a>')); } $this->display_module($gb, array(false), 'automatic_display'); }
public function year() { $theme = $this->pack_module('Base/Theme'); Base_ThemeCommon::load_css('Utils_Calendar', 'common'); $theme->assign('nextyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)+1).date('-m-d',$this->date)))); $theme->assign('nextyear_label',__('Next year')); $theme->assign('today_href', $this->create_unique_href(array('date'=>date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prevyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)-1).date('-m-d',$this->date)))); $theme->assign('prevyear_label', __('Previous year')); $theme->assign('info', __('Double click on cell to add event')); $link_text = $this->create_unique_href_js(array('date'=>'__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text,'year')); $day_headers = array(); $day = strtotime('Sun'); $day = strtotime('+'.Utils_PopupCalendarCommon::get_first_day_of_week().' days', $day); for ($i=0; $i<7; $i++) { $day_headers[] = __date('D', $day); $day = strtotime('+1 day', $day); } $theme->assign('month_view_label', __('Year calendar')); $year = array(); $ret = call_user_func(array($this->event_module.'Common','get_event_days'),date('Y-01-01',$this->date),(date('Y',$this->date)+1).'-01-01'); for ($i=1; $i<=12; $i++) { $date = strtotime(date('Y',$this->date).'-'.str_pad($i, 2, '0', STR_PAD_LEFT).'-15'); $month = $this->month_array($date, $ret); $year[] = array('month' => $month, 'month_link' => $this->create_unique_href(array('action'=>'switch','time'=>$date, 'tab'=>'Month')), 'month_label' => __date('F', $date), 'year_label' => date('Y', $date) ); } $theme->assign('year', $year); $theme->assign('day_headers', $day_headers); $navigation_bar_additions = ''; $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->display('year'); }
public function body() { if (!Base_AclCommon::check_permission('View Activity Report')) { return; } $rb_tabs = DB::GetAssoc('SELECT tab, caption FROM recordbrowser_table_properties ORDER BY caption'); foreach ($rb_tabs as $k => $v) { $rb_tabs[$k] = Utils_RecordBrowserCommon::get_caption($k); } $form = $this->init_module('Libs/QuickForm'); $users_count = DB::GetOne('SELECT COUNT(id) FROM user_login') > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete'); if ($users_count) { $crits = array('!login' => ''); $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company'); $form->addElement('autoselect', 'user', __('User'), array(), array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback)), $fcallback); } else { $users = DB::GetAssoc('SELECT id, id FROM user_login'); foreach ($users as $k => $u) { $users[$k] = Base_UserCommon::get_user_label($u, true); } asort($users); $users = array('' => '[' . __('All') . ']') + $users; $form->addElement('select', 'user', __('User'), $users); } $form->addElement('multiselect', 'recordsets', __('Record Type'), $rb_tabs); $form->addElement('checkbox', 'new', __('New record')); $form->addElement('checkbox', 'edit', __('Record edit')); $form->addElement('checkbox', 'delete_restore', __('Record Delete/restore')); $form->addElement('checkbox', 'file', __('Files')); $form->addElement('datepicker', 'start_date', __('Start Date')); $form->addElement('datepicker', 'end_date', __('End Date')); //$form->addElement('submit', 'submit', __('Show')); Base_ActionBarCommon::add('search', __('Show'), $form->get_submit_form_href()); $filters = $this->get_module_variable('filters', array('user' => '', 'new' => 1, 'edit' => 1, 'delete_restore' => 1, 'recordsets' => array_keys($rb_tabs), 'start_date' => date('Y-m-01'), 'end_date' => date('Y-m-d'))); if ($form->validate()) { $filters = $form->exportValues(); $this->set_module_variable('filters', $filters); } $form->setDefaults($filters); $theme = $this->init_module('Base/Theme'); $form->assign_theme('form', $theme); $theme->display(); $filters['recordsets'] = array_flip($filters['recordsets']); foreach ($rb_tabs as $k => $v) { if (!isset($filters['recordsets'][$k])) { unset($rb_tabs[$k]); } } $gb = $this->init_module('Utils/GenericBrowser', null, 'activity_report'); $gb->set_table_columns(array(array('name' => __('Date'), 'width' => 40), array('name' => __('User'), 'width' => 40), array('name' => __('Type'), 'width' => 40), array('name' => __('Label')), array('name' => __('Actions taken'), 'width' => 40))); $tables = array(); if ($users_count) { $filters['user'] = CRM_ContactsCommon::get_contact($filters['user']); $filters['user'] = $filters['user']['login']; } $af_where = array(); foreach ($rb_tabs as $k => $t) { $af_where[] = 'ual.local ' . DB::like() . ' ' . DB::Concat(DB::qstr($k . '/'), DB::qstr('%')); } $af_where = count($af_where) ? ' (' . implode(' OR ', $af_where) . ')' : 'TRUE '; $e_where = array(); $c_where = ''; if ($filters['user']) { $e_where[] = ' edited_by = ' . $filters['user']; $c_where = ' created_by = ' . $filters['user']; $af_where .= ' AND uaf.created_by = ' . $filters['user']; } if (isset($filters['edit'])) { if (!isset($filters['delete_restore'])) { $e_where[] = ' ehd.field!=' . DB::qstr('id'); } } else { if (isset($filters['delete_restore'])) { $e_where[] = ' ehd.field=' . DB::qstr('id'); } } if ($filters['start_date']) { $date = DB::qstr(date('Y-m-d', strtotime($filters['start_date']))); $af_where .= ' AND uaf.created_on >= ' . $date; $c_where .= ($c_where ? ' AND' : '') . ' created_on >= ' . $date; $e_where[] = ' edited_on >= ' . $date; } if ($filters['end_date']) { $date = DB::qstr(date('Y-m-d 23:59:59', strtotime($filters['end_date']))); $af_where .= ' AND uaf.created_on <= ' . $date; $c_where .= ($c_where ? ' AND' : '') . ' created_on <= ' . $date; $e_where[] = ' edited_on <= ' . $date; } if (!empty($e_where)) { $e_where = ' WHERE' . implode(' AND', $e_where); } else { $e_where = ''; } if ($c_where) { $c_where = ' WHERE' . $c_where; } $postgre_cast_type = DB::is_postgresql() ? '::varchar' : ''; // **** files **** if (isset($filters['file'])) { $tables[] = 'SELECT uaf.id AS id,uaf.created_on AS edited_on,uaf.created_by AS edited_by, ual.local AS r_id, ' . DB::qstr('') . ' AS tab, ' . DB::qstr('file') . ' AS action FROM utils_attachment_file uaf INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local ual ON ua.id=ual.attachment WHERE original!=' . DB::qstr('') . ' AND ' . $af_where; } // **** edit **** if (isset($filters['edit']) || isset($filters['delete_restore'])) { foreach ($rb_tabs as $k => $t) { $tables[] = 'SELECT id, edited_on, edited_by, ' . $k . '_id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('edit') . ' as action FROM ' . $k . '_edit_history eh LEFT JOIN ' . $k . '_edit_history_data ehd ON ehd.edit_id=eh.id' . $e_where; } } // **** create **** if (isset($filters['new'])) { foreach ($rb_tabs as $k => $t) { $tables[] = 'SELECT 0 AS id, created_on AS edited_on, created_by AS edited_by, id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('create') . ' as action FROM ' . $k . '_data_1' . $c_where; } } if (!empty($tables)) { $tables = implode(' UNION ', $tables); $limit = DB::GetOne('SELECT COUNT(*) FROM (' . $tables . ') AS tmp'); $limit = $gb->get_limit($limit); $ret = DB::SelectLimit('SELECT * FROM (' . $tables . ') AS tmp ORDER BY edited_on DESC', $limit['numrows'], $limit['offset']); while ($row = $ret->FetchRow()) { $user = Base_UserCommon::get_user_label($row['edited_by']); $action = ''; $link = ''; switch ($row['action']) { case 'edit': $details = DB::GetAssoc('SELECT field, old_value FROM ' . $row['tab'] . '_edit_history_data WHERE edit_id=%d', array($row['id'])); if (isset($details['id'])) { $action = $details['id'] == 'DELETED' ? __('Deleted') : __('Restored'); } else { $action = __('Edited'); $action = '<a ' . Utils_TooltipCommon::tooltip_leightbox_mode() . ' ' . Utils_TooltipCommon::ajax_open_tag_attrs(array('Utils_RecordBrowserCommon', 'get_edit_details_label'), array($row['tab'], $row['r_id'], $row['id']), 500) . '>' . $action . '</a>'; } $r_id = $row['r_id']; break; case 'create': $action = __('Created'); $r_id = $row['r_id']; break; case 'file': $action = __('Attachment') . ': '; $action .= $row['id'] == 0 ? __('New') : __('Updated'); $id = explode('/', $row['r_id']); $row['tab'] = $id[0]; $r_id = $id[1]; break; case 'note': $action = __('Note') . ': '; $action .= $row['id'] == 0 ? __('New') : __('Updated'); $id = explode('/', $row['r_id']); $row['tab'] = $id[0]; $r_id = $id[1]; break; } if (!Utils_RecordBrowserCommon::get_access($row['tab'], 'view', Utils_RecordBrowserCommon::get_record($row['tab'], $r_id))) { $link = __('Access restricted'); $action = strip_tags($action); } else { $link = Utils_TooltipCommon::create('<img src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'info.png') . '">', Utils_RecordBrowserCommon::get_html_record_info($row['tab'], $r_id), false); $link .= ' '; $link .= Utils_RecordBrowserCommon::create_default_linked_label($row['tab'], $r_id, false, false); } $gb->add_row(Base_RegionalSettingsCommon::time2reg($row['edited_on']), $user, $rb_tabs[$row['tab']], $link, $action); } } Base_ThemeCommon::load_css('Utils_RecordBrowser', 'changes_list'); $this->display_module($gb); }
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'); }
public function week() { $theme = $this->pack_module(Base_Theme::module_name()); Base_ThemeCommon::load_css('Utils_CalendarBusyReport', 'common'); $theme->assign('next7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date + 604800)))); $theme->assign('next7_label', __('Next week')); $theme->assign('next_href', $this->create_unique_href(array('shift_week_day' => 1))); $theme->assign('next_label', __('Next day')); $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prev_href', $this->create_unique_href(array('shift_week_day' => 0))); $theme->assign('prev_label', __('Previous day')); $theme->assign('prev7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date - 604800)))); $theme->assign('prev7_label', __('Previous week')); $link_text = $this->create_unique_href_js(array('week_date' => '__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $this->settings['first_day_of_week'])); $week_shift = $this->get_module_variable('week_shift', 0); $first_day_of_displayed_week = date('w', $this->date) - $this->settings['first_day_of_week']; if ($first_day_of_displayed_week < 0) { $first_day_of_displayed_week += 7; } $diff = $week_shift - $first_day_of_displayed_week; $dis_week_from = strtotime(($diff < 0 ? $diff : '+' . $diff) . ' days', $this->date); //headers $day_headers = array(); $today = Base_RegionalSettingsCommon::time2reg(null, false, true, true, false); if (date('m', $dis_week_from) != date('m', $dis_week_from + 518400)) { $second_span_width = date('d', $dis_week_from + 518400); $header_month = array('first_span' => array('colspan' => 7 - $second_span_width, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))), 'second_span' => array('colspan' => $second_span_width, 'month' => __date('M', $dis_week_from + 518400), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from + 518400), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Year')))); } else { $header_month = array('first_span' => array('colspan' => 7, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year')))); } for ($i = 0; $i < 7; $i++) { $that_day = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $day_headers[] = array('date' => date('d', $that_day) . ' ' . __date('D', $that_day), 'style' => (date('Y-m-d', $that_day) == $today ? 'today' : 'other') . (date('N', $that_day) >= 6 ? '_weekend' : ''), 'link' => $this->create_unique_href(array('action' => 'switch', 'time' => $that_day, 'tab' => 'Day'))); } $theme->assign('header_month', $header_month); $theme->assign('day_headers', $day_headers); $theme->assign('head_col_width', $this->settings['head_col_width']); $report = array(); //timeline and ids $time_ids = array(); $timeline = array(); for ($i = 0; $i < 7; $i++) { $time_ids[$i] = array(); $today_t_timeless = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $today_t = Base_RegionalSettingsCommon::reg2time(date('Y-m-d', $today_t_timeless)); $today_date = date('Y-m-d', $today_t_timeless); $timeline[$today_date] = $this->get_timeline($today_date); $prev = null; foreach ($timeline[$today_date] as &$v) { if ($v['time'] === false) { $time_ids[$i][] = false; } elseif (is_string($v['time'])) { $ii = $today_t_timeless . '_' . $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.$ii.'";'); // *DEBUG* } else { $ii = $today_t + $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.Base_RegionalSettingsCommon::time2reg($ii).'";'); // *DEBUG* } $prev = $v; } } $navigation_bar_additions = ''; if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) { $event_module_instance = $this->init_module($this->event_module); $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', ''); } $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->assign('time_ids', $time_ids); $theme->assign('timeline', reset($timeline)); $theme->assign('week_view_label', __('Week calendar')); //data //$dis_week_from = Base_RegionalSettingsCommon::reg2time($dis_week_from); //$dis_week_to = $dis_week_from+7*86400-1; $dis_week_to = date('Y-m-d', $dis_week_from + 7.5 * 86400); $dis_week_from = date('Y-m-d', $dis_week_from); $ret = $this->get_events($dis_week_from, $dis_week_to); $this->displayed_events = array('start' => $dis_week_from, 'end' => $dis_week_to, 'events' => $ret); $custom_keys = $this->settings['custom_rows']; $busy_labels = $this->settings['busy_labels']; foreach ($ret as $k => $ev) { if (!isset($ev['busy_label'])) { continue; } if (!is_array($ev['busy_label'])) { $ev['busy_label'] = array($ev['busy_label']); } ob_start(); Utils_CalendarBusyReportCommon::print_event($ev); $ev_print = ob_get_clean(); $day_start = explode(':', $this->settings['start_day']); $day_start = ($day_start[0] * 60 + $day_start[1]) * 60; if (!isset($ev['start'])) { $diff = 1; } else { $diff = ($day_start - ($ev['start'] - $today_t)) / 3600; } $dur = ceil($ev['duration'] / (strtotime($this->settings['interval']) - strtotime('0:00'))); if (isset($ev['timeless']) && $ev['timeless']) { if (!isset($ev['custom_row_key'])) { $ev['custom_row_key'] = 'timeless'; } $today_t_timeless = strtotime($ev['timeless']); if (isset($custom_keys[$ev['custom_row_key']])) { $dest_id = $today_t_timeless . '_' . $ev['custom_row_key']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } else { // trigger_error('Invalid custom_row_key:'.$ev['custom_row_key'],E_USER_ERROR); continue; } } else { $today_t = Base_RegionalSettingsCommon::time2reg($ev['start'], true, true, true, false); $today_date = date('Y-m-d', strtotime($today_t)); $today_t = strtotime(date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time($today_date))); $ev_start = $ev['start'] - $today_t; if (!isset($timeline[$today_date])) { continue; } $ct = count($timeline[$today_date]); for ($i = 1, $j = 2; $j < $ct; $i++, $j++) { while ($timeline[$today_date][$i]['time'] === false) { $i++; } while (($timeline[$today_date][$j]['time'] === false || $i >= $j) && $j < $ct) { $j++; } if ($j == $ct) { break; } if ($timeline[$today_date][$i]['time'] <= $ev_start && $ev_start < $timeline[$today_date][$j]['time']) { break; } } for ($k = $i; $k < $i + $dur; $k++) { $dest_id = $today_t + $timeline[$today_date][$k]['time']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } } } $theme->assign('report', $report); $theme->assign('busy_labels', $busy_labels); //ok, display $theme->display('week'); if ($this->custom_new_event_href_js !== null) { $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__', '__OBJECT__'); } else { $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => '__TIME__', 'timeless' => '__TIMELESS__', 'object' => '__OBJECT__')); } eval_js('Utils_CalendarBusyReport.activate_dclick(\'' . Epesi::escapeJS($jshref, false) . '\')'); }