<?php

	include "library.php";

	$cxn = start_code( true );

	$cxn_common = db_common_login();


	$screen_graphics = true;

	$_SESSION['sitename'] = 'MP Workflow System';

	$userid = val( $_SESSION, 'userid' );

		
	if ($userid == "")
	{
		$_SESSION['nextpage'] = url_encode( "/" );

		jump_to_page( "login.php" );		/* must happen before print output */

		exit();
	}


		/* log the hits. remember the original source for conversions */

	if (val( $_GET, "internaljump" ) != "true")
	{
		$source = val( $_GET, "source" );

		if ($source == "")
			$source = "organic";

		$_SESSION['source'] = $source;

		log_hits( $source, $cxn, $cxn_common );
	}
	else
	{
		$source = val( $_SESSION, 'source' );
			
		if ($source == "")
			$source = "organic";

		$_SESSION['source'] = $source;
	}


		// relaod this page after setting the 'screen_width' and 'screen_height' values using javascript
	if (val( $_GET, "screen_width" ) == "" && val( $_SESSION, "screen_width" ) == "")		
		echo "<script language='JavaScript'> document.location=\"index.php?internaljump=true&screen_width=\"+screen.width+\"&screen_height=\"+screen.height; </script>";


	if (val( $_GET, "screen_width" ) != "" && val( $_SESSION, "screen_width" ) == "")
	{
		log_screen_size( $_GET['screen_width'], $_GET['screen_height'], $cxn );

		$_SESSION['screen_width'] = $_GET['screen_width'];
	}



	if (val( $_GET, "noncharging" ) == "true")
		$_SESSION['non_charging_override'] = true;

	$_SESSION['availableoverride'] = val( $_GET, 'availableoverride' );

	$_SESSION['validation_error'] = "false";
	$_SESSION['validation_errors'] = "";

	$_SESSION['session_active'] = "yes";

	page_header( "", $cxn, "", true, true );

	$domain = $_SESSION['domain'];

	$ip_country = get_ip_country( $cxn );
	$ip_country = str_replace( "'", "", $ip_country );
	$country = rawurlencode( $ip_country );

