Ejemplo n.º 1
0
 public static function get($id, $content, $header = '', $big = 0)
 {
     if (MOBILE_DEVICE) {
         return '';
     }
     static $init = true;
     if ($init) {
         Base_ThemeCommon::load_css(Libs_LeightboxCommon::module_name(), '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();
 }
Ejemplo n.º 2
0
	public function body(){
		$form = $this->init_module('Libs/QuickForm', null, 'RBpicker_test');
		$form->addElement('multiselect', 'test', 'Test', array(1=>0, 4=>1, 7=>2, 8=>3));
		$form->addElement('submit', 'submit', 'Submit');
		$form->display();
		if ($form->validate()) print_r($form->exportValues());

		$rb1 = $this->init_module('Utils/RecordBrowser/RecordPicker');
		$this->display_module($rb1, array('contact' ,'test',array('Tests_LeightboxCommon','TEST'), array('company_name'=>1), array('country'=>true)));
		print($rb1->create_open_link('Click here!'));

		Libs_LeightboxCommon::display('leightbox1','<h1>Leightbox</h1>'.
							'ble ble ble','Test header');

		print('<hr><a '.Libs_LeightboxCommon::get_open_href('leightbox1').'>leightbox container</a>
			</div>');
		
		//------------------------------ print out src
		print('<hr><b>Install</b><br>');
		$this->pack_module('Utils/CatFile','modules/Tests/Leightbox/LeightboxInstall.php');
		print('<hr><b>Main</b><br>');
		$this->pack_module('Utils/CatFile','modules/Tests/Leightbox/Leightbox_0.php');
		print('<hr><b>Common</b><br>');
		$this->pack_module('Utils/CatFile','modules/Tests/Leightbox/LeightboxCommon_0.php');
		
	}
Ejemplo n.º 3
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) . '\');');
     }
 }
Ejemplo n.º 4
0
 public function body($tab, $element, $format = array(), $crits = array(), $cols = array(), $order = array(), $filters = array(), $filters_defaults = array(), $custom_filters = array())
 {
     Module::$disable_confirm_leave = true;
     $rb = $this->init_module(Utils_RecordBrowser::module_name(), $tab, $tab . '_picker');
     $rb->adv_search = true;
     $rb->set_filters_defaults($filters_defaults);
     $rb->disable_actions();
     foreach ($custom_filters as $field => $arr) {
         $rb->set_custom_filter($field, $arr);
     }
     $this->element = $element;
     Libs_LeightboxCommon::display('rpicker_leightbox_' . $element, $this->get_html_of_module($rb, array($element, $format, $crits, $cols, $order, $filters), 'recordpicker'), __('Select'), true);
     Module::$disable_confirm_leave = false;
 }
Ejemplo n.º 5
0
 public static function create_new_record_href($tab, $def, $id = 'none', $check_defaults = true, $multiple_defaults = false)
 {
     if ($multiple_defaults) {
         static $done = false;
         if ($done) {
             return Libs_LeightboxCommon::get_open_href('actionbar_rb_new_record');
         }
         eval_js_once('actionbar_rb_new_record_deactivate = function(){leightbox_deactivate(\'actionbar_rb_new_record\');}');
         $th = Base_ThemeCommon::init_smarty();
         $cds = array();
         foreach ($def as $k => $v) {
             $cds[] = array('label' => _V($k), 'open' => '<a OnClick="actionbar_rb_new_record_deactivate();' . Module::create_href_js(self::get_new_record_href($tab, $v['defaults'], $id, $check_defaults)) . '">', 'icon' => $v['icon'], 'close' => '</a>');
         }
         $th->assign('custom_defaults', $cds);
         ob_start();
         Base_ThemeCommon::display_smarty($th, 'Utils_RecordBrowser', 'new_record_leightbox');
         $panel = ob_get_clean();
         Libs_LeightboxCommon::display('actionbar_rb_new_record', $panel, __('New record'));
         $done = true;
         return Libs_LeightboxCommon::get_open_href('actionbar_rb_new_record');
     } else {
         return Module::create_href(self::get_new_record_href($tab, $def, $id, $check_defaults));
     }
 }
