<?php
include('includes/application_top.php');
include(DIR_WS_CLASSES.'class.notiz.php');
$dbprefix = "Notice_";

function _draw_checkbox_id($id){
	return xtc_draw_checkbox_field('id[]',$id,false);
}

function _timestamp_to_date($date){
	return strftime(DATE_FORMAT_SHORT,$date);
}

function _get_capt($string){
	$match1 = "{";
	$match2 = "}";
	$h1 = strpos($string,$match1);
	$h2 = strpos($string,$match2);
	$read_status = substr($string,($h1+1),strlen($match1));
	$string = substr($string,($h2+1));
	if($read_status == 0)
		return '<b>'.$string.'</b>';
	else
		return $string;
}

$altcap='';
$altnote='';

$hour_array = array();
for($i=0;$i<24;$i++){
	$val = (strlen($i)==1)?'0'.$i:$i;
	$hour_array[] = array('id'=>$val,'text'=>$val);
}
$minute_array = array();
for($i=0;$i<60;$i+=15){
	$val = (strlen($i)==1)?'0'.$i:$i;
	$minute_array[] = array('id'=>$val,'text'=>$val);
}

if($_GET['iframe']){
	$id = xtc_db_input($_GET['iframe']);
	$notiz = new notiz($id);
	$smarty = new yesSmarty;
	$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
	$smarty->assign('HTML_PARAMS',HTML_PARAMS);
	$smarty->assign('NOTE',	nl2br($notiz->get_note()) );
	$smarty->display(DIR_FS_ADMIN.'templates/notiz_iframe_note.html');
	exit;
}

