<?php

	class asterisk_popup_link
	{
		var $popup_height;
		var $popup_width;
		var $addr_suffix;
		var $cur_user;
		var $focus;

		var $type;
		var $record;
		var $theme;
		
		function asterisk_popup_link($type, $id, $height="330", $width="450")
		{
			$this->popup_height="350";
			$this->popup_width="550";
			$this->setRecordType($type);
			$this->setRecord($id);
			$this->addr_suffix="&type=".$this->type."&record=".$this->record;
		}

		function setRecord($id)
		{
			$this->record = $id;
		}

		function setRecordType($id_type)
		{
			$this->type = $id_type;
		}
 
		function Addr_String($string)
		{
			$this->addr_suffix=$this->addr_suffix.$string;
		}

		function getAddr()
		{
			return $this->addr_suffix;
		}

		function getLayoutDefs(){
			return array(
		
				// list of what Subpanels to show in the DetailView

				'subpanel_setup' => array(
				'activities' => array(
					'order' => 10,
					'sort_order' => 'desc',
					'sort_by' => 'date_start',
					'title_key' => 'LBL_ACTIVITIES_SUBPANEL_TITLE',
					'type' => 'collection',
					'subpanel_name' => 'activities',   //this values is not associated with a physical file.
					'module'=>'Activities',
		
					'top_buttons' => array(
						array('widget_class' => 'SubPanelTopCreateTaskButton'),
						array('widget_class' => 'SubPanelTopScheduleMeetingButton'),
						array('widget_class' => 'SubPanelTopScheduleCallButton'),
						//array('widget_class' =>'SubPanelTopCreateNoteButton'),
						//array('widget_class' => 'SubPanelTopComposeEmailButton'),
					),
					'collection_list' => array(	
						'meetings' => array(
							'module' => 'Meetings',
							'subpanel_name' => 'ForActivities',
							'get_subpanel_data' => 'meetings',
						),
					)			
				),
		
				'history' => array(
					'order' => 20,
					'sort_order' => 'desc',
					'sort_by' => 'date_modified',
					'title_key' => 'LBL_HISTORY_SUBPANEL_TITLE',
					'type' => 'collection',
					'subpanel_name' => 'history',   //this values is not associated with a physical file.
					'module'=>'History',
		
					'top_buttons' => array(
					array('widget_class' => 'SubPanelTopCreateNoteButton'),
					//array('widget_class' => 'SubPanelTopArchiveEmailButton'),
					//array('widget_class' => 'SubPanelTopSummaryButton'),
					),

					'collection_list' => array(	
						'meetings' => array(
							'module' => 'Meetings',
							'subpanel_name' => 'ForHistory',
							'get_subpanel_data' => 'meetings',
						),
						'tasks' => array(
							'module' => 'Tasks',
							'subpanel_name' => 'ForHistory',
							'get_subpanel_data' => 'tasks',
						),
						'calls' => array(
							'module' => 'Calls',
							'subpanel_name' => 'ForHistory',
							'get_subpanel_data' => 'calls',
						),	
						'notes' => array(
							'module' => 'Notes',
							'subpanel_name' => 'ForHistory',
							'get_subpanel_data' => 'notes',
						),	
						'emails' => array(
							'module' => 'Emails',
							'subpanel_name' => 'ForHistory',
							'get_subpanel_data' => 'emails',
						),
					)			
				),				
			),
		);
		}

		function create_icon_link($phone_num)
		{
			return "<a href='#' onclick='window.open(\"index.php?module=Contacts&action=AS_Popup&html=Dial&form=Dial&number=".$phone_num."&to_pdf=1&dialed=1&type=".$this->type."&record=".$this->record."\",\"Dialing\",\"width=".$this->popup_width.",height=".$this->popup_height.",resizable=0,scrollbars=1\")'><img src=\"include/images/phone_icon.png\" width=10 height=10 border=0></a><img src=\"include/images/spacer.png\" width=5 border=0>".$phone_num;
		}

		function create_phone_link($phone_num)
		{
			return "<img src=\"include/images/spacer.png\" width=5 border=0><a href='#' onclick='window.open(\"index.php?module=Contacts&action=AS_Popup&html=Dial&form=Dial&number=".$phone_num."&to_pdf=1&dialed=1&type=".$this->type."&record=".$this->record."\",\"Dialing\",\"width=".$this->popup_width.",height=".$this->popup_height.",resizable=0,scrollbars=1\")'>".$phone_num."</a>";

		}
	}

	////////END ASTERISK PATCH////////

?>
