⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
// any dates? use current
if (!$year) {
	$year = $today_y;
}
if (!$month) {
	$month = $today_m;
}
if (!$day) {
	$day = $today_d;
}

if(!$date) {
	$date = $year . '-' . $month . '-' . $day;
}

$named_day = $day;
$named_month =  date('M', mktime(0,0,0,$month,$day,$year));
$named_year = $year;

$taskstoday = 0;
$taskstoday_overdue = 0;
$tasks_today = cachetasks($today, $today, 1);
if (is_array($tasks_today)) {
	foreach($tasks_today AS $date_tmp => $tasks) {
		foreach ($tasks AS $task) {
			if ($date_tmp != $today) {
				$taskstoday_overdue++;
			} else {
				$taskstoday++;
			}
		}
	}
}

if ($taskstoday_overdue) {
	$taskstoday = "$taskstoday/$taskstoday_overdue*";
}

#####################################################################################
############################### PAGE NAVIGATION ###############################
#####################################################################################

$hidden = form_hidden('do', $_REQUEST['do']) . form_hidden('type', $_REQUEST['type']);
$hidden .= form_hidden('overdue', $_REQUEST['overdue']);

if ($_REQUEST['do'] == 'yearly') {

	$year_before = $year - 1;
	$year_after = $year + 1;

	$jump_one = form_submit($year_before) . form_hidden('year', $year_before) . $hidden;
	$jump_two = form_submit($year_after) . form_hidden('year', $year_after) . $hidden;

	$jump_date = form_date('date', '', '', '', '', $date, array('y'));

} elseif ($_REQUEST['do'] == 'daily' OR ($_REQUEST['do'] == 'weekly' AND $_REQUEST['type'] == 'calendar')) {

	$date_before = date("Y-m-d", strtotime("$date -1 day"));
	$date_b = explode('-', $date_before);
	$date_after = date("Y-m-d", strtotime("$date +1 day"));
	$date_a = explode('-', $date_after);

	if ($_REQUEST['do'] == 'weekly') {

		if (!$week) {
			$week = week_number("$year-$month-$day");
		}

		if ($week == 1) {
			$last_year_weeks = (int)strftime('%W',strtotime("Dec 31 " . ($year-1)));

			$jump_one = form_submit("Week $last_year_weeks, " . ($year - 1)) .
				$hidden . form_hidden('year', $year - 1) . form_hidden('week',
				$last_year_weeks);

		} else {

			$jump_one = form_submit("Week " . ($week - 1) . ", $year") .
				$hidden . form_hidden('year', $year) . form_hidden('week', $week - 1);

		}

		$nextweekdate = start_of_week($week + 1, $year);
		$nextweeknum = (int)week_number(date('Y-m-d', $nextweekdate));

		$weeks = (int)strftime('%W',strtotime("Dec 31 $year"));
		if ($nextweeknum >= $weeks) {

			$jump_two = form_submit("Week 1, " . ($year + 1)) . $hidden .
				form_hidden('year', $year+1) . form_hidden('week', 1);

		} else {

			$jump_two = form_submit("Week " . ($week + 1) . ", $year") .
				$hidden . form_hidden('year', $year) . form_hidden('week', $week + 1);
		}

		$jump_date .= "  Week " . 
			form_select('week', range(1, $weeks), '', $week, 1) . 
			form_date_year('year', $year);

	} else {

		$jump_one = form_submit(format_date($date_before)) . $hidden .
			form_hidden('month', $date_b[1]) . 
			form_hidden('year', $date_b[0]) .
			form_hidden('day', $date_b[2]); 
		
		$jump_two = form_submit(format_date($date_after)) . $hidden . 
			form_hidden('month', $date_a[1]) . 
			form_hidden('year', $date_a[0]) . 
			form_hidden('day', $date_a[2]);

		$jump_date = form_date('date', '', '', '', '', $date);
	}

} elseif ($_REQUEST['do'] == 'weekly' && $_REQUEST['type'] == 'list') {

	if (!$week) {
		$week = week_number("$year-$month-$day");
	}

	if ($week == 1) {
		$last_year_weeks = (int)strftime('%W',strtotime("Dec 31 " . ($year-1)));

		$jump_one = form_submit("Week $last_year_weeks, " . ($year - 1)) .
			$hidden . form_hidden('year', $year - 1) . form_hidden('week',
			$last_year_weeks);
	} else {

		$jump_one = form_submit("Week " . ($week - 1) . ", $year") . $hidden .
			form_hidden('year', $year) . form_hidden('week', $week - 1);
	}

	$nextweekdate = start_of_week($week + 1, $year);
	$nextweeknum = (int)week_number(date('Y-m-d', $nextweekdate));

	$weeks = (int)strftime('%W',strtotime("Dec 31 $year"));
	if ($nextweeknum >= $weeks) {

		$jump_two = form_submit("Week 1, " . ($year + 1)) . $hidden .
			form_hidden('year', $year+1) . form_hidden('week', 1);
	} else {

		$jump_two = form_submit("Week " . ($week + 1) . ", $year") . $hidden .
			form_hidden('year', $year) . form_hidden('week', $week + 1);
	}

	$jump_date = "Week " . form_select('week', range(1, $weeks), '', $week, 1) . 
		' ' . form_date_year('year', $year);

} elseif ($_REQUEST['do'] == 'monthly') {

	if ($month == 1) {
		$month_before = 12;
		$month_after = 2;
		$year_before = $year - 1;
		$year_after = $year;
	} elseif ($month == 12) {
		$month_before = 11;
		$month_after = 1;
		$year_before = $year;
		$year_after = $year + 1;
	} else {
		$month_before = $month - 1;
		$month_after = $month + 1;
		$year_before = $year;
		$year_after = $year;
	}

	$jump_one = form_submit(month_name($month_before)) . $hidden .
		form_hidden('month', $month_before) . form_hidden('year', $year_before);

	$jump_two = form_submit(month_name($month_after)) . $hidden .
		form_hidden('month', $month_after) . form_hidden('year', $year_after);

	$jump_date = form_date('date', '', '', '', '', $date, array('m', 'y'));
}