Ejemplo n.º 6
0
    public function view_entry($mode='view', $id = null, $defaults = array(), $show_actions=true) {
		Base_HelpCommon::screen_name('rb_'.$mode.'_'.$this->tab);
        if (isset($_SESSION['client']['recordbrowser']['admin_access'])) Utils_RecordBrowserCommon::$admin_access = true;
        self::$mode = $mode;
        if ($this->navigation_executed) {
            $this->navigation_executed = false;
            return true;
        }
        if ($this->check_for_jump()) return;
        $theme = $this->init_module('Base/Theme');
        if ($this->isset_module_variable('id')) {
            $id = $this->get_module_variable('id');
            $this->unset_module_variable('id');
        }
        self::$browsed_records = null;

        Utils_RecordBrowserCommon::$cols_order = array();
        $js = ($mode!='view');
        $time = microtime(true);
        if ($this->is_back()) {
            self::$clone_result = 'canceled';
            return $this->back();
        }

        $this->init();
		if (is_numeric($id)) {
	                $id = intVal($id);
			self::$last_record = $this->record = Utils_RecordBrowserCommon::get_record($this->tab, $id, $mode!=='edit');
		} else {
			self::$last_record = $this->record = $id;
			$id = intVal($this->record['id']);
		}
		if ($id===0) $id = null;
        if ($id!==null && is_numeric($id)) Utils_WatchdogCommon::notified($this->tab,$id);

        if($mode=='add') {
            foreach ($defaults as $k=>$v)
                $this->custom_defaults[$k] = $v;
            foreach($this->table_rows as $field => $args)
                if (!isset($this->custom_defaults[$args['id']]))
					$this->custom_defaults[$args['id']] = $args['type'] == 'multiselect' ? array() : '';
			$this->custom_defaults['created_by'] = Acl::get_user();
		}

        $access = $this->get_access($mode=='history'?'view':$mode, isset($this->record)?$this->record:$this->custom_defaults);
        if ($mode=='edit' || $mode=='add')
            $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults);
        else
            $this->view_fields_permission = $access;

        if ($mode!='add' && (!$access || $this->record==null)) {
            if (Base_AclCommon::i_am_admin()) {
                Utils_RecordBrowserCommon::$admin_access = true;
                $access = $this->get_access($mode, isset($this->record)?$this->record:$this->custom_defaults);
                if ($mode=='edit' || $mode=='add')
                    $this->view_fields_permission = $this->get_access('view', isset($this->record)?$this->record:$this->custom_defaults);
                else
                    $this->view_fields_permission = $access;
            } else {
                print(__('You don\'t have permission to view this record.'));
                if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) {
                    Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
                    //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
                }
                return true;
            }
        }
        if ($mode=='add' && !$access) {
			print(__('You don\'t have permission to perform this action.'));
			if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back']))) {
				Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
				//Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
			}
			return true;
		}

        if($mode == 'add' || $mode == 'edit') {
            $theme -> assign('click2fill', '<div id="c2fBox"></div>');
            load_js('modules/Utils/RecordBrowser/click2fill.js');
            eval_js('initc2f("'.__('Scan/Edit').'","'.__('Paste data here with Ctrl-v, click button below, then click on separated words in specific order and click in text field where you want put those words. They will replace text in that field.').'")');
            Base_ActionBarCommon::add('clone', __('Click 2 Fill'), 'href="javascript:void(0)" onclick="c2f()"');
        }

