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

📄 payment.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		$no_update = 1;
	}
	$cols = array(
		'User', 
		'Technician', 
		'Ticket ID',
		'Time', 
		'Charge', 
		"Paid $paid_js",
		"Billable $bill_js",
		'Date/Time'
	);
} else {
	$cols = array(
		iff($_REQUEST['bytech'], 'Technician', 'User'),
		'Time', 
		'Charge'
	);
}

$total_users = array();
$total_techs = array();
$total_tickets = array();
$total_time = 0;
$total_charge = 0;
$total_billable = 0;
$total_unbillable = 0;
$total_paid = 0;
$total_unpaid = 0;

while ($res = $db->row_array()) {
	if ($_REQUEST['daily_tech']) {
		$daily_tech[date('Y-m-d', $res['stamp'])][$res['techid']]['charge'] += $res['charge'];
		$daily_tech[date('Y-m-d', $res['stamp'])][$res['techid']]['time'] += $res['time'];
	}

	if ($_REQUEST['daily_user']) {
		$daily_user[date('Y-m-d', $res['stamp'])][$res['userid']]['charge'] += $res['charge'];
		$daily_user[date('Y-m-d', $res['stamp'])][$res['userid']]['time'] += $res['time'];
	}

	if ($detail) {
		$rows[] = array(
			$res['username'], 
			$res['techname'], 
			$res['ticketid'], 
			clean_time($res['time']), 
			sprintf('%01.2f', $res['charge']), 
			form_checkbox_single('ispaid[]', $res['id'], iff($res['paid'], 1, 0)), 
			form_checkbox_single('isbillable[]', $res['id'], iff($res['billable'], 1, 0)),
			date('r', $res['stamp'])
		);
		$ids[] = $res['id'];
	} else {
		$rows[] = array(
			iff($_REQUEST['bytech'], $res['techname'], $res['username']), 
			clean_time($res['time']), 
			sprintf('%01.2f', $res['charge'])
		);
	}
	$total_users[$res['userid']]++;
	$total_techs[$res['techid']]++;
	$total_tickets[$res['ticketid']]++;
	$total_time += $res['time'];
	$total_charge += $res['charge'];
	$total_billable += (iff($res['billable'], 1, 0));
	$total_unbillable += (iff(!$res['billable'], 1, 0));
	$total_paid += (iff($res['paid'], 1, 0));
	$total_unpaid += (iff(!$res['paid'], 1, 0));
	if ($total_earliest) {
		$total_earliest = (iff(($res['stamp'] < $total_earliest), $res['stamp'], $total_earliest));
	} else {
		$total_earliest = $res['stamp'];
	}
	$total_latest = (iff(($res['stamp'] > $total_latest), $res['stamp'], $total_latest));
}

if (count($rows) > 0) {
	if ($detail) {
		$rows[] = array(
			'<HR><B>' . count($total_users) . '</B> user(s)<BR>&nbsp;',
			'<HR><B>' . count($total_techs) . '</B> tech(s)<BR>&nbsp;',
			'<HR><B>' . count($total_tickets) . '</B> ticket(s)<BR>&nbsp;',
			'<HR><B>' . clean_time($total_time) . '</B><BR>&nbsp;',
			'<HR><B>' . sprintf('%01.2f', $total_charge) . '</B><BR>&nbsp;',
			"<HR><B>$total_paid</B> paid<BR><B>$total_unpaid</B> unpaid",
			"<HR><B>$total_billable</B> billable<BR><B>$total_unbillable</B> unbillable",
			'<HR><B>' . date('D M jS Y g:i:sa', $total_earliest) . '</B> to<BR><B>' . date('D M jS Y g:i:sa', $total_latest) . '</B>'
		);
	} else {
		$rows[] = array(
			'<HR><B>' . count($total_users) . '</B>' . iff($_REQUEST['bytech'], ' tech(s)', ' user(s)') . '<BR>&nbsp;',
			'<HR><B>' . clean_time($total_time) . '</B><BR>&nbsp;',
			'<HR><B>' . sprintf('%01.2f', $total_charge) . '</B><BR>&nbsp;'
		);
	}
} else {
	$rows[] = array('<B>No items found.</B>');
}

$db->query("SELECT username, id FROM tech ORDER BY username");
$techs[0] = 'Include All Techs';
while ($result = $db->row_array()) {
	$techs[$result[id]] = $result[username];
}

