allmem = array(); $this->username = ""; $this->password = ""; $this->member = ""; $this->year = date('Y'); } function check_username($username){ global $database; $sql="SELECT * FROM memberinfo WHERE username='".$username."'"; $result_set = $database->query($sql); $value= $database->fetch_array($result_set); $member = new memberObject($_SESSION['memberid']); return ($database->num_rows($result_set)===0); } function addMember($info){ global $database; if ($info['adstatus']=="non") {$info['adstatus']="";} $fname = $database->escape_value($info['fname']); $lname = $database->escape_value($info['lname']); $aclass = $database->escape_value($info['aclass']); $sql = "INSERT INTO memberinfo ("; $sql .= "lname, fname, class, mgstatus, admin_status"; $sql .= ") VALUES ('"; $sql .= $lname ."', '"; $sql .= $fname ."', '"; $sql .= $aclass ."', '"; $sql .= $database->escape_value($info['mgstatus']) ."', '"; $sql .= $database->escape_value($info['adstatus']) ."')"; $database->query($sql); $sqla="SELECT * FROM memberinfo WHERE lname='".$lname."' AND fname='".$fname."' AND class='".$aclass."'"; $result_seta = $database->query($sqla); $value= $database->fetch_array($result_seta); $userid = $value['id']; $sql = "INSERT INTO membercontact ("; $sql .= "id, street, town, state, zip, hphone, cphone, preferred"; $sql .= ") VALUES ('"; $sql .= $userid ."', '"; $sql .= $database->escape_value($info['street']) ."', '"; $sql .= $database->escape_value($info['town']) ."', '"; $sql .= $database->escape_value($info['state']) ."', '"; $sql .= $database->escape_value($info['zip']) ."', '"; $sql .= $database->escape_value($info['hphone']) ."', '"; $sql .= $database->escape_value($info['cphone']) ."', '"; $sql .= $database->escape_value($info['preferred']) ."')"; $database->query($sql); } function update_info($info, $id){ global $database; if ($info['admin_status']=="non") {$info['admin_status']="";} $sql = "UPDATE memberinfo SET "; $sql .= "fname='". $database->escape_value($info['fname']) ."', "; $sql .= "lname='". $database->escape_value($info['lname']) ."', "; $sql .= "class='". $database->escape_value($info['class']) ."', "; $sql .= "mgstatus='". $database->escape_value($info['mgstatus']) ."', "; $sql .= "admin_status='". $database->escape_value($info['admin_status']) ."' "; $sql .= "WHERE id='". $id. "' "; $database->query($sql); } function editMember($info){ global $database; $id = $database->escape_value($info['id']); $this->update_info($info, $id); $sql = "UPDATE membercontact SET "; $sql .= "street='". $database->escape_value($info['street']) ."', "; $sql .= "town='". $database->escape_value($info['town']) ."', "; $sql .= "state='". $database->escape_value($info['state']) ."', "; $sql .= "zip='". $database->escape_value($info['zip']) ."', "; $sql .= "hphone='". $database->escape_value($info['hphone']) ."', "; $sql .= "cphone='". $database->escape_value($info['cphone']) ."', "; $sql .= "preferred='". $database->escape_value($info['preferred']) ."' "; $sql .= "WHERE id='". $id. "' "; $database->query($sql); } function changeToActive($group){ global $database; for ($i=0; $i < count($group); $i++) { $sql = "UPDATE memberinfo SET "; $sql .= "mgstatus='A' "; $sql .= "WHERE id='". $group[$i]['id']. "' "; $database->query($sql); } } function deleteMember($memberid){ global $database; $id = $database->escape_value($memberid); $sql = "DELETE FROM memberinfo "; $sql .= "WHERE id=". $id; $sql .= " LIMIT 1"; $database->query($sql); $sql = "DELETE FROM membercontact"; $sql .= "WHERE id=". $id; $sql .= " LIMIT 1"; $database->query($sql); } function checkLogin($username, $password){ global $database; $pword = sha1($database->escape_value($password)); $sql="SELECT * FROM memberinfo WHERE username='".$username."' AND pword='".$pword."'"; $result_set = $database->query($sql); if($database->num_rows($result_set)>0){ $value= $database->fetch_array($result_set); if($value['exptime'] >0 && $value['exptime']username = $username; $_SESSION['memberid'] = $value['id']; $this->member = $value['id']; $memberhrs = new memberHrs($_SESSION['memberid']); //$memberhrs->setDates(); return true; } else { return false; } } function addMemberContact($meminfo, $memid){ global $database; $id = $database->escape_value($memid); $sql="SELECT * FROM membercontact WHERE id = '".$id."'"; $result_set = $database->query($sql); $memcontact = $database->fetch_array($result_set); $return_array = array( "id" => $id, "fname" => $meminfo['fname'], "lname" => $meminfo['lname'], "class" => $meminfo['class'], "mgstatus" => $meminfo['mgstatus'], "admin_status" => $meminfo['admin_status'], "street" => $memcontact['street'], "town" => $memcontact['town'], "state" => $memcontact['state'], "zip" => $memcontact['zip'], "hphone" => $memcontact['hphone'], "cphone" => $memcontact['cphone'], "preferred" => $memcontact['preferred'] ); return $return_array; } function get_flist(){ global $database; $temp_array = array(); $sql="SELECT * FROM memberinfo WHERE admin_status='full' ORDER BY lname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { $mem_array = $this->addMemberContact($value, $value['id']); array_push($temp_array, $mem_array); } return $temp_array; } function get_hlist(){ global $database; $temp_array = array(); $sql="SELECT * FROM memberinfo WHERE admin_status='hours' ORDER BY lname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { $mem_array = $this->addMemberContact($value, $value['id']); array_push($temp_array, $mem_array); } return $temp_array; } function get_list($filter='full', $filterwhich='full', $page=1, $year=2000){ global $database; if ($year==2000){$year = $this->year;} $temp_array = []; if ($filter=='full'){ $this->set_array(); $first_array = $this->allmem; $index = 20; } else{ if ($filter=='class'){ $sql="SELECT * FROM memberinfo WHERE class = '".$filterwhich."' ORDER BY lname"; } elseif ($filter=='endlist') { $sql="SELECT * FROM memberinfo WHERE mgstatus = 'A' OR mgstatus = 'Active 1000hrs' ORDER BY lname"; } else { $sql="SELECT * FROM memberinfo WHERE mgstatus = '".$filterwhich."' ORDER BY lname"; } $index = 25; $first_array = []; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { if ($filter!='nclass') { array_push($first_array, $value); } else { if ($value['class']==$year) { array_push($first_array, $value); } } } } $start = $page*$index-$index; for ($counter=$start; $counter< $page*$index && $counteraddMemberContact($first_array[$counter], $id); array_push($temp_array, $mem_array); } return $temp_array; } function get_hrmlist($filter='full', $filterwhich='full', $page=1, $year=2000){ if ($year==2000){$year = $this->year;} $initial_array = $this->get_list($filter, $filterwhich, $page, $year); $temp_array = array(); foreach ($initial_array as $value) { $member = new memberHrs($value['id']); $hours = $member->get_totalss($year); $total = $member->overallTotal($year); $member_array = array( "name" => $value['fname'].' '.$value['lname'], 'id' => $value['id'], 'status'=> $value['mgstatus'], 'hours' => $hours, 'total' => $total ); array_push($temp_array, $member_array); } return ($temp_array); } function get_last($filter='full', $filterwhich='full'){ global $database; if ($filter=='full'){ return $this->get_pages(); } elseif ($filter=='class') { $sql="SELECT COUNT(*) AS totalnum FROM memberinfo WHERE class = '".$filterwhich."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); } else { $sql="SELECT COUNT(*) AS totalnum FROM memberinfo WHERE mgstatus = '".$filterwhich."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); } $numarray = $value['totalnum']; $temp_array['last']=ceil($numarray/25); return $temp_array; } function set_array(){ global $database; $this->allmem = array(); $sql="SELECT * FROM memberinfo ORDER BY lname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { // if ($value['password']!=''){ // $sql = "UPDATE memberinfo SET "; // $sql .= "pword='". sha1($value['password']) ."' "; // $sql .= "WHERE id='". $value['id']. "' "; // $database->query($sql); // } array_push($this->allmem, $value); } } function nohours($id){ $memberhrs = new memberHrs($id); $value = $memberhrs->num_entries(); return ($value==0); } function hrsNonlist(){ $this->set_array(); $nonReg_array = array(); $RegNoHrs_array = array(); $the_array = array ("IA", "T/NotG", "E"); foreach ($this->allmem as $value) { if (!in_array($value['mgstatus'], $the_array)){ $nohours = $this->nohours($value['id']); if ($value['username']==''){ array_push($nonReg_array, $value); } elseif ($nohours) { array_push($RegNoHrs_array, $value); } } } $returnArray = array( 'nonReg' => $nonReg_array, 'RegNoHrs' => $RegNoHrs_array ); return $returnArray; } function lookupMem($lname){ global $database; $temp_array = array(); $sql="SELECT * FROM memberinfo WHERE lname='".$lname."' ORDER BY fname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { $mem_array = $this->addMemberContact($value, $value['id']); array_push($temp_array, $mem_array); } return $temp_array; } function get_pages(){ $this->set_array(); $temp_array = []; $temp_array['last']=ceil(count($this->allmem)/20); return $temp_array; } function get_initial_info(){ global $database; $temp_array = []; $sql="SELECT * FROM memberinfo ORDER BY class ASC LIMIT 1"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); $temp_array['firstyear'] = 1994; if ($value['class']>0 && $value['class'] != $temp_array['firstyear']){ $temp_array['firstyear'] = $value['class']; } $this->set_array(); $temp_array['last']=ceil(count($this->allmem)/20); return $temp_array; } function checkMember($fname, $lname, $year){ global $database; $sql="SELECT * FROM memberinfo WHERE fname='".$fname."' AND lname='".$lname."' AND class='".$year."'"; $result_set = $database->query($sql); if($database->num_rows($result_set)>0){ $value= $database->fetch_array($result_set); $_SESSION['memberid'] = $value['id']; $this->member = $value['id']; return true; } else { return false; } } // function get_memberid(){ // $temp_array = array(); // $temp_array['id']=$this->member; // return $temp_array; // } function checkUserName($username){ global $database; $sql="SELECT * FROM memberinfo WHERE username='".$username."'"; $result_set = $database->query($sql); return ($database->num_rows($result_set)>0); } function createLogin($info){ global $database; $sql = "UPDATE memberinfo SET "; $sql .= "username='". $info['uname'] ."', "; $sql .= "password='". $info['pword'] ."', "; $sql .= "email='". $info['email'] ."' "; $sql .= "WHERE id='". $_SESSION['memberid']. "' "; $database->query($sql); $username = $info['uname']; $password = $info['pword']; $email = $info['email']; $m = new PHPMailer; $m->From = 'hours@mgofmc.org'; $m->FromName = ""; $m->addReplyTo('hours@mgofmc.org', "Reply Address"); $m->Subject = "Master Gardners Info, Part I"; $m->Body = "Your username as: ".$username."."; $m->addAddress($email); $m->send(); $m = new PHPMailer; $m->From = 'hours@mgofmc.org'; $m->FromName = ""; $m->addReplyTo('hours@mgofmc.org', "Reply Address"); $m->Subject = "Master Gardners Info, Part II"; $m->Body = "Your password as: ".$password."."; $m->addAddress($email); $m->send(); // $_SESSION['newUser'] = true; } function check_email($email){ global $database; $sql="SELECT * FROM memberinfo WHERE email='".$email."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); $isThere = ($database->num_rows($result_set)>0); if ($isThere){ $username = $value['username']; $id = $value['id']; $random = rand(12, 18); $password = random_password($random); $encrypt = sha1($password); $date = date("m/d/Y"); $date1 = strtotime("+2 days", strtotime($date)); $date2 = date("m/d/Y", $date1); list($month, $day, $year) = explode('/', $date2); $themonth = intval($month); $theday = intval($day); $theyear = intval($year); $dateExpire = mktime(23,59,59,$themonth,$theday,$theyear); $email = $value['email']; $sql = "UPDATE memberinfo SET "; $sql .= "pword='". $encrypt ."', "; $sql .= "password='". $password ."', "; $sql .= "exptime='". $dateExpire ."' "; $sql .= "WHERE id='". $id. "' "; $database->query($sql); $m = new PHPMailer; $m->From = 'hours@mgofmc.org'; $m->FromName = "Master Gardeners"; $m->isHTML(true); $m->addReplyTo('hours@mgofmc.org', "Reply Address"); $m->Subject = "Master Gardners Info"; $m->Body = "Your username is: ".$username.".
Your temporary password is: ".$password." which will expire on: ".$date2.".
Please go to your membership profile page in the hours site to create a new password."; $m->addAddress($email); $m->send(); } return $isThere; } function get_total_mgs(){ $this->set_array(); $reg_array = array( "A" => 0, "A - Trainee" => 0, "E" => 0, "IA" => 0, "T/NotG" => 0, "Active 1000hrs" => 0 ); foreach ($this->allmem as $value) { $key = $value['mgstatus']; $reg_array[$key]++; } return $reg_array; } function get_registered(){ $this->set_array(); $reg_array = array( "A" => 0, "A - Trainee" => 0, "E" => 0, "IA" => 0, "T/NotG" => 0, "Active 1000hrs" => 0 ); foreach ($this->allmem as $value) { if ($value['username'] != ""){ $key = $value['mgstatus']; $reg_array[$key]++; } } return $reg_array; } function get_entered_hrs(){ $this->set_array(); $hrs_array = array( "A" => 0, "A - Trainee" => 0, "E" => 0, "IA" => 0, "T/NotG" => 0, "Active 1000hrs" => 0 ); foreach ($this->allmem as $value) { $member = new memberHrs($value['id']); if ($member->num_entries() >0 ){ $key = $value['mgstatus']; $hrs_array[$key]++; } } return $hrs_array; } function rdlist($mgstatus, $year=2000){ global $database; if ($year==2000){$year = $this->year;} $marray = array(); $sql="SELECT * FROM memberinfo WHERE mgstatus = '".$mgstatus."' ORDER BY lname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { array_push($marray, $value); } $temp_array = array(); $howmany = count($marray); for ($counter=0; $counterget_totalss($year); $totals_array = $t_array[12]; $totals_array['newMC']=false; switch ($mgstatus) { case 'A - Trainee': $not_below = ( $marray[$counter]['class']==$year && ($totals_array['Mercer County']<25 || $totals_array['GardenCore'] <30 || $totals_array['Compost (Trainee)']<5 )); if ($not_below && $totals_array['GardenCore'] >30) { $diff = ($totals_array['GardenCore'] - 30); $newTotal = $totals_array['Mercer County']+$diff; // if ($newTotal>24.99){ // $not_below = false; // } else{ $newMC=$totals_array['Mercer County']."+".$diff." (from Helpline/GardenCore) = ".$newTotal; $totals_array['Mercer County']=$newTotal; $totals_array['newMC']=true; $totals_array['diff']=$newMC; // } } break; case 'A': $not_below = ($totals_array['Mercer County']<15 || $totals_array['GardenCore'] <15 || $totals_array['Continuing Ed']<10 ); if ($not_below && $totals_array['GardenCore'] >15) { $diff = $totals_array['GardenCore']-15; $newTotal = $totals_array['Mercer County']+$diff; $newMC=$totals_array['Mercer County']."+".$diff." (from Helpline/GardenCore) = ".$newTotal; $totals_array['Mercer County']=$newTotal; $totals_array['newMC']=true; $totals_array['diff']=$newMC; } break; case 'Active 1000hrs': if ($year<2018) { $not_below = ($totals_array['Mercer County']<25 || $totals_array['Continuing Ed']<10 ); } else { $not_below = ($totals_array['Mercer County']<20 || $totals_array['Continuing Ed']<10 || $totals_array['GardenCore']<5); } break; default: break; } if ($not_below){ $member_array = array( 'lname' => $marray[$counter]['lname'], 'fname' => $marray[$counter]['fname'], 'class' => $marray[$counter]['class'], 'status' => $marray[$counter]['mgstatus'], 'totals' => $totals_array ); array_push($temp_array, $member_array); } } return $temp_array; } function clistDownload(){ $this->set_array(); $mem_array = array('A', 'Active 1000hrs', 'A - Trainee'); $output = ""; $output .= ' '; $output .=''; $output .=' '; foreach ($this->allmem as $value) { if (in_array($value['mgstatus'], $mem_array)){ $member = new memberObject($value['id']); $output .=''; } } $output .= '
Master Gardeners of Mercer County Contact List
Last Name First Name Class Street Town State Zip Home Phone Cell Phone Preferred Phone Email
'.$member->get_lname().' '.$member->get_fname().' '.$member->get_class().' '.$member->get_street().' '.$member->get_town().' '.$member->get_state().' '.$member->get_zip().' '.$member->get_hphone().' '.$member->get_cphone().' '.$member->get_preferred().' '.$member->get_email().'
'; return $output; } function rdlistDownload($mgstatus, $year=2000){ if ($year<2017){ $year = $this->year;} $rdlist_array = $this->rdlist($mgstatus, $year); $mstatus = ($mgstatus==='A') ? "Active Members" : $mgstatus; $output = ""; $output .= ' '; $output .=''; $output .=' '; switch ($mgstatus) { case 'A': $output .=' '; break; case 'A - Trainee': $output .=' '; break; case 'Active 1000hrs': if (date('Y') < 2018) { $output .=' '; } else { $output .=' '; } break; default: # code... break; } $output .=''; foreach($rdlist_array as $member){ $GardenCore = $member['totals']['Helpline'] + $member['totals']['GardenCore']; $output .=""; switch ($mgstatus) { case 'A': if ($member['totals']['newMC']){ $output .=""; } else { $output .=""; } $output .=" "; break; case 'A - Trainee': $output .=""; if ($member['totals']['newMC']){ $output .=""; } else { $output .=""; } $output .=" "; break; case 'Active 1000hrs': if (date('Y') < 2018){ $output .=" "; } else { $output .=" "; } break; default: # code... break; } } return $output; } function nclist($page=1, $year=2000){ global $database; if ($year<2016){ $year = $this->year;} $nc_array = $this->get_list("nclass", "A - Trainee", $page, $year); $temp_array= array(); foreach ($nc_array as $value) { $member = new memberObject($value['id']); $memberhrs = new memberHrs($value['id']); $totals_array = $memberhrs->overallTotal($year); $totals_array['ototal'] = $totals_array['Total']+$totals_array['Continuing Ed']; if ($member->get_class() == $year){ $member_array = array( 'lname' => $member->get_lname(), 'fname' => $member->get_fname(), 'class' => $member->get_class(), 'status' => $member->get_status(), 'totals' => $totals_array ); array_push($temp_array, $member_array); } } $sql="SELECT COUNT(*) AS totalnum FROM memberinfo WHERE mgstatus = 'A - Trainee' AND class='".$year."'"; $result_set = $database->query($sql); $info = $database->fetch_array($result_set); $numarray = $info['totalnum']; $last = ceil($numarray/25); // $last_array = array( // 'last' => $last // ); $returnArray = array( 'reportArray' => $temp_array, 'last' => $last ); return $returnArray; } function nclistDownload($year){ if ($year<2016){ $year = $this->year;} $this->set_array(); $marray = $this->allmem; $output = ""; $output .= '
'.$year.' Requirement Deficiencies Report: '.$mstatus.'
Last Name First Name Class StatusMercer County (15hrs) Helpline/GardenCore (15hrs) Continuing Ed (10hrs)Compost (5hrs) Mercer County (25hrs) Helpline/GardenCore (30hrs)Mercer County (25hrs) Continuing Ed (10hrs)Mercer County (20hrs) GardenCore (5hrs) Continuing Ed (10hrs)Annual Total
".$member['lname']." ".$member['fname']." ".$member['class']." ".$member['status']."".$member['totals']['diff']."".$member['totals']['Mercer County']."".$GardenCore." ".$member['totals']['Continuing Ed']." ".$member['totals']['Total']."
".$member['totals']['Compost (Trainee)']."".$member['totals']['diff']."".$member['totals']['Mercer County']."".$member['totals']['Helpline']." ".$member['totals']['Total']."
".$member['totals']['Mercer County']." ".$member['totals']['Continuing Ed']." ".$member['totals']['Total']."
".$member['totals']['Mercer County']." ".$GardenCore." ".$member['totals']['Continuing Ed']." ".$member['totals']['Total']."
'; $output .=''; $output .=' '; for ($counter=0; $counter< count($marray); $counter++) { if (($marray[$counter]['mgstatus']=='A - Trainee') && ($marray[$counter]['class']==$year)){ $id = $marray[$counter]['id']; $member = new memberObject($id); $memberhrs = new memberHrs($id); $totals_array = $memberhrs->overallTotal($year); $totals_array['ototal'] = $totals_array['Total']+$totals_array['Continuing Ed']; $output .= ' '; } } $output .= '
New Class Report
Last Name First Name Class Status Helpline/GardenCore Compost MC & Other Total H,C, MC Total CE Overall Total
'.$member->get_lname().' '.$member->get_fname().' '.$member->get_class().' '.$member->get_status().' '.$totals_array["GardenCore"].' '.$totals_array["Compost (Trainee)"].' '.$totals_array["Mercer County"].' '.$totals_array["Total"].' '.$totals_array["Continuing Ed"].' '.$totals_array["ototal"].'
'; return $output; } function slistDownload($year){ if ($year<2016){ $year = $this->year;} $this->set_array(); $marray = $this->allmem; $output = ""; $output .= ' '; $output .=''; $output .=' '; for ($counter=0; $counter< count($marray); $counter++) { $id = $marray[$counter]['id']; $member = new memberObject($id); $memberhrs = new memberHrs($id); $totals_array = $memberhrs->overallTotal($year); $totals_array['ototal'] = $totals_array['Total']+$totals_array['Continuing Ed']; $output .= ' '; } $output .= '
Summary Report: '.$year.'
Last Name First Name Class Status Helpline/GardenCore MC & Other Total H,C, MC Total CE Overall Total
'.$member->get_lname().' '.$member->get_fname().' '.$member->get_class().' '.$member->get_status().' '.$totals_array["GardenCore"].' '.$totals_array["Mercer County"].' '.$totals_array["Total"].' '.$totals_array["Continuing Ed"].' '.$totals_array["ototal"].'
'; return $output; } function slist($page=1, $year, $endlist=false){ if ($year<2016){ $year = $this->year;} if ($endlist){ $nc_array = $this->get_list("endlist", "full", $page, $year); } else { $nc_array = $this->get_list("full", "full", $page, $year); } $temp_array= array(); foreach ($nc_array as $value) { $member = new memberObject($value['id']); $memberhrs = new memberHrs($value['id']); if ($endlist) { $totals_array = $memberhrs->get_totalss($year); $totals_array['ototal'] = $totals_array[12]['Total']+$totals_array[12]['Continuing Ed']; } else { $totals_array = $memberhrs->overallTotal($year); $totals_array['ototal'] = $totals_array['Total']+$totals_array['Continuing Ed']; } $member_array = array( 'lname' => $member->get_lname(), 'fname' => $member->get_fname(), 'class' => $member->get_class(), 'status' => $member->get_status(), 'totals' => $totals_array ); array_push($temp_array, $member_array); } $last = $this->get_last('full', 'full'); $lasting = $last['last']; $returnArray = array( 'reportArray' => $temp_array, 'last' => $lasting ); return $returnArray; } function endlist($page=1, $year){ return $this->slist($page, $year, true); } function set_array_for_endlist(){ global $database; $returnArray = array(); $sql="SELECT * FROM memberinfo WHERE mgstatus='A' OR mgstatus= 'Active 1000hrs' ORDER BY lname"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { //$t_array = change_status($value); array_push($returnArray, $value); } return $returnArray; } function endDownload($year){ if ($year<2016){ $year = $this->year;} $marray = $this->set_array_for_endlist(); $output = ""; $output .= ' '; $output .=''; $output .=' '; for ($counter=201; $counter<250; $counter++) { $id = $marray[$counter]['id']; $memberhrs = new memberHrs($id); $totals_array = $memberhrs->get_totalss($year); $totals_array['ototal'] = $totals_array[12]['Total']+$totals_array[12]['Continuing Ed']; $output .= ' '; } $output .= '
End of Year Report: '.$year.'
Last Name First Name Class Mercer County Helpline/GardenCore CE Total Overall Total
'.$marray[$counter]['lname'].' '.$marray[$counter]['fname'].' '.$marray[$counter]['class'].' '.$totals_array[12]["Mercer County"].' '.$totals_array[12]["GardenCore"].' '.$totals_array[12]["Continuing Ed"].' '.$totals_array[12]["Total"].' '.$totals_array["ototal"].'
'; return $output; } function mlist($milestone='l100', $year){ if ($year<2016){ $year = $this->year;} $this->set_array(); $returnArray = array(); foreach ($this->allmem as $value) { $memberhrs = new memberHrs($value['id']); $totals_array = $memberhrs->overallTotal($year); $ototal = $totals_array['Total']+$totals_array['Continuing Ed']; $put_in_array = false; switch ($milestone) { case 'l100': $put_in_array = ($ototal < 100); break; case 'l250': $put_in_array = (($ototal >99) && ($ototal <250)); break; case 'l500': $put_in_array = ($ototal > 249 && $ototal < 500); break; case 'l1000': $put_in_array = ($ototal > 499 && $ototal < 1000); break; case 'l2500': $put_in_array = ($ototal > 999 && $ototal < 2500); break; case 'l5000': $put_in_array = ($ototal > 2499 && $ototal < 5000); break; case '5000+': $put_in_array = ($ototal > 4999); break; case 'msAll': $put_in_array = true; break; default: break; } if ($put_in_array){ $member = new memberObject($value['id']); $totals_array['ototal'] = $totals_array['Total']+$totals_array['Continuing Ed']; $member_array = array( 'lname' => $member->get_lname(), 'fname' => $member->get_fname(), 'class' => $member->get_class(), 'status' => $member->get_status(), 'ce' => $totals_array['Continuing Ed'], // 'ototal' => $ototal 'ytotal' => $totals_array['Total'] ); array_push($returnArray, $member_array); } } function method1($a,$b) { return ($a["ototal"] >= $b["ototal"]) ? -1 : 1; } usort($returnArray, "method1"); return $returnArray; } function mlistDownload($value='5000+', $year){ if ($year<2016){ $year = $this->year;} $output = ""; $output .= ''; $fulldate = date('F j, Y'); $output .=''; $output .='
'.$year.' Lifetime Milestones Report
Report Date: '.$fulldate.'
'; $group_array = $this->mlist($value, $year); $group = (string)count($group_array); switch ($value) { case 'l100': $group .= ' Under 100'; break; case 'l250': $group .= ' Between 100 & 250'; break; case 'l500': $group .= ' Between 250 & 500'; break; case 'l1000': $group .= ' Between 500 & 1000'; break; case 'l2500': $group .= ' Between 1000 & 2500'; break; case 'l5000': $group .= ' Between 2500 & 5000'; break; case '5000+': $group .= ' With 5000 Or More'; break; case 'msAll': $group .= ' All Members'; break; default: break; } $output .=''; $output .=''; for ($counter=0; $counter< count($group_array); $counter++) { $output .= ''; } $output .= '
'.$group.'
Last Name First Name Class Status Total CE Total Volunteer Hrs
'.$group_array[$counter]['lname'].' '.$group_array[$counter]['fname'].' '.$group_array[$counter]['class'].' '.$group_array[$counter]['status'].' '.$group_array[$counter]['ce'].' '.$group_array[$counter]['ytotal'].'
'; return $output; } } ?> query($sql); $value = $database->fetch_array($result_set); $this->fname = $value['fname']; $this->lname = $value['lname']; $this->email = $value['email']; $this->pword = $value['pword']; $this->password = $value['password']; $this->exptime = $value['exptime']; $this->uname = $value['username']; $this->class = $value['class']; $this->status = $value['mgstatus']; $this->admin = isset($value['admin_status']) ? $value['admin_status'] : "" ; $this->memberid = $memberid; $sqlc="SELECT * FROM membercontact WHERE id='".$memberid."'"; $result_setc = $database->query($sqlc); $valuec = $database->fetch_array($result_setc); $this->street = $valuec['street']; $this->town = $valuec['town']; $this->state = $valuec['state']; $this->zip = $valuec['zip']; $this->hphone = $valuec['hphone']; $this->cphone = $valuec['cphone']; $this->preferred = $valuec['preferred']; } function get_fullname(){ return $this->fname." ".$this->lname; } function get_fname(){ return $this->fname; } function get_expire(){ return $this->exptime; } function expire_show(){ return date('m/d/Y', $this->exptime); } function get_lname(){ return $this->lname; } function get_status(){ $this->checkStatus(); return $this->status; } function get_mstatus(){ return $this->status; } function get_class(){ return $this->class; } function get_admin(){ return $this->admin; } function get_username(){ return $this->uname; } function get_password(){ return $this->pword; } function get_email(){ return $this->email; } function get_street(){ return $this->street; } function get_town(){ return $this->town; } function get_state(){ return $this->state; } function get_zip(){ return $this->zip; } function get_hphone(){ return $this->hphone; } function get_cphone(){ return $this->cphone; } function get_preferred(){ return $this->preferred; } function set_session(){ $_SESSION['member'] = $this->memberid; } function createLogin($info){ global $database; if ($info['pword']==$this->pword){ $pword = $this->pword; $password = $this->password; $expire = $this->exptime; } else { $pword = sha1($database->escape_value($info['pword'])); $password = ''; $expire = 0; } $sql = "UPDATE memberinfo SET "; $sql .= "username='". $database->escape_value($info['uname']) ."', "; $sql .= "password='". $password ."', "; $sql .= "pword='". $pword ."', "; $sql .= "exptime ='". $expire."', "; $sql .= "email='". $database->escape_value($info['email']) ."' "; $sql .= "WHERE id='". $this->memberid. "' "; $database->query($sql); if ( isset($info['street']) || isset($info['town']) || isset($info['state']) || isset($info['zip']) || isset($info['hphone']) || isset($info['cphone']) ) { $sql = "UPDATE membercontact SET "; $sql .= "street='". $database->escape_value($info['street']) ."', "; $sql .= "town='". $database->escape_value($info['town']) ."', "; $sql .= "state='". $database->escape_value($info['state']) ."', "; $sql .= "zip='". $database->escape_value($info['zip']) ."', "; $sql .= "hphone='". $database->escape_value($info['hphone']) ."', "; $sql .= "cphone='". $database->escape_value($info['cphone']) ."', "; $sql .= "preferred='". $database->escape_value($info['preferred']) ."' "; $sql .= "WHERE id='". $this->memberid. "' "; $database->query($sql); } return $expire; } function check_full(){ return ($this->admin === 'full'); } function check_hrs(){ return ($this->admin === 'full' || $this->admin === 'hours'); } function have_registered(){ return ($this->uname != "" && $this->pword != ""); } function isTrainee(){ return ($this->status=="A - Trainee" || $this->status=="T/NotG"); } function checkStatus(){ global $database; $memberhrs = new memberHrs($this->memberid); $total_array = $memberhrs->overallTotal(); if (($total_array['Total'] ==1000 || $total_array['Total'] > 1000) && $this->status === "A"){ $sql = "UPDATE memberinfo SET "; $sql .= "mgstatus='Active 1000hrs' "; $sql .= "WHERE id='". $this->memberid. "' "; $database->query($sql); $this->status = 'Active 1000hrs'; $m = new PHPMailer; $m->From = ($this->email); $m->FromName = ($this->get_fullname()); $m->addReplyTo($this->email, "Reply Address"); $m->Subject = "Master Gardeners, Reached 1000hrs "; $m->Body = $this->get_fullname()." has reached 1000hrs."; $m->addAddress('hours@mgofmc.org'); $m->send(); } if ($total_array['Total'] < 1000 && $this->status == "Active 1000hrs"){ $sql = "UPDATE memberinfo SET "; $sql .= "mgstatus='A' "; $sql .= "WHERE id='". $this->memberid. "' "; $database->query($sql); $this->status = 'A'; } } } ?> memhrs = array(); $this->memberid = $id; $this->the_year = date('Y'); } function num_entries(){ global $database; $temp = 0; $sql="SELECT * FROM hours WHERE memberid='".$this->memberid."'"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { $temp++; } return $temp; } function set_hrs($year){ global $database; $which_year = $database->escape_value($year); if ($which_year == "") {$which_year = $this->the_year;} $hrs_array = array(); $sql="SELECT * FROM hours WHERE memberid='".$this->memberid."' ORDER BY hdate DESC"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { $hrsobject = new hrsObject($value['numid']); $whatYear = date('Y', $hrsobject->get_date()); if ($which_year == $whatYear){ $temp_array = $hrsobject->set_in_array(); array_push($hrs_array, $temp_array); } } return $hrs_array; } function enter_hoursAdmin($info){ global $database; list($month, $day, $year) = explode("/", $info['hdate']); $themonth = intval($month); $theday = intval($day); $theyear = intval($year); $date = mktime(0,0,0,$themonth,$theday,$theyear); $today = date('U'); $info['hdate'] = $date; $hours = $database->escape_value($info['numhrs']); $hours_float = floatval($hours); $hours_int = intval($hours); $remainder = $hours_float - $hours_int; if ($remainder <0.6 && $remainder !=0.0){ $hours_int += 0.5; } elseif ($remainder >0.5) { $hours_int++; } $sql = "INSERT INTO hours ("; $sql .= "memberid, hdate, hrstype, numhrs, description, chstatus, chdate, chdescription"; $sql .= ") VALUES ('"; $sql .= $this->memberid ."', '"; $sql .= $database->escape_value($info['hdate']) ."', '"; $sql .= $database->escape_value($info['hrstype']) ."', '"; $sql .= $hours_int ."', '"; $sql .= $database->escape_value($info['description']) ."', '"; $sql .= "a', '"; $sql .= $today ."', '"; $sql .= $database->escape_value($info['chdescription']) ."')"; $database->query($sql); } function enter_hours($info){ // global $database; // list($month, $day, $year) = explode("/", $info['hdate']); // $themonth = intval($month); // $theday = intval($day); // $theyear = intval($year); // $hours = $database->escape_value($info['numhrs']); // $hours_float = floatval($hours); // $hours_int = intval($hours); // $remainder = $hours_float - $hours_int; // if ($remainder <0.6 && $remainder !=0.0){ // $hours_int += 0.5; // } elseif ($remainder >0.5) { // $hours_int++; // } // $hrstype = $database->escape_value($info['hrstype']); // if ($theyear>2017 && $hrstype=='Helpline') { // $hrstype = 'GardenCore'; // } // $date = mktime(0,0,0,$themonth,$theday,$theyear); // $info['hdate'] = $date; // $sql = "INSERT INTO hours ("; // $sql .= "memberid, hdate, hrstype, numhrs, description"; // $sql .= ") VALUES ('"; // $sql .= $this->memberid ."', '"; // $sql .= $database->escape_value($info['hdate']) ."', '"; // $sql .= $hrstype ."', '"; // $sql .= $hours_int ."', '"; // $sql .= $database->escape_value($info['description']) ."')"; // $database->query($sql); } function delete_hrs($numid){ global $database; $sql = "DELETE FROM hours "; $sql .= "WHERE numid=". $numid; $sql .= " LIMIT 1"; $database->query($sql); } function get_num_pages($year){ global $database; $which_year = $database->escape_value($year); if ($which_year == "") {$which_year = $this->the_year;} $the_array = $this->set_hrs($which_year); $numarray = count($the_array); $temp_array = array(); $temp_array['entries'] = $numarray; $temp_array['last']=ceil($numarray/20); return $temp_array; } function get_hours($page=1, $year=2000){ global $database; $which_year = $database->escape_value($year); if ($which_year == 2000) {$which_year = $this->the_year;} $first_array = $this->set_hrs($which_year); $index = 20; $start = $page*$index-$index; $temp_array = array(); for ($counter=$start; $counter< $page*$index && $counterescape_value($year); if ($which_year == 2000) {$which_year = $this->the_year;} $member = new memberObject($this->memberid); $status = $member->get_status(); $totals = $this->get_totalss($which_year); $ototals = $this->overallTotal($which_year); switch ($status) { case 'Active 1000hrs': if (date('Y')==2017) { $vhrs = 25; $mc = 25; $hl = 0; } else { $vhrs = 25; $mc = 20; $hl = 5; } break; case 'A': $vhrs = 30; $mc = 15; $hl = 15; break; case 'A - Trainee': $vhrs = 60; $mc = 25; $hl = 30; break; default: break; } $output = ""; $output .= ' '; $output .=''; $output .=' '; $output .=''; if ($status != 'A - Trainee'){ $output .=''; } else { $output .=''; } $output .='
Yearly Hour Totals for '.$year.': '.$member->get_fullname().'
Requirement Annual Historical
Volunteer Hours '.$vhrs.' '.$totals[12]["Total"].' '.$ototals["Total"].'
    Mercer County '.$mc.' '.$totals[12]["Mercer County"].' '.$ototals["Mercer County"].'
    GardenCore '.$hl.' '.$totals[12]["GardenCore"].' '.$ototals["GardenCore"].'
Continuing Ed (CE) 10 '.$totals[12]["Continuing Ed"].' '.$ototals["Continuing Ed"].'
Compost 5 '.$totals[12]["Compost (Trainee)"].' '.$ototals["Compost (Trainee)"].'

'; $first_array = $this->set_hrs($year); $output .= ' '; $output .=''; $output .=' '; foreach ($first_array as $value) { $output .=''; } $output .='
Entries for '.$year.'
Date Type of Hours Number of Hours Description
'.$value["hdate"].' '.$value["hrstype"].' '.$value["numhrs"].' '.$value["description"].'
'; return $output; } function get_hours_month($whichMonth, $year){ global $database; $which_year = $database->escape_value($year); if ($which_year == "") {$which_year = $this->the_year;} $month_array = array( "Mercer County" => 0, "Helpline" => 0, "GardenCore" => 0, "Continuing Ed" => 0, "Compost (Trainee)" => 0, "Other (Trainee)" => 0, "Total" => 0 ); $date_range1 = mktime(0,0,0,$whichMonth,1,$which_year); $num_days = cal_days_in_month(CAL_GREGORIAN, $whichMonth , $which_year); $date_range2 = mktime(23,59,59,$whichMonth,$num_days,$which_year); $sql="SELECT * FROM hours WHERE memberid='".$this->memberid."' AND hdate>= '".$date_range1."' AND hdate <='".$date_range2."' ORDER BY hdate"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { if ($value['chstatus'] !='d'){ $key = $value['hrstype']; $month_array[$key] += $value['numhrs']; if($key !="Continuing Ed"){ $month_array['Total'] +=$value['numhrs']; } } } return $month_array; } function year_end_fix($year=2000){ global $database; $which_year = $database->escape_value($year); if ($which_year == 2000) {$which_year = $this->the_year;} $total_array = array( "Mercer County" => 0, "Helpline" => 0, "GardenCore" => 0, "Continuing Ed" => 0, "Compost (Trainee)" => 0, "Other (Trainee)" => 0, "Total" => 0 ); $date_range1 = mktime(0,0,0,1,1,$which_year); $date_range2 = mktime(23,59,59,12,31,$which_year); $sql="SELECT * FROM hours WHERE memberid='".$this->memberid."' AND hdate>= '".$date_range1."' AND hdate <='".$date_range2."'"; $result_set = $database->query($sql); while ($value = $database->fetch_array($result_set)) { if ($value['chstatus'] !='d'){ $key = $value['hrstype']; $total_array[$key] += $value['numhrs']; if($key !="Continuing Ed"){ $total_array['Total'] +=$value['numhrs']; } } } $overall=$total_array['Total']+$total_array['Continuing Ed']; $total_array['GardenCore'] = $total_array['GardenCore'] + $total_array['Helpline']; $sql="SELECT * FROM overalltotals WHERE memberid='".$this->memberid."' AND year='".$which_year."'"; $result_set = $database->query($sql); if ($database->num_rows($result_set)>0){ $sql = "UPDATE overalltotals SET "; $sql .= "mc='". $total_array['Mercer County'] ."', "; $sql .= "gc='". $total_array['GardenCore'] ."', "; $sql .= "ce='". $total_array['Continuing Ed'] ."', "; $sql .= "ytotal='". $total_array['Total'] ."', "; $sql .= "overallt='". $overall ."' "; $sql .= "WHERE id='". $this->memberid. "' "; $database->query($sql); } else { $sql = "INSERT INTO overalltotals ("; $sql .= "id, year, mc, gc, ce ytotal, overallt"; $sql .= ") VALUES ('"; $sql .= $this->memberid ."', '"; $sql .= $which_year ."', '"; $sql .= $total_array['Mercer County'] ."', '"; $sql .= $total_array['GardenCore'] ."', '"; $sql .= $total_array['Continuing Ed'] ."', '"; $sql .= $total_array['Total'] ."', '"; $sql .= $overall ."')"; $database->query($sql); } } function get_totalss($year=2000){ global $database; $which_year = $database->escape_value($year); if ($which_year == 2000) {$which_year = $this->the_year;} $totals_array = $this->set_hrs($which_year); $months_array = array(); for ($month=1; $month<=12; $month++){ array_push($months_array, $this->get_hours_month($month, $which_year)); } $total_array = array( "Mercer County" => 0, "Helpline" => 0, "GardenCore" => 0, "Continuing Ed" => 0, "Compost (Trainee)" => 0, "Other (Trainee)" => 0, "Total" => 0 ); for ($i = 0; $i < count($totals_array); $i++) { $key=$totals_array[$i]['hrstype']; if ($totals_array[$i]['chstatus'] !='d'){ $total_array[$key] += $totals_array[$i]['numhrs']; $total_array['Total'] += $totals_array[$i]['numhrs']; } } $total_array['Total']=$total_array['Total']-$total_array['Continuing Ed']; $total_array['GardenCore'] = $total_array['GardenCore'] + $total_array['Helpline']; array_push($months_array, $total_array); return $months_array; } function get_totals(){ $totals_array = $this->set_hrs(); $months_array = array(0,0,0,0,0,0,0,0,0,0,0,0); $current_month=12; $total = 0; for ($i = 0; $i < count($totals_array); $i++) { $date = date('m/d/Y',$totals_array[$i]['hdate']); list($mon, $day, $year) = explode("/", $date); if ($year == date('Y')) { $month = (int)$mon; if ($month<$current_month){ $current_month = $month; } $months_array[$current_month] += $totals_array[$i]['numhrs']; $total += $totals_array[$i]['numhrs']; } } array_push($months_array, $total); return $months_array; } function overallTotal($year=''){ global $database; $which_year = $database->escape_value($year); if ($which_year == "") {$which_year = $this->the_year;} $total_array = array( "Mercer County" => 0.0, "Helpline" => 0.0, "GardenCore" => 0.0, "Continuing Ed" => 0.0, "Compost (Trainee)" => 0.0, "Total" => 0.0 ); $sql="SELECT * FROM pretotals WHERE id='".$this->memberid."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); if ($value['mercer'] != null){ $total_array['Mercer County'] = $value['mercer']; } if ($value['conted'] != null){ $total_array['Continuing Ed'] = $value['conted']; } $sql="SELECT * FROM hours WHERE memberid='".$this->memberid."' ORDER BY hdate ASC"; $result_set = $database->query($sql); $ceTotal = 0.0; while ($value = $database->fetch_array($result_set)) { $hrsobject = new hrsObject($value['numid']); $whatYear = date('Y', $hrsobject->get_date()); if ($value['chstatus']!='d' && $whatYear <= $which_year){ switch ($value['hrstype']) { case "Mercer County": $total_array['Mercer County'] += $value['numhrs']; break; case "Helpline": $total_array['Helpline'] += $value['numhrs']; break; case "GardenCore": $total_array['GardenCore'] += $value['numhrs']; break; case "Compost (Trainee)": $total_array['Compost (Trainee)'] += $value['numhrs']; break; case "Continuing Ed": $total_array['Continuing Ed'] += $value['numhrs'];; break; default: break; } } } $total_array['Total'] = $total_array['Mercer County'] + $total_array['Helpline'] +$total_array['GardenCore']+$total_array['Compost (Trainee)']; $total_array['GardenCore'] = $total_array['GardenCore'] + $total_array['Helpline']; return $total_array; } function get_numid($hdate, $numhrs, $hrstype, $description){ global $database; list($month, $day, $year) = explode("/", $hdate); $themonth = intval($month); $theday = intval($day); $theyear = intval($year); $date = mktime(0,0,0,$themonth,$theday,$theyear); $hdate = $date; $sql="SELECT * FROM hours WHERE memberid ='".$this->memberid."' AND hdate = '".$hdate."' AND hrstype ='".$hrstype."' AND numhrs ='".$numhrs."'AND description ='".$description."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); $temp = $value['numid']; return $temp; } function get_everything($year){ global $database; $which_year = $database->escape_value($year); if ($which_year == "") {$which_year = $this->the_year;} $returnArray = array ( "num_pages" => $this->get_num_pages($which_year), "hours_info" => $this->get_hours(1, $which_year), "hours_totals" => $this->get_totalss($which_year), "overall_totals"=> $this->overallTotal($which_year) ); return $returnArray; } } ?> query($sql); $value = $database->fetch_array($result_set); $this->hrsid = $id; $this->numhrs = $value['numhrs']; $this->hrstype = $value['hrstype']; $this->description = $value['description']; $this->hdate = $value['hdate']; $this->chstatus = $value['chstatus']; $this->chdate = $value['chdate']; $this->chdescription = $value['chdescription']; } function get_date(){ return $this->hdate; } function set_in_array(){ $temp_array = array( 'hdate' => date('m/d/Y',$this->hdate), 'hrstype' => $this->hrstype, 'numhrs' => $this->numhrs, 'description' => $this->description, 'chstatus' => $this->chstatus, 'chdate' => date('m/d/Y',$this->chdate), 'chdescription' => $this->chdescription, 'numid' => $this->hrsid ); return $temp_array; } function update_hours($info){ // global $database; // list($month, $day, $year) = explode("/", $info['hdate']); // $themonth = intval($month); // $theday = intval($day); // $theyear = intval($year); // $date = mktime(0,0,0,$themonth,$theday,$theyear); // $info['hdate'] = $date; // $hours = $database->escape_value($info['numhrs']); // $hours_float = floatval($hours); // $hours_int = intval($hours); // $remainder = $hours_float - $hours_int; // if ($remainder <0.6 && $remainder !=0.0){ // $hours_int += 0.5; // } elseif ($remainder >0.5) { // $hours_int++; // } // $hrstype = $database->escape_value($info['hrstype']); // if ($theyear>2017 && $hrstype=='Helpline') { // $hrstype = 'GardenCore'; // } // $sql = "UPDATE hours SET "; // $sql .= "hdate='". $info['hdate'] ."', "; // $sql .= "hrstype='". $hrstype ."', "; // $sql .= "numhrs='". $hours_int ."', "; // $sql .= "description='". $info['description'] ."' "; // $sql .= "WHERE numid='". $this->hrsid. "' "; // $database->query($sql); } function update_hoursAdmin($info){ global $database; $sql = "INSERT INTO orghours ("; $sql .= "hrstype, numhrs, description, numid"; $sql .= ") VALUES ('"; $sql .= $this->hrstype ."', '"; $sql .= $this->numhrs ."', '"; $sql .= $this->description ."', '"; $sql .= $this->hrsid ."')"; $database->query($sql); $today = date('U'); $sql = "UPDATE hours SET "; $sql .= "hrstype='". $database->escape_value($info['hrstype']) ."', "; $sql .= "numhrs='". $database->escape_value($info['numhrs']) ."', "; $sql .= "description='". $database->escape_value($info['description']) ."', "; $sql .= "chstatus='c', "; $sql .= "chdate='". $today ."', "; $sql .= "chdescription='". $database->escape_value($info['chdescription']) ."' "; $sql .= "WHERE numid='". $this->hrsid. "' "; $database->query($sql); } function delete_hoursAdmin($info){ global $database; $today = date('U'); $sql = "UPDATE hours SET "; $sql .= "chstatus='d', "; $sql .= "chdate='". $today ."', "; $sql .= "chdescription='". $database->escape_value($info['chdescription']) ."' "; $sql .= "WHERE numid='". $this->hrsid. "' "; $database->query($sql); } function undoInfo(){ global $database; $tempArray= $this->set_in_array(); $changeFromArray = array(); if ($tempArray['chstatus']=='c'){ $sql="SELECT * FROM orghours WHERE numid='".$this->hrsid."'"; $result_set = $database->query($sql); $valueFrom = $database->fetch_array($result_set); $holder_array = array(); if ($tempArray['hrstype'] != $valueFrom['hrstype']){ $temp_array=array( "type" => "hrstype", "from" => $valueFrom['hrstype'], "to" => $tempArray['hrstype'] ); array_push($holder_array, $temp_array); } if ($tempArray['numhrs'] != $valueFrom['numhrs']){ $temp_array=array( "type" => "numhrs", "from" => $valueFrom['numhrs'], "to" => $tempArray['numhrs'] ); array_push($holder_array, $temp_array); } if ($tempArray['description'] != $valueFrom['description']){ $temp_array=array( "type" => "description", "from" => $valueFrom['description'], "to" => $tempArray['description'] ); array_push($holder_array, $temp_array); } array_push($changeFromArray, $holder_array); } $returnArray=array( "now" => $tempArray, "changes" => $changeFromArray ); return $returnArray; } function undo_hoursAdmin(){ global $database; switch ($this->chstatus) { case 'a': $sql = "DELETE FROM hours "; $sql .= "WHERE numid=". $this->hrsid; $sql .= " LIMIT 1"; $database->query($sql); break; case 'c': $sql="SELECT * FROM orghours WHERE numid='".$this->hrsid."'"; $result_set = $database->query($sql); $value = $database->fetch_array($result_set); $sql = "UPDATE hours SET "; $sql .= "hrstype='". $value['hrstype'] ."', "; $sql .= "numhrs='". $value['numhrs'] ."', "; $sql .= "description='". $value['description'] ."', "; $sql .= "chstatus ='', "; $sql .= "chdate ='', "; $sql .= "chdescription ='' "; $sql .= "WHERE numid='". $this->hrsid. "' "; $database->query($sql); $sql = "DELETE FROM orghours "; $sql .= "WHERE numid=". $this->hrsid; $sql .= " LIMIT 1"; $database->query($sql); break; case 'd': $sql = "UPDATE hours SET "; $sql .= "chstatus ='', "; $sql .= "chdate ='', "; $sql .= "chdescription ='' "; $sql .= "WHERE numid='". $this->hrsid. "' "; $database->query($sql); break; default: # code... break; } } } ?> MGofMc

Master Gardeners Hours Collection