//        if ($mode!='add' && !$this->record[':active'] && !Base_AclCommon::i_am_admin()) return $this->back();

        $tb = $this->init_module('Utils/TabbedBrowser', null, 'recordbrowser_addons');
		if ($mode=='history') $tb->set_inline_display();
        self::$tab_param = $tb->get_path();

        $form = $this->init_module('Libs/QuickForm',null, $mode);
        if(Base_User_SettingsCommon::get($this->get_type(), 'confirm_leave') && ($mode == 'add' || $mode == 'edit'))
        	$form->set_confirm_leave_page();
        
        $this->form = $form;

        if($mode!='add')
            Utils_RecordBrowserCommon::add_recent_entry($this->tab, Acl::get_user(),$id);

		$dp = Utils_RecordBrowserCommon::record_processing($this->tab, $mode!='add'?$this->record:$this->custom_defaults, ($mode=='view' || $mode=='history')?'view':$mode.'ing');
		if($dp===false) return false;
		if (is_array($dp))
			$defaults = $this->custom_defaults = self::$last_record = $this->record = $dp;

        if (self::$last_record===null) self::$last_record = $defaults;
        if($mode=='add')
            $form->setDefaults($defaults);

        switch ($mode) {
            case 'add':     $this->action = _M('New record'); break;
            case 'edit':    $this->action = _M('Edit record'); break;
            case 'view':    $this->action = _M('View record'); break;
            case 'history':    $this->action = _M('Record history view'); break;
        }

        $this->prepare_view_entry_details($this->record, $mode=='history'?'view':$mode, $id, $form);

        if ($mode==='edit' || $mode==='add')
            foreach($this->table_rows as $field => $args) {
                if (!$access[$args['id']])
                    $form->freeze($args['id']);
            }
        if ($form->exportValue('submited') && $form->validate()) {
            $values = $form->exportValues();
			
			foreach ($defaults as $k=>$v) {
				if (!isset($values[$k]) && isset($this->view_fields_permission[$k]) && !$this->view_fields_permission[$k]) $values[$k] = $v;
				if (isset($access[$k]) && !$access[$k]) $values[$k] = $v;
			}
            foreach ($this->table_rows as $v) {
                if ($v['type']=='checkbox' && !isset($values[$v['id']])) $values[$v['id']]=0;
            }
            $values['id'] = $id;
            foreach ($this->custom_defaults as $k=>$v)
                if (!isset($values[$k])) $values[$k] = $v;
            if ($mode=='add') {
                $id = Utils_RecordBrowserCommon::new_record($this->tab, $values);
                self::$clone_result = $id;
                self::$clone_tab = $this->tab;
                return $this->back();
            }
            $time_from = date('Y-m-d H:i:s', $this->get_module_variable('edit_start_time'));
            $ret = DB::Execute('SELECT * FROM '.$this->tab.'_edit_history WHERE edited_on>=%T AND edited_on<=%T AND '.$this->tab.'_id=%d',array($time_from, date('Y-m-d H:i:s'), $id));
            if ($ret->EOF) {
                $this->update_record($id,$values);
                return $this->back();
            }
            $this->dirty_read_changes($id, $time_from);
        }
		$form->add_error_closing_buttons();

        if (($mode=='edit' || $mode=='add') && $show_actions!==false) {
            Utils_ShortcutCommon::add(array('Ctrl','S'), 'function(){'.$form->get_submit_form_js().'}');
        }
        if ($mode=='edit') {
            $this->set_module_variable('edit_start_time',$time);
        }

        if ($show_actions!==false) {
            if ($mode=='view') {
                if ($this->get_access('edit',$this->record)) {
                    Base_ActionBarCommon::add('edit', __('Edit'), $this->create_callback_href(array($this,'navigate'), array('view_entry','edit',$id)));
                    Utils_ShortcutCommon::add(array('Ctrl','E'), 'function(){'.$this->create_callback_href_js(array($this,'navigate'), array('view_entry','edit',$id)).'}');
                }
                if ($this->get_access('delete',$this->record)) {
                    Base_ActionBarCommon::add('delete', __('Delete'), $this->create_confirm_callback_href(__('Are you sure you want to delete this record?'),array($this,'delete_record'),array($id)));
                }
                if ($this->get_access('add',$this->record)) {
                    Base_ActionBarCommon::add('clone',__('Clone'), $this->create_confirm_callback_href(__('You are about to create a copy of this record. Do you want to continue?'),array($this,'clone_record'),array($id)));
                }
                /** @var Base_Print_Printer $printer */
                $printer = Utils_RecordBrowserCommon::get_printer($this->tab);
                if ($printer) {
                    Base_ActionBarCommon::add('print', __('Print'), $printer->get_href(array('tab' => $this->tab, 'record_id' => $this->record['id'])));
                }
                if ($show_actions===true || (is_array($show_actions) && (!isset($show_actions['back']) || $show_actions['back'])))
                    Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
            } elseif($mode!='history') {
                Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
                Base_ActionBarCommon::add('delete', __('Cancel'), $this->create_back_href());
            }
            //Utils_ShortcutCommon::add(array('esc'), 'function(){'.$this->create_back_href_js().'}');
        }

        if ($mode!='add') {
            $theme -> assign('info_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(Utils_RecordBrowserCommon::get_html_record_info($this->tab, $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','info.png').'" /></a>');
            $row_data= array();

			if ($mode!='history') {
				if ($this->favorites)
					$theme -> assign('fav_tooltip', Utils_RecordBrowserCommon::get_fav_button($this->tab, $id));
				if ($this->watchdog)
					$theme -> assign('subscription_tooltip', Utils_WatchdogCommon::get_change_subscription_icon($this->tab, $id));
				if ($this->full_history) {
					$info = Utils_RecordBrowserCommon::get_record_info($this->tab, $id);
					if ($info['edited_on']===null) $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('This record was never edited')).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history_inactive.png').'" /></a>');
					else $theme -> assign('history_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to view edit history of currently displayed record')).' '.$this->create_callback_href(array($this,'navigate'), array('view_edit_history', $id)).'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','history.png').'" /></a>');
				}
				if ($this->clipboard_pattern) {
					$theme -> assign('clipboard_tooltip', '<a '.Utils_TooltipCommon::open_tag_attrs(__('Click to export values to copy')).' '.Libs_LeightboxCommon::get_open_href('clipboard').'><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','clipboard.png').'" /></a>');
					$text = $this->clipboard_pattern;
					$record = Utils_RecordBrowserCommon::get_record($this->tab, $id);
					/* for every field name store its value */
					$data = array();
					foreach($this->table_rows as $val) {
						$fval = Utils_RecordBrowserCommon::get_val($this->tab, $val['id'], $record, true);
						if(strlen($fval)) $data[$val['id']] = $fval;
					}
					/* some complicate preg match to find every occurence
					 * of %{ .. {f_name} .. } pattern
					 */
                    if (preg_match_all('/%\{(([^%\}\{]*?\{[^%\}\{]+?\}[^%\}\{]*?)+?)\}/', $text, $match)) { // match for all patterns %{...{..}...}
                        foreach ($match[0] as $k => $matched_string) {
                            $text_replace = $match[1][$k];
                            $changed = false;
                            while(preg_match('/\{(.+?)\}/', $text_replace, $second_match)) { // match for keys in braces {key}
                                $replace_value = '';
                                if(array_key_exists($second_match[1], $data)) {
                                    $replace_value = $data[$second_match[1]];
                                    $changed = true;
                                }
                                $text_replace = str_replace($second_match[0], $replace_value, $text_replace);
                            }
                            if(! $changed ) $text_replace = '';
                            $text = str_replace($matched_string, $text_replace, $text);
                        }
                    }
					load_js("modules/Utils/RecordBrowser/selecttext.js");
					/* remove all php new lines, replace <br>|<br/> to new lines and quote all special chars */
					$ftext = htmlspecialchars(preg_replace('#<[bB][rR]/?>#', "\n", str_replace("\n", '', $text)));
					$flash_copy = '<object width="60" height="20">'.
								'<param name="FlashVars" value="txtToCopy='.$ftext.'">'.
								'<param name="movie" value="'.$this->get_module_dir().'copyButton.swf">'.
								'<embed src="'.$this->get_module_dir().'copyButton.swf" flashvars="txtToCopy='.$ftext.'" width="60" height="20">'.
								'</embed>'.
								'</object>';
					$text = '<h3>'.__('Click Copy under the box or move mouse over box below to select text and hit Ctrl-c to copy it.').'</h3><div onmouseover="fnSelect(this)" style="border: 1px solid gray; margin: 15px; padding: 20px;">'.$text.'</div>'.$flash_copy;

					Libs_LeightboxCommon::display('clipboard',$text,__('Copy'));
				}
			}
        }

		if ($mode=='view') {
			$dp = Utils_RecordBrowserCommon::record_processing($this->tab, $this->record, 'display');
			if ($dp && is_array($dp))
				foreach ($dp as $k=>$v)
					$theme->assign($k, $v);
		}

        if ($mode=='view' || $mode=='history') $form->freeze();
        $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
        $form->accept($renderer);
        $data = $renderer->toArray();

        print($data['javascript'].'<form '.$data['attributes'].'>'.$data['hidden']."\n");

        $last_page = DB::GetOne('SELECT MIN(position) FROM '.$this->tab.'_field WHERE type = \'page_split\' AND field != \'General\'');
		if (!$last_page) $last_page = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field')+1;
        $label = DB::GetRow('SELECT field, param FROM '.$this->tab.'_field WHERE position=%s', array($last_page));
		if ($label) {
			$cols = $label['param'];
			$label = $label['field'];
		} else $cols = false;

        $this->view_entry_details(1, $last_page, $data, $theme, true);
        $ret = DB::Execute('SELECT position, field, param FROM '.$this->tab.'_field WHERE type = \'page_split\' AND position > %d ORDER BY position', array($last_page));
        $row = true;
        if ($mode=='view')
            print("</form>\n");
        $tab_counter=-1;
		$additional_tabs = 0;
		$default_tab = null;
        while ($row) {
            $row = $ret->FetchRow();
            if ($row) $pos = $row['position'];
            else $pos = DB::GetOne('SELECT MAX(position) FROM '.$this->tab.'_field WHERE active=1')+1;

            $valid_page = false;
			$hide_page = ($mode=='view' && Base_User_SettingsCommon::get('Utils/RecordBrowser','hide_empty'));
            foreach($this->table_rows as $field => $args) {
                if (!isset($data[$args['id']]) || $data[$args['id']]['type']=='hidden') continue;
                if ($args['position'] >= $last_page && ($pos+1 == -1 || $args['position'] < $pos+1)) {
                    $valid_page = true;
					if ($hide_page && !$this->field_is_empty($this->record, $args['id'])) $hide_page = false;
                    break;
                }
            }
            if ($valid_page && $pos - $last_page>1 && !isset($this->hide_tab[$label])) {
				$tb->set_tab(_V($label),array($this,'view_entry_details'), array($last_page, $pos+1, $data, null, false, $cols, _V($label)), $js); // TRSL
				if ($hide_page) {
					eval_js('$("'.$tb->get_tab_id(_V($label)).'").style.display="none";');
					if ($default_tab===($tab_counter+1) || $tb->get_tab()==($tab_counter+1)) $default_tab = $tab_counter+2;
				} else
					$additional_tabs++;
			}
            $cols = $row['param'];
            $last_page = $pos;
            if ($row) $label = $row['field'];
            $tab_counter++;
        }
		if ($default_tab!==null) $tb->set_default_tab($default_tab);
        if ($mode!='history') {
            $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab));
            $addons_mod = array();
            while ($row = $ret->FetchRow()) {
                if (ModuleManager::is_installed($row['module'])==-1) continue;
                if (is_callable(explode('::',$row['label']))) {
                    $result = call_user_func(explode('::',$row['label']), $this->record, $this);
                    if (!isset($result['show'])) $result['show']=true;
					if (($mode=='add' || $mode=='edit') && (!isset($result['show_in_edit']) || !$result['show_in_edit'])) continue;
                    if ($result['show']==false) continue;
                    if (!isset($result['label'])) $result['label']='';
                    $row['label'] = $result['label'];
                } else {
					if ($mode=='add' || $mode=='edit') continue;
					$labels = explode('#',$row['label']);
					foreach($labels as $i=>$label) $labels[$i] = _V($label); // translate labels from database
					$row['label'] = implode('#',$labels);
				}
                $mod_id = md5(serialize($row));
				if (method_exists($row['module'].'Common',$row['func'].'_access') && !call_user_func(array($row['module'].'Common',$row['func'].'_access'), $this->record, $this)) continue;
                $addons_mod[$mod_id] = $this->init_module($row['module']);
                if (!method_exists($addons_mod[$mod_id],$row['func'])) $tb->set_tab($row['label'],array($this, 'broken_addon'), array(), $js);
                else $tb->set_tab($row['label'],array($this, 'display_module'), array(& $addons_mod[$mod_id], array($this->record, $this), $row['func']), $js);
            }
        }
        if ($additional_tabs==0 && ($mode=='add' || $mode=='edit' || $mode=='history'))
            print("</form>\n");
        $this->display_module($tb);
        $tb->tag();
		
		foreach ($this->fields_in_tabs as $label=>$fields) {
			$highlight = false;
			foreach ($fields as $f) {
				$err = $form->getElementError($f);
				if ($err) {
					$highlight = true;
					break;
				}
			}
			if ($highlight)
				$tb->tab_icon($label, Base_ThemeCommon::get_template_file('Utils_RecordBrowser','notify_error.png'));
		}
		
        if ($this->switch_to_addon) {
    	    $this->set_module_variable('switch_to_addon',false);
            if($tab_counter<0) $tab_counter=0;
            $ret = DB::Execute('SELECT * FROM recordbrowser_addon WHERE tab=%s AND enabled=1 ORDER BY pos', array($this->tab));
            while ($row = $ret->FetchRow()) {
                if (ModuleManager::is_installed($row['module'])==-1) continue;
                if (is_callable(explode('::',$row['label']))) {
                    $result = call_user_func(explode('::',$row['label']), $this->record,$this);
                    if (isset($result['show']) && $result['show']==false) continue;
                    $row['label'] = $result['label'];
                }
                if ($row['label']==$this->switch_to_addon) $this->switch_to_addon = $tab_counter;
                $tab_counter++;
            }
            $tb->switch_tab($this->switch_to_addon);
            location(array());
        }
        if ($additional_tabs!=0 && ($mode=='add' || $mode=='edit' || $mode=='history'))
            print("</form>\n");

        return true;
    } //view_entry