//	echo "<style> html, body {";
//	echo "margin:0;";
//	echo "padding:0;";
//	echo "}";
//	echo "</style>";
//
//	echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td style='line-height: 45px; font-family: Calibri; font-size: 18pt; color: #ffffff; background-color: #004499' align='left'>&nbsp;&nbsp;&nbsp;MP Workflow System</td></tr></table>";
//	
//	echo "<table width='100%'><td width='10%'></td><td align='left' width='20%'></td>";

	echo "<br>";

	echo "</td>";

	echo "<td width='15%' align='center' valign='bottom'>";

	echo "</td><td width='15%'></td></tr></table>";

	if (! low_res_screen())
		echo "<br><br><br>";

	echo "<table width='100%'><tr><td width='20%'></td><td width='15%' align='center' valign='top'>";

	echo "</td><td width='30%'></td><td width='15%' align='center'>";

	echo "</td><td width='20%'></td></tr></table>";

	echo "<br><br>";
	
	$query = "SELECT * FROM user WHERE id = ".$userid;
	
	$result = run_query( $query, $cxn );
	
	$data = get_row( $result );
	
	if ($data['owner_access'] == "Yes")
	{
		echo "<table cellspacing=0 cellpadding=1 width='100%'><tr><td width='8%'></td>";
	
		echo mainmenuheading( "Tasks" );
		echo mainmenuheading( "Reports" );
		echo mainmenuheading( "Add" );
		echo mainmenuheading( "Edit" );
		echo mainmenuheading( "Programs" );
		

		echo "</tr><tr><td width='8%'></td>";
	
	    
	    //  Tasks Reports Add Edit
	    
	
			/* first line of options */
	
		show_menu_option( "", "New Task", "edit_all_data.php", "formname", "task", "newrecord", "true", "readonly", "false" );
		show_menu_option( "", "Profitability", "report_get_dates.php", "reporttype", "profitability", "readonly", "false" );
		show_menu_option( "", "Adviser", "edit_all_data.php", "formname", "adviser", "newrecord", "true", "readonly", "false" );
		show_menu_option( "", "Adviser", "view_records.php", "formname", "adviser", "readonly", "false" );
		show_menu_option( "", "Generate Invoices", "generate_invoices_yes_no.php", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";
	
	
			/* second line of options */
	
		show_menu_option( "", "Edit Task", "edit_get_id.php", "readonly", "false" );
		show_menu_option( "", "Completed Not Invoiced", "reports.php", "reporttype", "completednotinvoiced", "readonly", "false" );
		show_menu_option( "", "Paraplanner", "edit_all_data.php", "formname", "paraplanner", "newrecord", "true", "readonly", "false" );
		show_menu_option( "", "Paraplanner", "view_records.php", "formname", "paraplanner", "readonly", "false" );
		show_menu_option( "", "Send Quotes (test)", "send_quotes.php", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";
	
	
			/* third line of options */
	
		show_menu_option( "", "Task Files", "files_get_id.php", "readonly", "false" );
		show_menu_option( "", "Tasks in Progress", "reports.php", "reporttype", "tasksinprogress", "readonly", "false" );
		show_menu_option( "", "Practice", "edit_all_data.php", "formname", "practice", "newrecord", "true", "readonly", "false" );
		show_menu_option( "", "Practice", "view_records.php", "formname", "practice", "readonly", "false" );
		show_menu_option( "", "Send Invoices (test)", "send_invoices.php", "readonly", "false" );
	
		echo "</tr><tr><td width='8%'></td>";
	
	
			/* fourth line of options */
	
		show_menu_option( "", "Request Attachments", "get_request_id.php" );
		show_menu_option( "", "Not Assigned", "reports.php", "reporttype", "notassigned", "readonly", "false" );
		show_menu_option( "", "User", "edit_all_data.php", "formname", "user", "newrecord", "true", "readonly", "false" );
		show_menu_option( "", "User", "view_records.php", "formname", "user", "readonly", "false" );
		show_menu_option( "", "Send Quotes (live)", "send_quotes.php", "sendit", "true", "readonly", "false" );
	
		echo "</tr><tr><td width='8%'></td>";
	
	
			/* fifth line of options */
	
		show_menu_option( "", "Resource Files", "select_resource_group.php", "readonly", "false" );
		show_menu_option( "", "All Completed", "report_get_dates.php", "reporttype", "allcompletedinperiod", "readonly", "false" );
//		show_menu_option( "", "Advertising", "edit_all_data.php", "formname", "website_advertising_accounts", "newrecord", "true", "readonly", "false" );
//		show_menu_option( "", "Advertising", "view_records.php", "formname", "website_advertising_accounts", "readonly", "false" );
		show_menu_option( "", "Payments", "edit_all_data.php" ,"formname", "paraplanner_payments", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Payments", "view_records.php", "formname", "paraplanner_payments", "readonly", "false" );	
		show_menu_option( "", "Send Invoices (live)", "send_invoices.php", "sendit", "true", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";
	
	
			/* sixth line of options */
	
//		show_menu_option( "", "Advertising", "advertising_reports.php" );
		show_menu_option( "", "Client Download Area", "get_request_id_downloads.php" );
		show_menu_option( "", "Payments Report", "payments_report_get_dates.php", "readonly", "false" );	
		show_menu_option( "", "Resource Groups", "edit_all_data.php" ,"formname", "resource_groups", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Resource Groups", "view_records.php", "formname", "resource_groups", "readonly", "false" );
		show_menu_option( "", "Resend Quote", "get_quote_id.php", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";
	
	
			/* seventh line of options */

		show_menu_option( "", "Display Request", "get_request_id_display_items.php" );	
		show_menu_option( "", "Available Credit Notes", "available_credit_notes.php", "readonly", "false" );	
		show_menu_option( "", "Salaries Accumulated", "edit_all_data.php" ,"formname", "salaries_accumulated", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Salaries Accumulated", "view_records.php", "formname", "salaries_accumulated", "readonly", "false"  );	
		show_menu_option( "", "Resend Invoice", "get_invoice_id.php", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* eighth line of options */
	
		show_menu_option( "", "View/Edit Request Notes", "get_request_id_edit_notes.php" );	
		show_menu_option( "", "Outstanding Invoices", "outstanding_invoices.php", "readonly", "false" );	
		show_menu_option( "", "Quote", "edit_all_data.php" ,"formname", "mpl_quote", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Quote", "view_records.php", "formname", "mpl_quote", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* ninth line of options */
	
		show_menu_option( "", "Logout", "session_kill.php" );			
		show_menu_option( "", "Overdue Invoices", "overdue_invoices.php", "readonly", "false" );	
		show_menu_option( "", "Credit Note", "edit_all_data.php" ,"formname", "mpl_credit_note", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Credit Note", "view_records.php", "formname", "mpl_credit_note", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* tenth' line of options */
	
		echo "<td width='10%'></td>";
		show_menu_option( "", "Unquoted Requests", "reports.php", "reporttype", "unquotedrequests", "readonly", "false" );
		show_menu_option( "", "Invoice", "edit_all_data.php" ,"formname", "mpl_invoice", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Invoice", "view_records.php", "formname", "mpl_invoice", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* Eleventh' line of options */
	
		echo "<td width='10%'></td>";
		echo "<td width='10%'></td>";
		show_menu_option( "", "Invoice Line", "edit_all_data.php" ,"formname", "mpl_invoice_line", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Invoice Line", "view_records.php", "formname", "mpl_invoice_line", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* Twelveth' line of options */

		echo "<td width='10%'></td>";
		echo "<td width='10%'></td>";
		show_menu_option( "", "Financial Planning Practices", "edit_all_data.php" ,"formname", "financial_planning_practices", "newrecord", "true", "readonly", "false" );	
		show_menu_option( "", "Dealer Groups", "view_records.php", "formname", "dealer_groups", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* Thirteenth' line of options */

		echo "<td width='10%'></td>";
		echo "<td width='10%'></td>";
		echo "<td width='10%'></td>";
		show_menu_option( "", "Financial Planning Practices", "edit_fp_practice.php", "newrecord", "false", "readonly", "false" );

		echo "</tr><tr><td width='8%'></td>";


			/* Fourteenth' line of options */

		echo "<td width='10%'></td><td width='7%'></td>";
		echo "<td width='10%'></td><td width='7%'></td>";

		echo "</tr><tr><td width='8%'></td>";

		echo "</tr></table>";
	}
	else
	if ($data['paraplanner_access'] == "Yes")
	{
	
//		echo "<table cellspacing=0 cellpadding=1 width='100%'><tr><td align='center'>".red( "Paraplanner functions" )."</td></tr></table>";
	
		echo "<br><br><br>";
	
		echo "<table width='100%'><tr><td width='8%'></td>";
	
		echo mainmenuheading( "Tasks" );
		echo mainmenuheading( "Reports" );

//		show_menu_option( "", "Claim a Task", "reports.php", "reporttype", "claimatask" );	

		echo "</tr><tr><td width='8%'></td>";

		show_menu_option( "", "View Task", "edit_get_id.php", "readonly", "true" );
		show_menu_option( "", "Tasks in Progress", "reports.php", "reporttype", "tasksinprogress", "readonly", "true" );	

		echo "</tr><tr><td width='8%'></td>";

		show_menu_option( "", "Task Files", "files_get_id.php"  );	
		show_menu_option( "", "All Tasks Completed", "report_get_dates.php", "reporttype", "allcompletedinperiod", "readonly", "true" );

		echo "</tr><tr><td width='8%'></td>";	


		show_menu_option( "", "Request Attachments", "get_request_id.php" );

		
		echo "</tr><tr><td width='8%'></td>";	
		
		show_menu_option( "", "Resource Files", "select_resource_group.php" );					

		echo "</tr><tr><td width='8%'></td>";	


		show_menu_option( "id5", "Logout", "session_kill.php" );			
		
		echo "</tr><tr><td width='8%'></td>";
	
		echo "</tr></table>";
	}
		

	echo "<br><br><br><br><table><tr><td width='8%'></td><td>";

	echo "</td><td width='8%'></td></tr></table>";

    echo "<br>";

?>