$nav = "<table width=\"100%\"><form><tr>
		<form method=\"post\" action=\"index.php\"><td>$jump_one</td></form>
		<form method=\"post\" action=\"index.php\">$hidden<td align=\"center\">$jump_date" . form_submit('Go') . "</td></form>
		<form method=\"post\" action=\"index.php\"><td align=\"right\">$jump_two</td></form>
		</tr></table>
		";

// Echo the page navigation header

$tw_both_nav_off="<a href=\"index.php?do=$_REQUEST[do]&type=$_REQUEST[type]&watch=0&year=$_REQUEST[year]&month=$_REQUEST[month]&day=$_REQUEST[day]&overdue=$_REQUEST[overdue]\">Both</a>";
$tw_watc_nav_off="<a href=\"index.php?do=$_REQUEST[do]&type=$_REQUEST[type]&watch=1&year=$_REQUEST[year]&month=$_REQUEST[month]&day=$_REQUEST[day]&overdue=$_REQUEST[overdue]\">Ticket Watches</a>";
$tw_norm_nav_off="<a href=\"index.php?do=$_REQUEST[do]&type=$_REQUEST[type]&watch=2&year=$_REQUEST[year]&month=$_REQUEST[month]&day=$_REQUEST[day]&overdue=$_REQUEST[overdue]\">Normal Events</a>";
$tw_both_nav_on="[Both]";
$tw_watc_nav_on="[Ticket Watches]";
$tw_norm_nav_on="[Normal Events]";

switch ($_REQUEST['watch']) {
	default:
	case '0':
		$ticketwatch_nav = "$tw_both_nav_on&nbsp;$tw_watc_nav_off&nbsp;$tw_norm_nav_off";
		$watch = 0;
		break;
	case '1':
		$ticketwatch_nav = "$tw_both_nav_off&nbsp;$tw_watc_nav_on&nbsp;$tw_norm_nav_off";
		$watch = 1;
		break;
	case '2':
		$ticketwatch_nav = "$tw_both_nav_off&nbsp;$tw_watc_nav_off&nbsp;$tw_norm_nav_on";
		$watch = 2;
		break;
}

if (!$_REQUEST['overdue']) {
	$overdue = get_tasks(1);
	if ($overdue == 1) {
		$overdues = "<a href=\"index.php?do=daily&type=list&overdue=1" . iff($_REQUEST['search'], $search_url . "&search=$_REQUEST[search]&taskid=$_REQUEST[taskid]") . "\"><FONT COLOR=\"red\">1 overdue item</font></a>";
	} elseif ($overdue > 1) {
		$overdues = "<a href=\"index.php?do=daily&type=list&overdue=1" . iff($_REQUEST['search'], $search_url . "&search=$_REQUEST[search]&taskid=$_REQUEST[taskid]") . "\"><FONT COLOR=\"red\">$overdue overdue items</font></a>";
	}
}

echo "

<table><tr><td valign=\"top\" width=\"100%\">