Ejemplo n.º 7
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'));
     }
 }
Ejemplo n.º 8
0
 public function launchpad()
 {
     if (self::$launchpad == null) {
         return;
     }
     $launcher = array();
     usort(self::$launchpad, array($this, 'compare_launcher'));
     if (!empty(self::$launchpad)) {
         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'launcher.png');
         $th = $this->pack_module(Base_Theme::module_name());
         usort(self::$launchpad, array($this, 'compare_launcher'));
         $th->assign('icons', self::$launchpad);
         eval_js_once('actionbar_launchpad_deactivate = function(){leightbox_deactivate(\'actionbar_launchpad\');}');
         ob_start();
         $th->display('launchpad');
         $lp_out = ob_get_clean();
         $big = count(self::$launchpad) > 10;
         Libs_LeightboxCommon::display('actionbar_launchpad', $lp_out, __('Launchpad'), $big);
         $launcher[] = array('label' => __('Launchpad'), 'description' => 'Quick modules launcher', 'open' => '<a ' . Libs_LeightboxCommon::get_open_href('actionbar_launchpad') . '>', 'close' => '</a>', 'icon' => $icon);
         $th = $this->pack_module(Base_Theme::module_name());
         $th->assign('icons', array());
         $th->assign('launcher', array_reverse($launcher));
         $th->display();
         eval_js('$("launchpad_button_section").style.display="";');
         eval_js('$("launchpad_button_section_spacing").style.display="";');
     }
 }