// PAGER LISTING ACTIONS
if(xtc_not_null($_POST['action'])){
	switch($_POST['action']){
		case 'delete':
			if(is_array($_POST['id'])){
				foreach($_POST['id'] as $k=>$v){
					$id = xtc_db_input($v);
					$notiz = new notiz($id);
					$notiz->delete();
				}
				$messageStack->add_session(MESSAGE_SUCCESS_DELETE,'success');
			}else{
				$messageStack->add_session(MESSAGE_ERROR_DELETE,'error');
			}
			xtc_redirect( xtc_href_link(FILENAME_NOTIZ) );
			break;
		case 'mark_as_read':
			if(is_array($_POST['id'])){
				for($i=0;$i<sizeOf($_POST['id']);$i++){
					$id = xtc_db_input($_POST['id'][$i]);
					$notiz = new notiz($id);
					$notiz->set_read_status(1);
				}
				$messageStack->add_session(MESSAGE_SUCCESS_MARKASREAD,'success');
			}else{
				$messageStack->add_session(MESSAGE_ERROR_MARKASREAD,'error');
			}
			xtc_redirect( xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action','nID')) ) );
			break;
		case 'move':
			$folder = xtc_db_input($_POST['action_parameter']);
			if(is_array($_POST['id'])){
				for($i=0;$i<sizeOf($_POST['id']);$i++){
					$id = xtc_db_input($_POST['id'][$i]);
					$notiz = new notiz($id);
					$notiz->move_to_folder($folder);
				}
				$messageStack->add_session(MESSAGE_SUCCESS_MOVED,'success');
			}else{
				$messageStack->add_session(MESSAGE_ERROR_MOVED,'success');
			}
			xtc_redirect( xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action','nID')) ) );
			break;
	}
}

if($_GET['action'] == 'quicknoteadd'){
	$notiz = new notiz(0);
	if(xtc_not_null($_POST['termin']))
		$date_termin = xtc_db_input($_POST['termin']).' '.xtc_db_input($_POST['termin_hour']).':'.xtc_db_input($_POST['termin_minute']).':00';
	else
		$date_termin = '';

	if($_GET['popup'] and $_GET['popup'] == '1')
		$note = xtc_db_input($_POST['note']."<br />LINK:<br /><a href=\"#\" onclick=\"window.open('".urldecode($_POST['src'])."','popup','width=".EXT_POPUP_WIDTH.",height=".EXT_POPUP_HEIGHT.",scrollbars=yes,resizable=yes');\" title=\"Link aufrufen\">Link aufrufen</a>");
	else
		$note = xtc_db_input($_POST['note']."<br />LINK:<br /><a href=\"#\" onclick=\"parent.window.location.href='".urldecode($_POST['src'])."';\" title=\"Link aufrufen\">Link aufrufen</a>");

	$saved = $notiz->save_new( xtc_db_input(utf8_decode($_POST['capt'])),
		utf8_decode(nl2br($note)),
		$_SESSION['customer_id'],
		$date_termin,
		$_POST['rec']
	);
	header('Content-Type: text/html; charset=iso-8859-1');
	if($saved){
		echo SUCCESS_SAVE_QUICKNOTE;
	}else{
		echo ERROR_SAVE_NOTE;
	}
	exit;
}

switch($_GET['action']){
	case 'save_forward':
		$id = xtc_db_input($_GET['id']);
		$rec = $_GET['cID'];
		$notiz = new notiz($id);
		for($i=0;$i<sizeOf($rec);$i++){
			$cID = xtc_db_input($rec[$i]);
			$notiz->save_forward($cID);
		}
		$messageStack->add_session('Notiz weitergeleitet.','success');
		xtc_redirect(xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action','cID'))));
		exit;
		break;
	case 'addfolder_save':
		if(xtc_not_null($_POST['folder_title'])){
			xtc_db_query("INSERT INTO Notice_folders SET customers_id='".$_SESSION['customer_id']."',folder_title='".$_POST['folder_title']."',date_created=now()");
			$messageStack->add_session('Neues Verzeichnis erstellt.','success');
		}else{
			$messageStack->add_session('Es wurde kein Name des Verzeichnisses angegeben.','error');
		}
		xtc_redirect( xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action')) ) );
		break;
	case 'delfolder_now':
		// ALS ERSTES SCHAUEN WELCHE NOTIZEN IM FOLDER SIND
		$notices_query = xtc_db_query(sprintf("SELECT notes_id FROM Notice_status WHERE usr='%s' and Notice_folders_id='%s'",
				$_SESSION['customer_id'],
				xtc_db_input($_GET['folder'])
			)
		);
		while($notices = xtc_db_fetch_array($notices_query)){
			$notiz = new notiz($notices['notes_id']);
			$notiz->delete();
		}
		xtc_db_query("DELETE FROM Notice_folders WHERE customers_id='".$_SESSION['customer_id']."' and Notice_folders_id='".$_GET['folder']."'");
		$messageStack->add_session('Verzeichnis wurde gel&ouml;scht.','success');
		xtc_redirect( xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action','folder'))) );
		break;
	case 'delete':
		$id = xtc_db_input($_GET['id']);
		$notiz = new notiz($id);
		$notiz->delete();
		$messageStack->add_session('Termin gel&ouml;scht.','success');
		xtc_redirect( xtc_href_link(FILENAME_NOTIZ) );
		break;
	case 'save_termin':
		$id = xtc_db_input($_GET['id']);
		$hour = xtc_db_input($_POST['termin_hour']);
		$minute = xtc_db_input($_POST['termin_minute']);
		$date = xtc_db_input($_POST['termin']);
		$termin = $date.' '.$hour.':'.$minute.':00';

		if($date != '' and strtotime($termin)>time() ){
			$status_sql_raw = "UPDATE ".$dbprefix."status SET date_termin='".$termin."' WHERE notes_id='".$id."' and usr='".$_SESSION['customer_id']."'";
			xtc_db_query($status_sql_raw);
			$messageStack->add_session('Termin zur Notiz gespeichert.','success');
		}
		xtc_redirect( xtc_href_link(FILENAME_NOTIZ) );
		break;
	case 'delete_termin':
		$id = xtc_db_input($_GET['id']);
		$status_sql_raw = "UPDATE ".$dbprefix."status SET date_termin='' WHERE notes_id='".$id."' and usr='".$_SESSION['customer_id']."'";
		xtc_db_query($status_sql_raw);
		$messageStack->add_session('Termin zur Notiz gel&ouml;scht.','success');
		xtc_redirect( xtc_href_link(FILENAME_NOTIZ) );
		break;
}

//eintragen:
if (isset($_POST['newnote'])){
	$recs = substr($recs,0,(strlen($recs)-1) );
	if ($_POST['change']==0){
		$notiz = new notiz(0);
		if($_POST['termin_active'] == '1'){
			$date_termin = xtc_db_input($_POST['termin']).' '.xtc_db_input($_POST['termin_hour']).':'.xtc_db_input($_POST['termin_minute']).':00';
		}else{
			$date_termin = '';
		}

		$saved = $notiz->save_new( xtc_db_input($_POST['cap']),
			xtc_db_input($_POST['not']),
			$_SESSION['customer_id'],
			$date_termin,
			$_POST['rec']
		);
		if($saved)
			$messageStack->add_session('Notiz gespeichert','success');
		else
			$messageStack->add_session('Notiz nicht gespeichert. Bitte alle Pflichtfelder ausf&uuml;llen.','error');
	}else{
		if($_POST['termin_active'] == '1'){
			$date_termin = xtc_db_input($_POST['termin']).' '.xtc_db_input($_POST['termin_hour']).':'.xtc_db_input($_POST['termin_minute']).':00';
		}else{
			$date_termin = '';
		}
		$com='update '.$dbprefix.'notes set capt=\''.xtc_db_input($_POST['cap']).'\', note=\''.xtc_db_input($_POST['not']).'\' where id='.xtc_db_input($_POST['change']).';';
		xtc_db_query($com);
		
		$status_sql_raw = "UPDATE ".$dbprefix."status SET date_termin='".$date_termin."' WHERE notes_id='".xtc_db_input($_POST['change'])."' and usr='".$_SESSION['customer_id']."'";
		xtc_db_query($status_sql_raw);
		$messageStack->add_session('Notiz ge&auml;ndert.','success');
	}
	xtc_redirect(FILENAME_NOTIZ);
}

$lightbox_mode = ($_GET['action'] == 'view' or $_GET['action'] == 'change' or $_GET['action'] == 'forward_select' or $_GET['action'] == 'delfolder' or $_GET['action'] == 'addfolder') ? true : false;
$__NO_LOAD_LIGHTBOX = true;
if($_GET['subaction'] != 'print'){
	if($lightbox_mode){
		header('Content-Type: text/html; charset=iso-8859-1');
	}else{
		require(DIR_WS_INCLUDES . 'header.php');
		$heading = ($_GET['action'] == 'calendar') ? NOTICE_CALENDAR : NOTICE_OVERVIEW;
		$smarty->assign('HEADING_TITLE',$heading);
	}
} // end if subaction = print 	


	switch($_GET['action']){
		case 'termin':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('termin',1);
			break;
		case 'forward_select':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('forward',1);
			break;
		case 'new':
		case 'change':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('edit',1);
			break;
		case 'view':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('view',1);
			break;
		case 'notelist':
			$smarty->assign('notelist',1);
			break;
		case 'addfolder':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('addfolder',1);
			break;
		case 'delfolder':
			$smarty = new yesSmarty;
			$smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
			$smarty->assign('delfolder',1);
			break;
		default:
			$smarty->assign('list',1);
			break;
	}
	$folderID = (xtc_not_null($_GET['folder'])) ? $_GET['folder'] : 0;

	$smarty->assign('NOTICE_VIEW',VIEW_NOTICE);
	$smarty->assign('BUTTON_CLOSE',BUTTON_CLOSE);
	$smarty->assign('NOTE_CAPT',NOTE_CAPT);
	$smarty->assign('NOTE_FROM_DATE',NOTE_FROM_DATE);
	$smarty->assign('NOTE_RECIPIENT',NOTE_RECIPIENT);
	$smarty->assign('NOTE_TERMIN',NOTE_TERMIN);
	$smarty->assign('NOTE_TERMIN_INTRO',NOTE_TERMIN_INTRO);
	$smarty->assign('NOTE_TERMIN_ADD_INTRO',NOTE_TERMIN_ADD_INTRO);
	$smarty->assign('BUTTON_SAVE_TERMIN',BUTTON_SAVE_TERMIN);
	$smarty->assign('BUTTON_DELETE_TERMIN',BUTTON_DELETE_TERMIN);
	$smarty->assign('NOTE_NOTE',NOTE_NOTE);
	$smarty->assign('MARK_ALL',MARK_ALL);
	$smarty->assign('DEMARK_ALL',DEMARK_ALL);

	switch($_GET['action']){
		case 'forward_select':
			$id = xtc_db_input($_GET['id']);
			$notiz = new notiz($id);
			$rec = $notiz->get_forward_recipients();
			for($i=0;$i<sizeOf($rec);$i++){
				$txt = substr($rec[$i]['customers_firstname'] . ' ' . $rec[$i]['customers_lastname'],0,25);
				$rec_array[] = array('input'=>xtc_draw_checkbox_field('fwd[]',$rec[$i]['customers_id']),'name'=>xtc_db_prepare_input($txt));
			}
			$smarty->assign('TEXT_FORWARD',FORWARD);
			$smarty->assign('TEXT_CHOOSE_RECIPIENT',TEXT_CHOOSE_RECIPIENT);
			$smarty->assign('forward',true);
			$smarty->assign('id',$id);
			$smarty->assign('rec_array',$rec_array);
			break;
		case 'calendar':
			$no_fetch = true;
			require(DIR_FS_ADMIN.'includes/calendar.inc.php');
			break;
		case 'view':
			$notiz = new notiz( xtc_db_input($_GET['id']) );
			$notiz->get_data();
			if($notiz->read_status == 0){
				$notiz->set_read_status(1);
			}

			$smarty->assign('TITLE',$notiz->capt);
			$smarty->assign('NOTE_IFRAME_SRC',xtc_href_link(FILENAME_NOTIZ,'iframe='.$_GET['id']));
			$smarty->assign('FROM',xtc_get_editor_name($notiz->usr));
			$smarty->assign('DATE',date('d.m.Y H:i',$notiz->dat));
			$smarty->assign('TERMIN',$notiz->date_termin);
			$smarty->assign('LINK_DELETE_TERMIN',xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action')).'action=delete_termin'));
			$smarty->assign('TERMIN_FORM',xtc_draw_form('termin',FILENAME_NOTIZ,'action=save_termin&id='.$_GET['id']));
			$termin_H = ($row['date_termin'] > 0) ? strftime('%H',strtotime($notiz->date_termin)) : date('H');
			$termin_M = ($row['date_termin'] > 0) ? strftime('%M',strtotime($notiz->date_termin)) :  date('M');
			$smarty->assign('INPUT_TERMIN_HOUR',xtc_draw_pull_down_menu('termin_hour',$hour_array,$termin_H));
			$smarty->assign('INPUT_TERMIN_MINUTE',xtc_draw_pull_down_menu('termin_minute',$minute_array,$termin_M));

			break;
		case 'addfolder':
			$smarty->assign('ADDFOLDER_FORM',xtc_draw_form('addf', FILENAME_NOTIZ, xtc_get_all_get_params(array('action')).'action=addfolder_save'));
			$smarty->assign('addfolder',1);
			$smarty->assign('ADDFOLDER_INPUT',xtc_draw_input_field('folder_title','','maxlength="128"'));
			$smarty->assign('ADDFOLDER_TITLE',ADDFOLDER_TITLE);
			$smarty->assign('ADDFOLDER_INTRO',ADDFOLDER_INTRO);
			$smarty->assign('ADDFOLDER_SUBMIT',yes_draw_href_button(IMAGE_SAVE,'','notiz','','submit'));
			$smarty->assign('ADDFOLDER_CANCEL',yes_draw_href_button(IMAGE_CANCEL,xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action'))),'notiz' ));
			break;
		case 'delfolder':
			$smarty->assign('delfolder',1);
			$title_query = xtc_db_query("SELECT folder_title FROM Notice_folders WHERE Notice_folders_id='".xtc_db_input($_GET['folder'])."'");
			$title = xtc_db_fetch_array($title_query);

			$smarty->assign('DELFOLDER_LINK',xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action')).'action=delfolder_now'));
			$smarty->assign('DELFOLDER_INTRO',DELFOLDER_INTRO);
			$smarty->assign('DELFOLDER_SUBMIT',yes_draw_href_button(IMAGE_DELETE,xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action')).'action=delfolder_now'),'notiz'));
			$smarty->assign('DELFOLDER_CANCEL',yes_draw_href_button(IMAGE_CANCEL,xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action'))),'notiz'));
			$smarty->assign('DELFOLDER_TITLE',sprintf(DELFOLDER_TITLE,xtc_db_prepare_input($title['folder_title'])));
			break;
		case 'change':
			$smarty->assign('FORM_ACTION',xtc_href_link(FILENAME_NOTIZ));
			if($_GET['id']){
				$notiz = new notiz(xtc_db_input($_GET['id']));
				$notiz->get_data();
				$altcap=$notiz->capt;
				$altnote=$notiz->get_note();
				$saved_termin = $notiz->date_termin;
				if($notiz->date_termin > 0)
					$smarty->assign('TERMIN',date('Y-m-d',strtotime($notiz->date_termin)));
				else
					$smarty->assign('TERMIN','');
				$smarty->assign('INPUT_TERMIN_ACTIVE',xtc_draw_checkbox_field('termin_active','1',(($saved_termin>0)?true:false)));
				$smarty->assign('INPUT_TERMIN_HOUR',xtc_draw_pull_down_menu('termin_hour',$hour_array,strftime('%H',strtotime($saved_termin))));
				$smarty->assign('INPUT_TERMIN_MINUTE',xtc_draw_pull_down_menu('termin_minute',$minute_array,strftime('%M',strtotime($saved_termin))));

				$smarty->assign('TITLE','Notiz &auml;ndern');
			}else{
				$notiz = new notiz(0);
				$smarty->assign('TERMIN','');
				$smarty->assign('TITLE','Neue Notiz hinzuf&uuml;gen');
				$smarty->assign('INPUT_TERMIN_ACTIVE',xtc_draw_checkbox_field('termin_active','1',false));
				$smarty->assign('INPUT_TERMIN_HOUR',xtc_draw_pull_down_menu('termin_hour',$hour_array,date('H')));
				$smarty->assign('INPUT_TERMIN_MINUTE',xtc_draw_pull_down_menu('termin_minute',$minute_array));
			}
			
			$smarty->assign('INPUT_TITLE','<input type="text" maxlength="100" size="30" name="cap" value="'.$altcap.'">');
			$smarty->assign('INPUT_NOTE','<textarea name="not" rows="7" cols="50">'.$altnote.'</textarea>');
			if(empty($altcap) and empty($altnote) ){
				$smarty->assign('INPUT_REC',$notiz->draw_recipients($_SESSION['customer_id'])); 
			}
			$smarty->assign('NOTE_PFLICHTFELDER',NOTE_PFLICHTFELDER);
			$smarty->assign('INPUT_CHANGE',xtc_draw_hidden_field("change",((empty($altcap) and empty($altnote) ) ? '0' : $_GET['id'])).xtc_draw_hidden_field('newnote',1));
			$smarty->assign('INPUT_SUBMIT',yes_draw_href_button(IMAGE_SAVE,'','notiz','','submit'));
			
			$smarty->assign('edit',1);
			break;

		default:
			$folders[0] = array('id'=>'0','text'=>MAIN_FOLDER);
			$folders_query = xtc_db_query("SELECT * FROM Notice_folders WHERE customers_id='".$_SESSION['customer_id']."' ORDER BY folder_title");
			while($folder = xtc_db_fetch_array($folders_query)){
				$folders[] = array('id'=>$folder['Notice_folders_id'],'text'=>$folder['folder_title'] );
			}
			$smarty->assign('TEXT_GOTO',TEXT_GOTO);
			$smarty->assign('FORM',xtc_draw_form('notizen',FILENAME_NOTIZ,xtc_get_all_get_params(array('action')).'action=del'));
			$smarty->assign('EDITLINK',yes_draw_href_image('images/notiz_add.gif',EDITLINK_TITLE,xtc_href_link(FILENAME_NOTIZ,xtc_get_all_get_params(array('action')).'action=change'),'notiz','lbOn'));
			$smarty->assign('FOLDERADD_LINK_TITLE',FOLDERADD_LINK_TITLE);
			$smarty->assign('FOLDERDELETE_LINK_TITLE',FOLDERDELETE_LINK_TITLE);
			$smarty->assign('VIEW_CALENDARLINK',yes_draw_href_text(VIEW_CALENDAR,xtc_href_link(FILENAME_NOTIZ,'action=calendar'),'notiz'));
			$smarty->assign('FOLDERADD_LINK',xtc_href_link(FILENAME_NOTIZ,'action=addfolder'));
			if(xtc_not_null($_GET['folder']) and $_GET['folder'] > 0){
				$smarty->assign('FOLDERREMOVE_LINK',xtc_href_link(FILENAME_NOTIZ,'action=delfolder&folder='.$_GET['folder']));
			}
			$smarty->assign('FOLDERFORM',xtc_draw_form('folders',FILENAME_NOTIZ,xtc_get_all_get_params(),'get'));
			$smarty->assign('FOLDERSELECT',xtc_draw_pull_down_menu('folder',$folders,$_GET['folder'],'onChange="document.forms[\'folders\'].submit();" class="dbforminput"') );
			$smarty->assign('JS_SAVE_FORWARD_LINK',xtc_href_link(FILENAME_NOTIZ,'action=save_forward'));
			
			
			
			include(DIR_WS_CLASSES.'class.adodb-pager.php');
			$pager = new ADODB_Pager($conn,"select n.id,dat,concat('{',s.read_status,'}',capt) as capt_string,n.usr,s.date_termin from Notice_notes n,Notice_status s");
			$pager->whereConditions = array(
				"n.id=s.notes_id",
				sprintf("s.usr='%s'",$_SESSION['customer_id']),
				sprintf("s.Notice_folders_id='%s'",$folderID)
			);
			$pager->index_field = 'id';
		
			$pager->pager_tab_file = 'pager_tab.php';
			
			$pager->get_row_selector = 'nID';
			$pager->gridHeader = array('&nbsp;',TABLE_HEADING_DATE,TABLE_HEADING_CAPT,TABLE_HEADING_FROM,TABLE_HEADING_TERMIN);
			$pager->gridHelper = array(
				'id'=>'_draw_checkbox_id',
				'capt_string'=>'_get_capt',
				'dat'=>'_timestamp_to_date',
				'usr'=>'xtc_get_editor_name'
			);
			$pager->sortOrders = array(
				'dat'=>TABLE_HEADING_DATE,
				'date_termin'=>TABLE_HEADING_TERMIN	
			);
			
			$selected_item = $pager->selected_row;
			$pager->Render($rows_per_page=MAX_DISPLAY_SEARCH_RESULTS_ADMIN);
			
			$grid_smarty = $smarty;
			$pager_smarty = $smarty;
			
			$pager_smarty->assign('pager_tab_file',$pager->pager_tab_file);
			$pager_smarty->assign('HEADER',$pager->getHeader());
			$pager_smarty->assign('SORTING',$pager->getSortingInput());
			
			$grid_smarty->assign('grid',$pager->getGrid());
			$grid = $grid_smarty->fetch(DIR_FS_ADMIN.'templates/pager_grid.tpl');
			
			$pager_smarty->assign('GRID',$grid);
			$pager_smarty->assign('FOOTER',$pager->getFooter());
			$smarty->assign('PAGER_LISTING',$pager_smarty->fetch(DIR_FS_ADMIN.'templates/pager.tpl') );
			$smarty->assign('PAGER_SELECT',$pager->draw_list_selector());
			$smarty->assign('PAGER_DELETELINK',yes_draw_href_text(IMAGE_DELETE,'javascript:pager_list_action(document.forms[\'pagergrid_form\'],\'delete\',\'\');',$access='notiz'));
			$smarty->assign('PAGER_MARKASREADLINK',yes_draw_href_text(TEXT_MARK_AS_READ,'javascript:pager_list_action(document.forms[\'pagergrid_form\'],\'mark_as_read\',\'\');',$access='notiz'));
			$smarty->assign('PAGER_MOVETOFOLDER',MOVE_TO_FOLDER.': '.xtc_draw_pull_down_menu('folderselect',$folders,$folderID,'class="dbforminput" onchange="do_folderselect(document.forms[\'pagergrid_form\'],this);"'));
	

			$smarty->assign('SELECTALL','<a href="#" onClick="mark(1);">Alle markieren</a><br><a href="#" onClick="mark(0);">Alle Demarkieren</a>');
			$actions = array(
				0=>array('id'=>'','text'=>TEXT_PLEASE_CHOOSE),
				1=>array('id'=>'mark_as_read','text'=>TEXT_MARK_AS_READ),
				2=>array('id'=>'del','text'=>IMAGE_DELETE)
			);
			foreach($folders as $k=>$v){
				if($v['id'] != $folderID){
					$actions[] = array('id'=>'move_'.$v['id'],'text'=>MOVE_TO_FOLDER.' '.$v['text']);
				}
			}
			$smarty->assign('LISTACTION',xtc_draw_pull_down_menu('myaction',$actions,'','onChange="check_submit();"'));
			break;
	}
	if(!$no_fetch)
		$smarty->display('notiz.html');
if( !$lightbox_mode ){
?>

	</td>
</tr>
</table>
<?php
	require(DIR_WS_INCLUDES . 'footer.php');
} // end if !view