<?php
include_once($staticpath.'classes/Button.php');
	$button = new Button;

include_once($staticpath.'classes/InputButton.php');
	$submitButton = new InputButton;
if(get_user_id())
{
	$current_user=get_user_id();
	$contact_user = db_request(db_execute("SELECT CFIELD_40001 as mail,CFIELD_40002 as phone FROM USERS WHERE USER_ID='".$current_user."';"),array(),array());
	$mail=$contact_user[1]['MAIL'];
	$phone=$contact_user[1]['PHONE'];
	echo '['.$phone.']=['.$mail.']';
	//WRITE HEADER
	get_student_info();
	if(!$_REQUEST['include']) 
	{
		if(!$_REQUEST['CREATEPDF'])	
		{
			if(!empty($phone))$header .= $button->createText(_('Send SMS'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=sms');
			if(!empty($mail))$header .= $button->createText(_('Send EMAIL'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=mail');
		}
	}
	elseif($_REQUEST['include']=='sms') 
	{
		if(!empty($phone))$header .= $button->createButton(_('Send SMS'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=sms');
		if(!empty($mail))$header .= $button->createText(_('Send EMAIL'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=mail');
	}
	else 
	{
		if(!empty($phone))$header .= $button->createText(_('Send SMS'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=sms');
		if(!empty($mail))$header .= $button->createButton(_('Send EMAIL'),'modloader.php?servicemod='.$_REQUEST['servicemod'].'&include=mail');
	}
	if(!isset($_REQUEST['CREATEPDF'])) 
		echo TabsHeader($header,$save_button);
	if($_REQUEST['message'] && $_GET['user_id'])
	{
		$array = db_request(db_execute("SELECT CFIELD_40001 as mail,CFIELD_40002 as phone FROM USERS WHERE USER_ID='".$_GET['user_id']."';"),array(),array());
		switch ($_REQUEST['include']) 
		{
			case 'sms':
				echo 'NEED SEND SMS TO '.$array[1]['PHONE'].' sms message['.$_REQUEST['message'].']<br>';				
			break;
			case 'mail':
				echo 'NEED SEND MAIL TO '.$array[1]['MAIL'].' mail message['.$_REQUEST['message'].']<br>';			
			break;
		}
//		var_dump($array);
	//	var_dump($_POST);
		//echo '<br><br><br>';
		//var_dump($_GET);
		//echo '<br><br><br>';
						
	}	
	if(!empty($_REQUEST['include']))
	{
		include_once($staticpath."js/fckeditor/fckeditor.php");
		echo '<FORM name="sender" enctype="multipart/form-data" action="modloader.php?servicemod='.$_REQUEST['servicemod'].'&include='.$_REQUEST['include'].'&user_id='.$current_user.'&servicefunction="send" id="user" method="POST">';
		switch ($_REQUEST['include']) 
		{
			case 'sms':
				echo '<b>'._('Create SMS').': </b>';
				echo '<TEXTAREA NAME="message" cols=50 rows=5></TEXTAREA>';
			break;
			case 'mail':
				echo '<b>'._('Create Mail').': </b>';
				$oFCKeditor = new FCKeditor('message',null,800);
				$oFCKeditor->BasePath = 'js/fckeditor/';
				$oFCKeditor->ToolbarSet = 'Letterhead';
				$oFCKeditor->Width = '800px';
				$oFCKeditor->Height = '300px';
				$oFCKeditor->Value = '';//$array[1]['HEADER'];
				echo '<BR><CENTER>'.$oFCKeditor->Create().'</CENTER>';
			break;
		}
			
			echo '<BR><CENTER>'.$submitButton->createSButton(_('Save')).'</CENTER>';
			echo '</FORM>';
	}
}
else
{
	Search('user_id',$addition);
}
?>