Ejemplo n.º 9
0
 public function advanced_setup($store = false)
 {
     //create default module form
     $form = $this->init_module('Libs/QuickForm', 'Processing modules', 'setup');
     //install module header
     $form->addElement('header', 'mod_header', '<b>' . __('Please select modules to be installed/uninstalled.') . '<br>' . __('For module details please click on "i" icon.'));
     $module_dirs = $this->get_module_dirs();
     $structure = array();
     $def = array();
     $is_required = ModuleManager::required_modules(true);
     // transform is_required array to javascript
     eval_js('var deps = new Array(' . sizeof($is_required) . ');');
     foreach ($is_required as $k => $mod) {
         eval_js('deps["' . $k . '"] = new Array(' . sizeof($mod) . ');');
         $i = 0;
         foreach ($mod as $dep_mod) {
             eval_js('deps["' . $k . '"][' . $i++ . '] = "' . $dep_mod . '";');
         }
     }
     // javascript to show warning only once and cascade uninstall
     load_js('modules/Base/Setup/js/main.js');
     eval_js('var showed = false;');
     eval_js_once('var original_select = new Array(' . sizeof($is_required) . ');');
     eval_js_once('base_setup__reinstall_warning = \'' . __('Warning!\\nAll data in reinstalled modules will be lost.') . '\'');
     eval_js_once('base_setup__uninstall_warning = \'' . __('Warning! The following modules will be uninstalled. Are you sure you want to continue?') . '\'');
     foreach ($module_dirs as $entry => $versions) {
         $installed = ModuleManager::is_installed($entry);
         $module_install_class = $entry . 'Install';
         $func_info = array($module_install_class, 'info');
         $info = '';
         if (is_callable($func_info)) {
             $module_info = call_user_func($func_info);
             if ($module_info) {
                 $info = ' <a ' . Libs_LeightboxCommon::get_open_href($entry) . '><img style="vertical-align: middle; cursor: pointer;" border="0" width="14" height="14" src=' . Base_ThemeCommon::get_template_file('Base_Setup', 'info.png') . '></a>';
                 $iii = '<h1>' . str_replace('_', '/', $entry) . '</h1><table>';
                 foreach ($module_info as $k => $v) {
                     $iii .= '<tr><td>' . $k . '</td><td>' . $v . '</td></tr>';
                 }
                 $iii .= '</table>';
                 Libs_LeightboxCommon::display($entry, $iii, 'Additional info');
             }
         }
         // Show Tooltip if module is required
         $tooltip = null;
         if (isset($is_required[$entry])) {
             $tooltip = __('Required by:') . '<ul>';
             foreach ($is_required[$entry] as $mod_name) {
                 $tooltip .= '<li>' . $mod_name . '</li>';
             }
             $tooltip .= '</ul>';
         }
         $versions[-1] = 'not installed';
         ksort($versions);
         if ($installed != -1 && !isset($is_required[$entry])) {
             $versions[-2] = 'reinstall';
         }
         $path = explode('_', $entry);
         $c =& $structure;
         for ($i = 0, $path_count = count($path) - 1; $i < $path_count; $i++) {
             if (!array_key_exists($path[$i], $c)) {
                 $c[$path[$i]] = array();
                 $c[$path[$i]]['name'] = $path[$i];
                 $c[$path[$i]]['sub'] = array();
             }
             $c =& $c[$path[$i]]['sub'];
         }
         $params_arr = array('onChange' => "show_alert(this,'{$entry}');", 'style' => 'width: 100px');
         $ele = $form->createElement('select', 'installed[' . $entry . ']', $path[count($path) - 1], $versions, $params_arr);
         $ele->setValue($installed);
         eval_js("original_select[\"{$entry}\"] = {$installed}");
         $c[$path[count($path) - 1]] = array();
         $c[$path[count($path) - 1]]['name'] = '<table width="400px"><tr><td align=left>' . $info . ' ' . $path[count($path) - 1] . '</td><td width="100px" align=right ' . ($tooltip ? Utils_TooltipCommon::open_tag_attrs($tooltip, false) : '') . '>' . $ele->toHtml() . '</td></tr></table>';
         $c[$path[count($path) - 1]]['sub'] = array();
         array_push($def, array('installed[' . $entry . ']' => $installed));
     }
     $tree = $this->init_module('Utils/Tree');
     $tree->set_structure($structure);
     $tree->set_inline_display();
     //$form->addElement('html', '<tr><td colspan=2>'.$tree->toHtml().'</td></tr>');
     $form->addElement('html', '<tr><td colspan=2>' . $this->get_html_of_module($tree) . '</td></tr>');
     $form->setDefaults($def);
     //validation or display
     if ($form->exportValue('submited') && $form->validate()) {
         ob_start();
         if (!$this->validate($form->getSubmitValues())) {
             print ob_get_clean();
             print '<hr class="line"><center><a class="button"' . $this->create_href(array()) . '>Back</a></center>';
         } else {
             ob_end_clean();
             location(array());
         }
         return;
     }
     $form->display();
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     if (!$store) {
         Base_ActionBarCommon::add('settings', __('Simple view'), $this->create_callback_href(array($this, 'switch_simple'), true));
     }
 }
