Exemple #1
0
 public static function is_watch_list_eligible($pet_wk, $watch_list_wk)
 {
     global $session;
     global $database;
     $pet = Pet::find_by_id($pet_wk);
     $watch_list_detail = Watch_List_Detail::find_by_sql("SELECT * FROM `watch_list_detail` WHERE `watch_list_wk` = " . $watch_list_wk . ";");
     //echo '<pre>' . var_export($watch_list_detail, true) . '</pre>'; //debug
     //generate the dynamic MySQL statement
     $sql = "SELECT `p`.* FROM `pet` AS `p` ";
     $sql .= "INNER JOIN `breed` AS `b` ON `b`.`breed_wk` = `p`.`breed_wk` ";
     $sql .= "INNER JOIN `pet_type` AS `pt` ON `pt`.`pet_type_wk` = `b`.`pet_type_wk` ";
     $sql .= "WHERE `p`.`is_deleted` = 0 AND `p`.`pet_wk` = " . $pet_wk . " ";
     //loop through each criteria, determine if it's eligible
     foreach ($watch_list_detail as $item) {
         //if one of the min or max fields
         if (in_array($item->column_name, array('age_min', 'age_max', 'weight_min', 'weight_max'))) {
             if ($item->column_name == 'age_min') {
                 $sql .= "AND `age` >= " . $item->value . " ";
             } else {
                 if ($item->column_name == 'age_max') {
                     $sql .= "AND `age` <= " . $item->value . " ";
                 } else {
                     if ($item->column_name == 'weight_min') {
                         $sql .= "AND `weight` >= " . $item->value . " ";
                     } else {
                         if ($item->column_name == 'weight_max') {
                             $sql .= "AND `weight` <= " . $item->value . " ";
                         }
                     }
                 }
             }
         } else {
             //not one of the min or max fields
             $sql .= "AND " . ($item->column_name == 'pet_type' ? '`pt`' : '`p`') . ".`" . $item->column_name . "_wk` = " . $item->value . " ";
         }
     }
     $sql .= ";";
     $result = Pet::find_by_sql($sql);
     //if the count of animals returned is 1, return true
     //else, return false
     if (count($result) == 1) {
         return true;
     } else {
         return false;
     }
 }
             redirect_head(ROOT_URL . "admin/manage_breeds.php");
         }
     }
 }
 /* if Pet_Type is being deleted */
 if (isset($_POST["delete_" . $type_name . "_name"])) {
     $success = true;
     // track successful breed deletions
     // Reassign all of the pets associated with each of the breeds
     // associated with this pet type first. Then
     // delete all of the breeds associated to this pet type. Then
     // actually delete the pet type.
     $assoc_breeds = Breed::find_by_sql("SELECT * FROM `" . Breed::$table_name . "` WHERE `pet_type_wk` = " . $type->pet_type_wk . ";");
     foreach ($assoc_breeds as $breed) {
         // get all pets associated with this breed
         $assoc_pets = Pet::find_by_sql("SELECT * FROM `" . Pet::$table_name . "` WHERE `breed_wk` = " . $breed->breed_wk . ";");
         foreach ($assoc_pets as $pet) {
             // reassign the pet to undefined breed and undefined type
             $pet->breed_wk = 0;
             if ($pet->save()) {
                 $session->message($session->message . $pet->name . " now has an undefined breed and type.<br />");
             } else {
                 $success = false;
                 $session->message($session->message . $pet->type . " was not successfully redefined.<br />");
             }
         }
         // now delete the breed
         if ($breed->delete()) {
             $session->message($session->message . $breed->name . " has been successfully deleted.<br />");
         } else {
             $success = false;
Exemple #3
0
		document.getElementById('reportCombo2').innerHTML = "Charts are unavailable at this time, Please reload the page or try again later";
	}
}

function displayChart1(){
	try{
		var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
		var today = new Date();
		var currentMonth = today.getMonth();
		var currentYear = today.getFullYear();
		var statuses = [];
		var statusesWk = [];
		var data = [];
		var header = ['Months'];
		<?php 
$pets = Pet::find_by_sql($sql);
$stats = Status::find_by_sql("SELECT DISTINCT * FROM status;");
foreach ($stats as $stat) {
    ?>
				statuses.push(<?php 
    echo "'" . $stat->name . "'";
    ?>
);
				header.push(<?php 
    echo "'" . $stat->name . "'";
    ?>
);
				statusesWk.push(<?php 
    echo $stat->status_wk;
    ?>
);
Exemple #4
0
function get_slider_pets()
{
    $six_pets = Pet::find_by_sql("SELECT * FROM pet WHERE is_deleted = 0 ORDER BY create_dt DESC LIMIT 17;");
    return $six_pets;
}