<?php
require(DIR_WS_CLASSES.'customers.php');
$id = xtc_db_input($_GET['id']);
$customers = new customers();
$customer = $customers->get_customer($id);

switch($_GET['action']){
	case 'delete_confirm':
		$smarty->assign('BOX_TITLE', $customer->getFullName() );
		$contents = array();
		$contents[] = array('align'=>'center','text' => DELETE_ENTRY );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_DELETE,xtc_href_link(FILENAME_CUSTOMERS,xtc_get_all_get_params(array('action')).'action=delete'),$access='func_customers_delete','width:100px;').'&nbsp;'.yes_draw_href_button(IMAGE_CANCEL,"javascript:ajax_box_action('".$id."','');",$access='customers','width:100px;') );
		
		break;
	case 'change_status':
		$smarty->assign('BOX_TITLE', IMAGE_STATUS );
		$contents = array('form' => xtc_draw_form('pager_box', FILENAME_CUSTOMERS, 'action=update_status') );
		$contents[] = array('align'=>'center','text' => yes_get_customers_status_name($customer->data->customers_status) );
		break;
	default:
		$smarty->assign('BOX_TITLE', $customer->getFullName() );
		$contents = array();
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_OVERVIEW,xtc_href_link(FILENAME_CUSTOMERS,'id='.$id.'&action=overview'),'customers','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_EDIT,xtc_href_link(FILENAME_CUSTOMERS_EDIT,'id='.$id),'customers_edit','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_ADDRESS_BOOKS,xtc_href_link(FILENAME_ADDRESS_BOOKS,'customers_id='.$id),'address_books','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(NEW_QUICKNOTE,"javascript:toggleBox('addquicknote');",'notiz','width:180px;').yes_draw_quicknote( xtc_href_link(FILENAME_CUSTOMERS,'id='.$id.'&action=overview') ) );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_EMAIL, yes_draw_js_popup_href(xtc_href_link(FILENAME_MAILMASTER,'customers_id='.$id)),'mailmaster','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_DELETE,"javascript:ajax_box_action('".$id."','delete_confirm');",'func_customers_delete','width:180px;') );
		$contents[] = array('align'=>'left','text' => '<br />'.TEXT_DATE_CREATED.': '.xtc_date_short($customer->data->customers_date_added) );
		if($customer->data->customers_last_modified > 0)
			$contents[] = array('align'=>'left','text' => TEXT_DATE_LAST_MODIFIED.': '.xtc_date_short($customer->data->customers_last_modified) );
		
		break;
}

$box = new box;
$smarty->assign('BOX_CONTENT', $box->infoBox($contents) );