Ejemplo n.º 10
0
 public function body()
 {
     Libs_LeightboxCommon::display('aboutepesi', $this->get_info(), 'About');
     print '<a ' . Libs_LeightboxCommon::get_open_href('aboutepesi') . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Click to get more info')) . '><img src="images/epesi-powered.png" border=0></a>';
 }
Ejemplo n.º 11
0
    public static function get_file_leightbox($row, & $view_link = '') {
        static $th;
        if(!isset($th)) $th = Base_ThemeCommon::init_smarty();

        if($row['original']==='') return '';

        $links = array();

        $lid = 'get_file_'.md5(serialize($row));
        if(isset($_GET['save_google_docs']) && $_GET['save_google_docs']==$lid) {
            self::save_google_docs($row['id']);
        }
        if(isset($_GET['discard_google_docs']) && $_GET['discard_google_docs']==$lid) {
            self::discard_google_docs($row['id']);
        }

        $close_leightbox_js = 'leightbox_deactivate(\''.$lid.'\');';
        if (Variable::get('utils_attachments_google_user',false) && preg_match('/\.(xlsx?|docx?|txt|odt|ods|csv)$/i',$row['original'])) {
            $label = __('Open with Google Docs');
            $label = explode(' ', $label);
            $mid = floor(count($label) / 2);
            $label = implode('&nbsp;', array_slice($label, 0, $mid)).' '.implode('&nbsp;', array_slice($label, $mid));
            $script = 'get_google_docs';
            $onclick = '$(\'attachment_save_options_'.$row['id'].'\').style.display=\'\';$(\'attachment_download_options_'.$row['id'].'\').hide();';
            $th->assign('save_options_id','attachment_save_options_'.$row['id']);
            $links['save'] = '<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('save_google_docs'=>$lid)).'">'.__('Save Changes').'</a><br>';
            $links['discard'] ='<a href="javascript:void(0);" onclick="'.$close_leightbox_js.Module::create_href_js(array('discard_google_docs'=>$lid)).'">'.__('Discard Changes').'</a><br>';
        } else {
            $label = __('View');
            $th->assign('save_options_id','');
            $script = 'get';
            $onclick = $close_leightbox_js;
        }
        $th->assign('download_options_id','attachment_download_options_'.$row['id']);

        $view_link = 'modules/Utils/Attachment/'.$script.'.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID,'view'=>1));
        $links['view'] = '<a href="'.$view_link.'" target="_blank" onClick="'.$onclick.'">'.$label.'</a><br>';
        $links['download'] = '<a href="modules/Utils/Attachment/get.php?'.http_build_query(array('id'=>$row['id'],'cid'=>CID)).'" onClick="leightbox_deactivate(\''.$lid.'\')">'.__('Download').'</a><br>';

        load_js('modules/Utils/Attachment/remote.js');
        if(!$row['crypted']) {
            $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link('.$row['id'].', '.CID.',\'get link\');leightbox_deactivate(\''.$lid.'\')">'.__('Get link').'</a><br>';
        }
        $th->assign('filename',$row['original']);
        $f_filename = DATA_DIR.'/Utils_Attachment/'.$row['aid'].'/'.$row['id'];
        if(!file_exists($f_filename)) return 'missing file: '.$f_filename;
        $th->assign('file_size',__('File size: %s',array(filesize_hr($f_filename))));

        $th->assign('labels',array(
            'filename'=>__('Filename'),
            'file_size'=>__('File size')
        ));

        foreach($links as $key=>&$l) {
            $th->assign($key,$l);
            $l = Base_ThemeCommon::parse_links($key, $l);
        }
        $th->assign('__link',$links);

        $custom_getters = array();
        if(!$row['crypted']) {
            $getters = ModuleManager::call_common_methods('attachment_getters');
            foreach($getters as $mod=>$arr) {
                if (is_array($arr))
                    foreach($arr as $caption=>$func) {
                        $cus_id = md5($mod.$caption.serialize($func));
                        if(isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter']==$cus_id)
                            call_user_func_array(array($mod.'Common',$func['func']),array($f_filename,$row['original'],$row['id']));
                        $custom_getters[] = array('open'=>'<a href="javascript:void(0)" onClick="'.Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter'=>$cus_id)),true,false).';leightbox_deactivate(\''.$lid.'\')">','close'=>'</a>','text'=>$caption,'icon'=>$func['icon']);
                    }
            }
        }
        $th->assign('custom_getters',$custom_getters);

        ob_start();
        Base_ThemeCommon::display_smarty($th,'Utils_Attachment','download');
        $c = ob_get_clean();

        Libs_LeightboxCommon::display($lid,$c,__('Attachment'));
        return Libs_LeightboxCommon::get_open_href($lid);
    }
Ejemplo n.º 12
0
 public function body($header = '', $params = array(), $add_disp = '', $big = true)
 {
     if (MOBILE_DEVICE) {
         return;
     }
     if (isset($_REQUEST['__location']) && $this->last_location != $_REQUEST['__location']) {
         $this->last_location = $_REQUEST['__location'];
         $this->leightbox_ready = false;
     }
     if (!$this->leightbox_ready) {
         if (!empty($params)) {
             $this->params = $params;
             $js = 'f' . $this->group . '_set_params = function(arg' . implode(',arg', array_keys($params)) . '){';
             foreach ($params as $k => $v) {
                 $js .= 'els=document.getElementsByName(\'' . $this->group . '_' . $v . '\');';
                 $js .= 'i=0;while(i<els.length){els[i].value=arg' . $k . ';i++;}';
             }
             $js .= '}';
             eval_js($js);
         }
         $this->leightbox_ready = true;
         eval_js_once('f' . $this->group . '_prompt_deactivate = function(){leightbox_deactivate(\'' . $this->group . '_prompt_leightbox\');}');
         eval_js_once('f' . $this->group . '_show_form = function(arg){$(arg+\'_' . $this->group . '_form_section\').style.display=\'block\';$(\'' . $this->group . '_buttons_section\').style.display=\'none\';}');
         eval_js('$(\'' . $this->group . '_buttons_section\').style.display=\'' . (count($this->options) == 1 ? 'none' : 'block') . '\';');
         $buttons = array();
         $sections = array();
         foreach ($this->options as $k => $v) {
             $next_button = array('icon' => $v['icon'], 'label' => $v['label']);
             if ($v['form'] !== null) {
                 $form = $v['form'];
             } else {
                 $form = $this->options[$k]['form'] = $this->init_module(Libs_QuickForm::module_name());
             }
             if (!empty($params)) {
                 foreach ($params as $w) {
                     $form->addElement('hidden', $this->group . '_' . $w, 'none', array('id' => $this->group . '_' . $w));
                 }
             }
             if ($v['form'] !== null) {
                 $v['form']->addElement('button', 'cancel', __('Cancel'), array('id' => $this->group . '_lp_cancel', 'onclick' => count($this->options) == 1 ? 'f' . $this->group . '_prompt_deactivate();' : '$(\'' . $this->group . '_buttons_section\').style.display=\'block\';$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'none\';'));
                 $v['form']->addElement('submit', 'submit', __('OK'), array('id' => $this->group . '_lp_submit', 'onclick' => 'f' . $this->group . '_prompt_deactivate();'));
                 ob_start();
                 $th = $this->init_module(Base_Theme::module_name());
                 $v['form']->assign_theme('form', $th);
                 $th->assign('id', $this->get_instance_id());
                 $th->display('form');
                 $form_contents = ob_get_clean();
                 $next_button['open'] = '<a href="javascript:void(0);" onclick="f' . $this->group . '_show_form(\'' . $k . '\');">';
                 $sections[] = '<div id="' . $k . '_' . $this->group . '_form_section" style="display:none;">' . $form_contents . '</div>';
                 eval_js('$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'' . (count($this->options) != 1 ? 'none' : 'block') . '\';');
                 if ($v['form']->exportValue('submited') && !$v['form']->validate()) {
                     // open this selection
                     eval_js('f' . $this->get_group_key() . "_show_form('{$k}')");
                 }
             } else {
                 //                  $next_button['open'] = '<a '.$this->create_callback_href(array($this,'option_chosen'), array($k)).' onmouseup="f'.$this->group.'_prompt_deactivate();">';
                 $next_button['open'] = '<a href="javascript:void(0);" onmouseup="f' . $this->group . '_prompt_deactivate();' . $form->get_submit_form_js() . ';">';
                 $form->display();
             }
             $next_button['close'] = '</a>';
             $buttons[] = $next_button;
         }
         $theme = $this->init_module(Base_Theme::module_name());
         $theme->assign('open_buttons_section', '<div id="' . $this->group . '_buttons_section">');
         $theme->assign('buttons', $buttons);
         $theme->assign('sections', $sections);
         $theme->assign('additional_info', $add_disp);
         $theme->assign('close_buttons_section', '</div>');
         ob_start();
         $theme->display('leightbox');
         $profiles_out = ob_get_clean();
         Libs_LeightboxCommon::display($this->group . '_prompt_leightbox', $profiles_out, $header, $big);
     }
 }
Ejemplo n.º 13
0
 public function company_addon($arg)
 {
     $rb = $this->init_module('Utils/RecordBrowser', 'contact', 'contact_addon');
     $rb->set_additional_actions_method(array($this, 'contacts_actions'));
     if (Utils_RecordBrowserCommon::get_access('contact', 'add')) {
         Base_ActionBarCommon::add('add', __('Add contact'), $this->create_callback_href(array($this, 'company_addon_new_contact'), array($arg['id'])));
     }
     $rb->set_button($this->create_callback_href(array($this, 'company_addon_new_contact'), array($arg['id'])));
     $rb->set_defaults(array('company_name' => $arg['id']));
     $this->display_module($rb, array(array('(company_name' => $arg['id'], '|related_companies' => array($arg['id'])), array('company_name' => false), array('last_name' => 'ASC', 'first_name' => 'ASC')), 'show_data');
     $uid = Base_AclCommon::get_clearance();
     if (in_array('ACCESS:manager', $uid) && in_array('ACCESS:employee', $uid)) {
         $prompt_id = "contacts_address_fix";
         $content = $this->update_contacts_address_prompt($arg, $prompt_id);
         Libs_LeightboxCommon::display($prompt_id, $content, __('Update Contacts'));
         Base_ActionBarCommon::add('all', __('Update Contacts'), Libs_LeightboxCommon::get_open_href($prompt_id));
     }
 }
Ejemplo n.º 14
0
 public static function get_file_leightbox($row, &$view_link = '')
 {
     static $th;
     if (!isset($th)) {
         $th = Base_ThemeCommon::init_smarty();
     }
     if ($row['original'] === '') {
         return '';
     }
     $links = array();
     $lid = 'get_file_' . md5(serialize($row));
     $close_leightbox_js = 'leightbox_deactivate(\'' . $lid . '\');';
     $label = __('View');
     $th->assign('save_options_id', '');
     $script = 'get';
     $onclick = $close_leightbox_js;
     $th->assign('download_options_id', 'attachment_download_options_' . $row['id']);
     $view_link = 'modules/Utils/Attachment/' . $script . '.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID, 'view' => 1));
     $links['view'] = '<a href="' . $view_link . '" target="_blank" onClick="' . $onclick . '">' . $label . '</a><br>';
     $links['download'] = '<a href="modules/Utils/Attachment/get.php?' . http_build_query(array('id' => $row['id'], 'cid' => CID)) . '" onClick="leightbox_deactivate(\'' . $lid . '\')">' . __('Download') . '</a><br>';
     load_js('modules/Utils/Attachment/remote.js');
     if (!$row['crypted']) {
         $links['link'] = '<a href="javascript:void(0)" onClick="utils_attachment_get_link(' . $row['id'] . ', ' . CID . ',\'get link\');leightbox_deactivate(\'' . $lid . '\')">' . __('Get link') . '</a><br>';
     }
     $th->assign('filename', $row['original']);
     $meta = Utils_FileStorageCommon::meta($row['filestorage_id']);
     $f_filename = $meta['file'];
     if (!file_exists($f_filename)) {
         return 'missing file: ' . $f_filename;
     }
     $th->assign('file_size', __('File size: %s', array(filesize_hr($f_filename))));
     $th->assign('labels', array('filename' => __('Filename'), 'file_size' => __('File size')));
     foreach ($links as $key => &$l) {
         $th->assign($key, $l);
         $l = Base_ThemeCommon::parse_links($key, $l);
     }
     $th->assign('__link', $links);
     $custom_getters = array();
     if (!$row['crypted']) {
         $getters = ModuleManager::call_common_methods('attachment_getters');
         foreach ($getters as $mod => $arr) {
             if (is_array($arr)) {
                 foreach ($arr as $caption => $func) {
                     $cus_id = md5($mod . $caption . serialize($func));
                     if (isset($_GET['utils_attachment_custom_getter']) && $_GET['utils_attachment_custom_getter'] == $cus_id) {
                         call_user_func_array(array($mod . 'Common', $func['func']), array($f_filename, $row['original'], $row['id']));
                     }
                     $custom_getters[] = array('open' => '<a href="javascript:void(0)" onClick="' . Epesi::escapeJS(Module::create_href_js(array('utils_attachment_custom_getter' => $cus_id)), true, false) . ';leightbox_deactivate(\'' . $lid . '\')">', 'close' => '</a>', 'text' => $caption, 'icon' => $func['icon']);
                 }
             }
         }
     }
     $th->assign('custom_getters', $custom_getters);
     ob_start();
     Base_ThemeCommon::display_smarty($th, 'Utils_Attachment', 'download');
     $c = ob_get_clean();
     Libs_LeightboxCommon::display($lid, $c, __('Attachment'));
     return Libs_LeightboxCommon::get_open_href($lid);
 }
Ejemplo n.º 15
0
 /**
  * Create a leightbox with buttons
  *
  * @param array $links array of array('href' => .. , 'label' => ..)
  *
  * @return string href to open leightbox
  */
 protected static function choose_box_href(array $links)
 {
     $unique_id = md5(serialize($links));
     $popup_id = 'print_choice_popup_' . $unique_id;
     $header = __('Select document template to print');
     $launchpad = array();
     $deactivate = " onclick=\"leightbox_deactivate('{$popup_id}')\"";
     foreach ($links as $template) {
         $launchpad[] = array('href' => $template['href'] . $deactivate, 'label' => $template['label']);
     }
     $th = Base_ThemeCommon::init_smarty();
     $th->assign('icons', $launchpad);
     ob_start();
     Base_ThemeCommon::display_smarty($th, self::Instance()->get_type(), 'launchpad');
     $content = ob_get_clean();
     Libs_LeightboxCommon::display($popup_id, $content, $header);
     return Libs_LeightboxCommon::get_open_href($popup_id);
 }
Ejemplo n.º 16
0
	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)" ';
	}
Ejemplo n.º 17
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>';
 }