<table width=\"440\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr> 
	<td width=\"5\" bgcolor=\"#BF4343\">&nbsp;</td>
    
	<td width=\"435\">
	<table width=\"435\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">
        <tr> 
          <td width=\"90\" height=\"20\" class=\"calendar1\">" . html_image('tech/bul089.gif', 'Calendar', 0, 0, 'hspace="5"') . "<strong>Calendar</strong></td>

          <td width=\"42\" align=\"center\" class=\"calendar1\">" . 
		  iff($_REQUEST['do'] == 'daily' AND $_REQUEST['type'] == 'calendar', '<strong>Day</strong>', "<a href=\"index.php?do=daily&type=calendar&watch=$watch&$year=year&month=$month&day=$day\" class=\"calendar1\">Day</a>") . "</td>

          <td width=\"43\" align=\"center\" class=\"calendar1\">" . 
		  iff($_REQUEST['do'] == 'weekly' AND $_REQUEST['type'] == 'calendar', '<strong>Week</strong>', "<a href=\"index.php?do=weekly&type=calendar&watch=$watch&year=$year&month=$month&day=$day\" class=\"calendar1\">Week") . "</td></td>

          <td width=\"51\" align=\"center\" class=\"calendar1\">" . 
		  iff($_REQUEST['do'] == 'monthly' AND $_REQUEST['type'] == 'calendar', '<strong>Month</strong>', "<a href=\"index.php?do=monthly&type=calendar&watch=$watch&year=$year&month=$month&day=$day\" class=\"calendar1\">Month</a>") . "</td>

          <td width=\"43\" align=\"center\" class=\"calendar1\">" . 
		  iff($_REQUEST['do'] == 'yearly' AND $_REQUEST['type'] == 'calendar', '<strong>Year</strong>', "<a href=\"index.php?do=yearly&type=calendar&watch=$watch&year=$year&month=$month&day=$day\" class=\"calendar1\">Year</a>") . "</td>

          <td width=\"75\" align=\"center\" class=\"calendar1\">&nbsp;</td>
          <td width=\"82\" align=\"center\" class=\"calendar1\">" . iff(($its_today AND $_REQUEST['type'] == 'calendar'), "Today ($taskstoday)", "<a href=\"index.php?do=daily&type=calendar&watch=$watch&year=$today_y&month=$today_m&day=$today_d\" class=\"calendar1\">Today ($taskstoday)</a>") . "</td>
        </tr>
        <tr> 
          <td colspan=\"7\"><img src=\"../../images/spacer.gif\" width=\"5\" height=\"5\"></td>
        </tr>
        <tr> 
          <td height=\"20\" bgcolor=\"#DADADA\">" . html_image('tech/bul090.gif', 'Tasks', 0, 0, 'hspace="5"') . "Tasks</td>

          <td align=\"center\" bgcolor=\"#DADADA\">" . 
		  iff($_REQUEST['do'] == 'daily' AND $_REQUEST['type'] == 'list', '<strong>Day</strong>', "<a href=\"index.php?do=daily&type=list&watch=$watch&year=$year&month=$month&day=$day\">Day</a>") . "</td>

          <td align=\"center\" bgcolor=\"#DADADA\">" . 
		  iff($_REQUEST['do'] == 'weekly' AND $_REQUEST['type'] == 'list', '<strong>Week</strong>', "<a href=\"index.php?do=weekly&type=list&watch=$watch&year=$year&month=$month&day=$day\">Week</a>") . "</td>

          <td align=\"center\" bgcolor=\"#DADADA\">" . 
		  iff($_REQUEST['do'] == 'monthly' AND $_REQUEST['type'] == 'list', '<strong>Month</strong>', "<a href=\"index.php?do=monthly&type=list&watch=$watch&year=$year&month=$month&day=$day\">Month</a>") . "</td>

          <td align=\"center\" bgcolor=\"#DADADA\">" . 
		  iff($_REQUEST['do'] == 'yearly' AND $_REQUEST['type'] == 'list', '<strong>Year</strong>', "<a href=\"index.php?do=yearly&type=list&watch=$watch&year=$year&month=$month&day=$day\">Year</a>") . "</td>

          <td align=\"center\" bgcolor=\"#DADADA\">&nbsp;</td>
          <td align=\"center\" bgcolor=\"#DADADA\">" . iff(($its_today AND $_REQUEST['type'] == 'list'), "Today ($taskstoday)", "<a href=\"index.php?do=daily&type=list&watch=$watch&year=$today_y&month=$today_m&day=$today_d\" >Today ($taskstoday)</a>") . "</td>
        </tr>
        <tr> 
          <td colspan=\"7\"><img src=\"../../images/spacer.gif\" width=\"5\" height=\"5\"></td>
        </tr>
        <tr> 
          <td colspan=\"7\" align=\"center\">
			$nav
		  </td>
        </tr>
      </table>
	  &nbsp;&nbsp;&nbsp;<b>Event type(s) to display:</b> $ticketwatch_nav
	  <center>$overdues</center>