$db->query("SELECT username, id FROM user ORDER BY username");
$users[0] = 'Include All Users';
while ($result = $db->row_array()) {
	$users[$result[id]] = $result[username];
}

$form[] = array('<FORM METHOD="post" ACTION="payment.php"><B>Limit report to:</B>', 
	'<TABLE><TR><TD>Techs:</TD><TD>Users:</TD></TR>
	<TR><TD>'. form_select('techid', $techs, '', $_REQUEST['techid'], 0, '', 4) . '</TD><TD>' .
	form_select('userid', $users, '', $_REQUEST['userid'], 0, '', 4) . '</TD></TR></TABLE>');
$form[] = array('<B>Show Items Occuring in Range:</B>',
	form_date('start', '', '', '', '', date('Y-m-d', $start)) . ' to ' . 
	form_date('end', '', '', '', '', date('Y-m-d', $end)));
$form[] = array('<B>Show Detailed View:</B>',
	form_checkbox_single('detail', 1, $detail) . 'Detail View');
$form[] = array('<B>Search Entry Types:</B>',
	'<TABLE><TR><TD><B>Billable</B>' .
		form_radio_single('billable', '0', iff(($billable == 0), 1, 0)) . 'Non-billable only<BR>' .
		form_radio_single('billable', '1', iff(($billable == 1), 1, 0)) . 'Billable only<BR>' .
		form_radio_single('billable', '2', iff(($billable == 2), 1, 0)) . 'Both' .
		'</TD><TD><B>Paid</B>' .
		form_radio_single('paid', '0', iff(($paid == 0), 1, 0)) . 'Unpaid only<BR>' .
		form_radio_single('paid', '1', iff(($paid == 1), 1, 0)) . 'Paid only<BR>' .
		form_radio_single('paid', '2', iff(($paid == 2), 1, 0)) . 'Both' .
		'</TD></TR></TABLE>'
	);
$form[] = array('<B>Show Details for Ticket:</B>',
	'Ticket # ' . form_input('ticketid', iff($ticketid, $ticketid, ''), 10)
);
$form[] = array('<B>Summarize By:</B><BR><I>Summary views only; ignored in detail views</I>',
	form_radio_single('bytech', '0', iff($_REQUEST['bytech'], 0, 1)) . ' by User ' .
	form_radio_single('bytech', '1', iff($_REQUEST['bytech'], 1, 0)) . ' by Technician '
	);
$form[] = array('<B>Show Daily Totals by Tech</B>',
	form_radio_yn('daily_tech', '', $_REQUEST['daily_tech']));
$form[] = array('<B>Show Daily Totals by User</B>',
	form_radio_yn('daily_user', '', $_REQUEST['daily_user']));
$form[] = array('<B>Update View</B>', form_submit('Update'));

$this_month_start = strtotime("$now[0]-$now[1]-01");
$last_month_start = explode('-', date('Y-m', strtotime(date('Y-m-d', $this_month_start) . ' -1 month')));
$last_month_end = explode('-', date('Y-m-d', strtotime(date('Y-m-d', $this_month_start) . ' -1 second')));

$summaries_bu[] = '<A HREF="payment.php?billable=1">All Billable (this month)</A>';
$summaries_bu[] = '<A HREF="payment.php?paid=0&billable=1">Unpaid Billable (this month)</A>';
$summaries_bu[] = "<A HREF=\"payment.php?paid=0&billable=1&ystart=$last_month_start[0]&mstart=$last_month_start[1]&dstart=1&yend=$last_month_end[0]&mend=$last_month_end[1]&dend=$last_month_end[2]\">Unpaid Billable (last month)</A>";
$summaries_bu[] = '<A HREF="payment.php?paid=0&billable=1&alldates=1">Unpaid Billable (all)</A>';
$summaries_bt[] = '<A HREF="payment.php?bytech=1&billable=1">All Billable (this month)</A>';
$summaries_bt[] = '<A HREF="payment.php?paid=0&billable=1&bytech=1">Unpaid Billable (this month)</A>';
$summaries_bt[] = "<A HREF=\"payment.php?paid=0&billable=1&bytech=1&ystart=$last_month_start[0]&mstart=$last_month_start[1]&dstart=1&yend=$last_month_end[0]&mend=$last_month_end[1]&dend=$last_month_end[2]\">Unpaid Billable (last month)</A>";
$summaries_bt[] = '<A HREF="payment.php?paid=0&billable=1&alldates=1&bytech=1">Unpaid Billable (all)</A>';

$details[] = '<A HREF="payment.php?billable=1&detail=1">All Billable (this month)</A>';
$details[] = '<A HREF="payment.php?paid=0&billable=1&detail=1">Unpaid Billable (this month)</A>';
$details[] = "<A HREF=\"payment.php?paid=0&billable=1&detail=1&ystart=$last_month_start[0]&mstart=$last_month_start[1]&dstart=1&yend=$last_month_end[0]&mend=$last_month_end[1]&dend=$last_month_end[2]\">Unpaid Billable (last month)</A>";
$details[] = '<A HREF="payment.php?paid=0&billable=1&detail=1&alldates=1">Unpaid Billable (all)</A>';

$prebuilds = array(
	'<TABLE><TR><TD><B><U>Summaries (by User):</U></B><BR>' . join('<BR>', $summaries_bu) . '</TD><TD>&nbsp</TD>' .
	'<TD><B><U>Summaries (by Technician):</U></B><BR>' . join('<BR>', $summaries_bt) . '</TD><TD>&nbsp;</TD>' .
	'<TD><B><U>Detail Views:</U></B><BR>' . join('<BR>', $details) . '</TD></TR></TABLE>'
);

if ($queries) {
	print '<B>Item(s) updated.</B><BR>';
}

print '<B>Showing: </B>' . join('; ', $criteria) . '<BR>';
if ($warnings) {
	print '<B>Warnings: </B>' . join('; ', $warnings) . '<BR>';
}

print '<BR>';

?>

<?

if ($daily_tech) {
	$d_rows = array();
	$techs = $db->query_return_array_id("SELECT username, id FROM tech", 'username');
	foreach ($daily_tech AS $date => $val) {
		$d_rows[] = array('<B>'.our_date(strtotime($date), 'day').'</B>');
		foreach ($val AS $tech => $data) {
			$d_rows[] = array($techs[$tech], sprintf('%01.2f', $data['charge']), clean_time($data['time']));
		}
	}
	$d_cols = array('Technician', 'Charge', 'Time');
	table_header('Daily Totals by Technician');
	table_content($d_cols, $d_rows);
	table_footer();
}

if ($daily_user) {
	$d_rows = array();
	$users = $db->query_return_array_id("SELECT username, id FROM user", 'username');
	foreach ($daily_user AS $date => $val) {
		$d_rows[] = array('<B>'.our_date(strtotime($date), 'day').'</B>');
		foreach ($val AS $usr => $data) {
			$d_rows[] = array($users[$usr], sprintf('%01.2f', $data['charge']), clean_time($data['time']));
		}
	}
	$d_cols = array('User', 'Charge', 'Time');
	table_header('Daily Totals by User');
	table_content($d_cols, $d_rows);
	table_footer();
}
print "</FORM>";

print '<FORM METHOD="POST" ACTION="payment.php" NAME="res" ID="res">';

table_header('Results');
table_content($cols, $rows);
table_footer();

print form_hidden('techid', $_REQUEST['techid']);
print form_hidden('userid', $_REQUEST['userid']);
print form_hidden('ystart', $_REQUEST['ystart']);
print form_hidden('mstart', $_REQUEST['mstart']);
print form_hidden('dstart', $_REQUEST['dstart']);
print form_hidden('yend', $_REQUEST['yend']);
print form_hidden('mend', $_REQUEST['mend']);
print form_hidden('dend', $_REQUEST['dend']);
print form_hidden('detail', $_REQUEST['detail']);
print form_hidden('billable', $_REQUEST['billable']);
print form_hidden('paid', $_REQUEST['paid']);
print form_hidden('ticketid', $_REQUEST['ticketid']);
print form_hidden('bytech', $_REQUEST['bytech']);
if (is_array($ids)) {
	print form_hidden('ids', join(',', $ids));
}

if (!$no_update) {
	print form_submit('Update Items') . '</FORM><BR>';
}

table_header('Quick Reports');
table_content('', $prebuilds);
table_footer();

table_header('Report Options');
table_content('', $form);
table_footer();

?>

</FORM>

<SCRIPT LANGUAGE="JavaScript">
function checkall(field) {
	field.checked = true;
	for (var i = 0; i < field.length; i++) 
		field[i].checked = true ;
}

function uncheckall(field) {
	field.checked = false;
	for (var i = 0; i < field.length; i++) 
		field[i].checked = false;
}
</SCRIPT>

⌨️ 快捷键说明

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