Ejemplo n.º 18
0
 private static function copy_company_data_subroutine($values)
 {
     $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values);
     if (!$access) {
         return;
     }
     /* First click should generate html code for leightbox and show it.
      * This function is rarely used and we don't want to increase page size.
      * To do this we use REQUEST variable UCD.
      *
      * We use module variable UCD to indicate that form was shown and we
      * must check if it was submitted. If yes - do action. If it wasn't
      * we should come back to initial state - do not print LB.
      */
     if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0))) {
         if (isset($values['company_name']) && $values['company_name']) {
             Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true)));
         }
     }
     if (isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0)) {
         $ucd = Module::static_get_module_variable('CRM/Contacts', 'UCD', 0);
         $ucd++;
         if ($ucd > 1) {
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
         } else {
             Module::static_set_module_variable('CRM/Contacts', 'UCD', $ucd);
         }
         $lid = 'UCDprompt';
         $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt');
         $form->construct();
         $sel_val = array();
         foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) {
             $sel_val[$id] = self::company_format_default(self::get_company($id), true);
         }
         $form->addElement('select', 'company', __('Select company:'), $sel_val);
         unset($sel_val);
         $form->addElement('html', __('Select which fields should be copied:'));
         $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false));
         foreach ($data as $row) {
             if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) {
                 $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array());
             }
         }
         $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $form->addGroup(array($ok, $cancel));
         if ($form->validate()) {
             $Uvalues = $form->exportValues();
             $fields = array();
             foreach ($data as $row) {
                 if (array_key_exists($row['sid'], $Uvalues)) {
                     $fields[$row['tid']] = $row['sid'];
                 }
             }
             if (isset($Uvalues['company'])) {
                 $company = CRM_ContactsCommon::get_company($Uvalues['company']);
                 $new_data = array();
                 foreach ($fields as $k => $v) {
                     $new_data[$k] = $company[$v];
                 }
                 Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data);
             }
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
             location(array());
         }
         // set default to main company
         if ($mc = self::get_main_company()) {
             $form->setDefaults(array('company' => $mc));
         }
         $html = $form->toHtml();
         Libs_LeightboxCommon::display($lid, $html);
         Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid));
         if (isset($_REQUEST['UCD'])) {
             eval_js('leightbox_activate(\'' . $lid . '\')');
         }
         unset($_REQUEST['UCD']);
     }
 }