</td></tr></table>";


// Show the search form.

if ($_REQUEST['yenddate'] && $_REQUEST['menddate'] && $_REQUEST['denddate']) {
	$ed = $_REQUEST['yenddate'].'-'.$_REQUEST['menddate'].'-'.$_REQUEST['denddate'];
} else {
	$ed = $date;
}

if ($_REQUEST['ystartdate'] && $_REQUEST['mstartdate'] && $_REQUEST['dstartdate']) {
	$sd = $_REQUEST['ystartdate'].'-'.$_REQUEST['mstartdate'].'-'.$_REQUEST['dstartdate'];
} else {
	$sd = '';
}

switch ($_REQUEST['completed']) {
	case 'all':
		$all = 'checked'; break;
	case 'complete':
		$complete = 'checked'; break;
	case 'incomplete':
		$incomplete = 'checked'; break;
}

if ($search) {
	if (is_array($_REQUEST['techs'])) {
		$techs = join("|", $_REQUEST['techs']);
	} else {
		$techs = '';
	}

	$search_url = 'title=' . htmlspecialchars_uni($_REQUEST['title']) .
		'&description=' . htmlspecialchars_uni($_REQUEST['description']) .
		"&ystartdate=$_REQUEST[ystartdate]".
		"&mstartdate=$_REQUEST[mstartdate]".
		"&dstartdate=$_REQUEST[dstartdate]".
		"&yenddate=$_REQUEST[yenddate]".
		"&menddate=$_REQUEST[menddate]".
		"&denddate=$_REQUEST[denddate]".
		"&completed=$_REQUEST[completed]".
		"&techs=$techs";
		
	$midbox = "<B>Viewing&nbsp;Search&nbsp;Results</B>&nbsp;&nbsp;<BR><A HREF=\"search.php?$search_url\">Edit&nbsp;Search</A>&nbsp;&nbsp;<A HREF=\"search.php\">Start&nbsp;a&nbsp;New&nbsp;Search</A>&nbsp;&nbsp;<BR><BR>$midbox";
	
	echo "<br /><center>$midbox</center>";
}

echo "</td><td align=\"right\" valign=\"top\">";

$task_table = "<table><form method=\"post\" action=\"index.php\">
	<tr><td>" . 
	form_input('title', 'Title ...', 20, '', '', "onfocus=\"this.value='';\"") . 
	" <a href=\"new.php\">Advanced Options</a></td></tr><tr><td>" . 
	form_textarea('description', 40, 4, 'Message ...', '', '',  "onfocus=\"this.value='';\"") . 
	"</td></tr><tr><td>" . 
	$hidden . 
	form_hidden('addentry', 1) . 
	form_hidden('month', $month) . 
	form_hidden('year', $year) . 
	form_hidden('day', $day) . 
	form_date('date', '', '', '', '', $date) . 
	form_submit('Add') .  
	"&nbsp;" . thelp('Calendar', 'Quick Add Task') . 
	"</td></tr></form></table>";

fancy_table('100%', "Add a Quick Task", $task_table);

echo "</td></tr></table>";

#####################################################################################
########################### GET CACHED DATA FOR DATE RANGE ##############################
#####################################################################################

########################### MONTHLY VIEW ##############################

if ($_REQUEST['do'] == "monthly" AND $_REQUEST['type'] == "list") {
	if ($search) {

		if (!validate_ymd($startdate)) {
			$startdate = '1970-01-01';
		}
		if (!validate_ymd($enddate)) {
			$enddate = date('2038-01-19');
		}
		if ($search == 'upcoming') {
			$data = cachetasks($startdate, $enddate, 1, NULL, NULL, NULL, NULL, $watch);
		} else {
			$data = cachetasks($startdate, $enddate, $_REQUEST['completed'],
				$_REQUEST['title'], $_REQUEST['description'], $_REQUEST['taskid'],
				$_REQUEST['techs'], $watch);
		}
	} else {
		$enddate = date('Y-m-d', strtotime(date('Y-m-d', strtotime("$year-$month-01 +1 month")) . " -1 days"));
		$enddate_tmp = explode('-', $enddate);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -