accounts2

[insert_php]
//**********************************
// for date picker
//**********************************
wp_enqueue_script(‘jquery-ui-datepicker’);
wp_enqueue_style(‘jquery-style’, ‘https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css’);

//*********************************************
// check for user logged in with right privileges
//*********************************************
$loggedin = false;
global $current_user;
get_currentuserinfo();
if(!$current_user->user_login == ” ) {
$level = $current_user->user_level;
if ($level > 5) {
$loggedin = true;
$sysmsg = “User can edit.”;
} else {
$sysmsg = “User cannot edit.”;
}
} else {
$sysmsg = “User cannot edit.”;
}

// ************************
// initialise
// ************************
$thisyear = date(‘Y’);
$nextyear = date(‘Y’, strtotime(‘+ 1year’));
$lastyear = date(‘Y’, strtotime(‘- 1year’));
$prevyear = date(‘Y’, strtotime(‘- 2year’));

$msg = “”;
$arr4 = getincometypes();
$arr5 = getexpendituretypes();
// ************************
//process each selection
// ***********************
if(isset($_POST[‘loadss’])){
setyear($_POST[‘ayear’]);
}

if(isset($_POST[‘save1’])){
if ($loggedin) {
$msg .= saveincome($_POST);
}
}
if(isset($_POST[‘save2’])){
if ($loggedin) {
$msg .= saveexpenditure($_POST);
}
}

if(isset($_POST[‘del1’])){
if ($loggedin) {
$tn = “income”;
$msg .= delrow($_POST[‘row’], $tn);
}
}
if(isset($_POST[‘del2’])){
if ($loggedin) {
$tn = “expenditure”;
$msg .= delrow($_POST[‘row’], $tn);
}
}
if(isset($_POST[‘printss’])){
if ($loggedin) {
$msg .= printss($_POST[‘ayear’]);
}
}
//*****************************************
$ayear = getyear();
$arr1 = getincome($ayear);
$msg .= $arr1[0][5] . ” “;
$arr2 = getexpenditure($ayear);
$msg .= $arr2[0][6];
//************************
// get income totals
//************************
$tots = getincometotals($ayear);
$grandtotalinc = $tots[‘income’];

//************************
// calculate expenditure totals
//************************
$exptot=0.0;
for ($i=0;$i < sizeof($arr2); $i++) { $exptot+= $arr2[$i][4]; } $exptot+=$totfees; $grandtotalexp = number_format(($exptot),2,'.', ''); //************************************** // Display //************************************* echo "Add a row. Scroll down to the bottom of the spreadsheet in question, and enter in the data.
“;
echo “Note 1: A new row will only be saved if a date has been entered.
“;
echo “Note 2: You may only save one NEW row at a time. You can, though, save multiple changes to the existing spreadsheet.
“;
echo “Save the spreadsheet Press Save for the spreadsheet in question.
“;
echo “Delete a row. Enter the row (ID) number in the box next to the Delete button and press Delete.
“;
echo “User access level: ” . $sysmsg . “
“;
echo “System message: ” . $msg . “
“;
//**************************************
echo “

“;
echo “

“;
echo “Select year: “;
echo ““;
echo ”   “;
echo ” “;
echo “

“;
//*****************************************
echo “

“;
echo “

Income

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;

for ($i=0; $i <= sizeof($arr1); $i++) { echo "

“;
for ($j = 0; $j < 5; $j++) { if ($j == 0) { echo "

“;
} else {
echo “

“;
}
}
echo “

“;
}
echo “

ID Date “;
echo “Category
Amount Note
“;
echo ““;
} else if ($j == 2) {
echo “

“;

echo “ “;
echo ”   Row ID Nr. “;
echo “

“;
echo “

Totals: Single: ” . $tots[‘single’] . ” – Joint: ” . $tots[‘joint’] . ” – Student: ” . $tots[‘student’] . ” – Retired Single: ” . $tots[‘retsingle’] . ” – Retired Joint: ” . $tots[‘retjoint’] . ” – Institution: ” . $tots[‘instit’] . ” – Donate: ” . $tots[‘donate’] . ” – Goods: ” . $tots[‘goods’] . “

“;
echo “

Income Total: £” . number_format($grandtotalinc,2) . “

“;
echo “

“;

//***************************************************************
// display expenditure table
//***************************************************************
echo “

Expenditure

“;
echo “

“;
echo”

“;
for ($i=0; $i <= sizeof($arr2); $i++) { echo " “;
for ($j = 0; $j < 6; $j++) { if ($j == 0) { echo "

“;
} else {
echo “

“;
}
}
echo “

“;
}
echo “

ID Date Category Payee Amount Note
“;
echo ““;
} else if ($j == 2) {
echo “

“;
echo “ “;
echo ”   Row ID Nr. “;
echo “

“;
echo “

PayPal fees: £” . $tots[‘fees’] . “

“;
echo “

Expenditure Total: £” . number_format($grandtotalexp,2) . “

“;
echo “

Overall Balance: £” . number_format(($grandtotalinc-$grandtotalexp),2,’.’, ”) .”

“;
echo “

“;

//***************************************************
// Javascript for the date picker display
//***************************************************
echo ““;

[/insert_php]