Professional Documents
Culture Documents
SpotAVet Documentation
SpotAVet Documentation
Introduction
Pets, either professionally trained or average domestic have various benefits to humans.
Guide for the blind, ease loneliness, reduce stress, promote social interaction, encourage exercise
and playfulness are some benefits of having a pet. Caring for a pet may also help a person live
longer. [1]
Human health is inextricably linked to animal health and production. [2] One of the most
enriching and delightful experience in life is to own a pet. [3] Pets help a person to become more
responsible, when they get a pet there is no doubt they will take care of them. The life and death
of another being on their hands makes them become a more responsible person. They learn to
manage their time, since it will surely take a significant amount of their time taking care of pets.
They will become a more nurturing and caring person. The emotional link between them and
their pet could both last for a lifetime. And surely, they’ll get a better health.
However, there are some cases that a person is not allowed to have a pet, or if they do
they must know the potential risk for diseases that can be passed from animals to humans. Also
during these cases, the service of veterinary clinic is important. Veterinarians could give a
person all information they need on infections that they might get from their pets. Veterinarians
could also examine all their pets and give their pet vaccinations if necessary.
specialization and services of veterinarians is very limited. This information would be beneficial
in helping the companion animals for protection as well as for being able to protect people from
UP Diliman, veterinary clinic/hospital operations are basically the same as operations of human
hospitals aside from the difference of whom to be treated. The same procedures are followed on
treating animal’s diseases, confinement and operation. Veterinarian’s specialization is almost the
same as normal doctor’s specialization. But even though the facilities and technology used for
treatment of animal disease are modern, there are no applications or automated systems used for
maintaining animal data records. Specifically in UP Veterinary Hospital, manual input of animal
records are done by hospital secretary, transactions from registration to payment are done
manually as well.
The essential role of animals in the transmission of infectious diseases has long been
recognized. Not only were animals known to be responsible for the maintenance of infections in
nature by harboring and enabling pathogens to survive; animals were also found to be an active
cause of pathogen spread in the environment and to other animals, including man. [4]
Availability of information about veterinary clinics that could help prevent the
transmission of infectious diseases from animals is very limited. It is hard to find the nearest
veterinary clinic that could cater the needs of pet owners with the current available systems on
the internet.
veterinary clinics thus leading pet owners on wrong clinic. This causes loss in time, effort and
even money for both the pet owner and the clinic.
2
C. Objectives
The project aims to create a Web and Android-based application that would provide
necessary information to pet owners of the location, and specialization of the nearest veterinary
clinic. It aims to help them find or search the most suitable clinic to cater their pet’s needs.
General Features/Functionalities:
- Allow users to issue queries on the nearest veterinary clinic available to their location.
The system will use an online interactive map service (Google Maps) to show the nearest
search results.
- Allow veterinarians to enter consultation information, along with the laboratory results
and medication
Web-based application:
Pet Owner:
Clinic Owner:
Veterinarian:
2. To allow the System Administrator who maintains the overall system’s database to:
4
Android application:
Looking for a good veterinarian to cater pet owner needs with less time taken than usual,
this system would create a way to connect more pet lovers to veterinarians and the community.
Animal diseases that human can catch are called zoonoses. Pets are no exception with
possibility to carry worms, viruses, and bacteria causing disease that is transferrable to human
information on location, specialization and services on veterinary clinics, pet owners could
protect their beloved companion and themselves from this kind of disease.
It helps reduce anxiety for pet owners or users looking for clinics for their pet to be
checked or cured. Scheduling visit and consultation will also not be a problem. Pet records and
2. Accuracy of information, data or location is based from the data provided by clinic and
5
3. Speed of queries is based on internet connection speed.
7. Only legally allowed pets are considered as type of pet and veterinarian’s specialization
as of this development
6
II. Review of Related Literature
Medical informatics is the discipline concerned with the theoretical foundations and
research, and practice. [6] Medical informatics areas are an integral part of veterinary practice –
for example, digital radiology and patient information software. Though information systems for
practice management and health are common, there is only minimal system that caters the need
practice. [7]
Oro City, Philippines is a system designed for quick and easy retrieval of pet records. It is used
to provide reliable and secured data preservation for the clinic. With the use of the system, the
clinic can operate more efficiently because every information is managed electronically. [8]
There are also available software systems to control, help and improve the current
process implemented. One example of this is CryoWEB. CryoWeb is web software used for the
applicable to all livestock breeds, independent of donors' species and type of preserved animals.
It also provides a way to trace the usage of the sample gene and the sample vessel within the
and data used to view and manage information connected with specific locations, analyze spatial
relationships, and model spatial processes. It can be used to provide information on affected
7
location that is critical to decision making associated with large outbreaks, whether animal or
human. Animal health authorities stated that GIS is one of the most powerful weapons they have
Nearest Hospital Search and Inquiry System (NHSIS) is a Special Problem made by
Meybel R. Martirez on 2004. NHSIS is a location based system designed to locate the nearest
hospitals from user’s location. It is a web-based application that generates clinical data provided
by the registered hospitals. It allows both registered and general users to issue their queries on
the hospital nearest to their location, doctors’ schedule of activities and the list of available
Later on during 2010, another Special Problem was made, Telehealth’s Geographic
Information System (TGIS) by Alexis Angelo Sadie. One of its objectives is to provide data
analysis to map and track origin of outbreak for diseases. It includes maps and charts in
presenting analyzed data. It uses Geographic Information system for a better visualization of the
geographical location associated with a specific study. It also integrates the result of NHSIS as
based search engine that enables user to search local specific location in Singapore and return the
distance from the current user’s location. The user can view the searched location on a satellite
map instead of the traditional two dimensional map currently use in street view directories. It
uses Haversine’s formula to calculate the distance between two coordinates. Whereas, the user is
required to input their current coordinate, then this coordinate is used during search to be able to
return the distance from user’s current location and the searched location. [13]
8
Geospatial health resource data and improved software analysis enable development of
digital “health maps”. The information derived from GIS-based descriptive maps provides an
operational tool for planning, monitoring and managing control programs for infectious diseases.
[14]
related to cancer-control activities. The system is designed primarily to enable web distribution
of maps to support public health activities related to cancer. It uses GIS as a tool to integrate,
analyze, and present geo-referenced data about cancer and associated covariates and risk factors.
The Pennsylvania Cancer Atlas (PA CA) for example, is designed to serve not as a product for
public use but as a model for the kind of atlases that state departments of public health, state
cancer registries, and related organizations can implement to disseminate the data they generate
Web Based Bicycle Trip Planning for Broward County, Florida is a GIS application
designed to promote bicycle as mode of transportation for increasing urban traffic congestion. It
uses ArcGIS Sever framework with ArcGIS JavaScript Extension for Google Maps API and the
Google Local Search Control for Maps API that allows user to access local search results from
businesses, addresses, road and intersections, political entities to geographic coordinates. [16]
Implementation of Location based Services in Android using GPS and Web Services uses
Android’s build in support for location base services that allows mobile user to exploit their
knowledge of the geographical position and use that information to provide different kind of
services like advising clients of current traffic conditions, providing routing information, helping
9
Restaurant Finder is an Android application that helps users to find the restaurants
according to their preferences. It provides easy access to nearby restaurants and its location on
map. It allows user to search by category such as type of cuisine, rating of restaurants and
distance from current location. The application also provides opportunity for customers to write
reviews and ratings for the restaurant’s service. With the use of Google Maps API it allows users
to view top five (5) restaurants present in the current location and it also provides route to the
restaurants. The application also makes it easy for the user to send out invitations to his/her
friends/colleagues for meetings and also mark the events in their calendar. [18]
Qualitative Study to Inform Future Practice, is a Web-based DPD intervention that aims to
qualitatively explore women veterans’ early experiences with diabetes, estimate weight loss,
participation and engagement to provide context for its findings. Participants perceived the DFD
program as an appealing way of initiating lifestyle changes and made them feel accountable in
achieving their daily goals. The online program was convenient because it could be accessed at
any time, and many found that it integrated well into daily life. [27]
Exploring the Far Side of Mobile Health: Information Security and Privacy of Mobile
Health Apps on iOS and Android establish an overview of Mobile health (mHealth) apps offered
on iOS and Android with a special focus on potential damage to users through information
security and privacy infringements. Through this study, it is found that various kinds of mHealth
apps collect and offer critical, sensitive, private medical information, calling for a special focus
on information security and privacy of mHealth apps. In order to foster user acceptance and trust,
appropriate security measures and processes need to be devised and employed so that users can
10
benefit from seamlessly accessible, tailored mHealth apps without exposing themselves to the
11
III. Theoretical Framework
Many veterinary medical offices have changed their system of recordkeeping from a
handwritten one to electronic system. Whether a veterinary practice keeps medical records in a
handwritten format or in an electronic format, the same rules applies; there is no single standard
of completeness for each record. However, medical records should contain the following key
This SP serves as an information system for pet medical records. It stores data from
appointment to medication and will be available from the time they used the system. The
information stored may be used as reference if needed, be it future use or for practice of
veterinary medicine.
B. Android OS
Android or Android OS is the operating system that powers more than one billion
smartphones and tablets. [19] It is based on Linux kernel and currently developed by Google and
primarily designed for touchscreen devices. On top of the Linux kernel, there are the
middleware, libraries and APIs written in C, and application software running on an application
framework which includes Java-compatible libraries. This enables any android device the ability
Android applications are usually developed in the Java programming language using the
Android Software Development Kit (SDK). The Android SDK provides a fast and reliable
12
development environment for building, testing, and debugging Android applications in
Windows, Mac or Linux. It gives mobile developers the chance to play around with the new
platform. It contains everything you need to start building applications, as well as a fully
specific geographic locations and are used for navigation and mapping. Most of these systems
use coordinate values, which are expressed as numeric or alphanumeric characters, to define
geographic locations. Coordinate systems are based on reference points from which position
Coordinate systems enable geographic datasets to use common locations for integration.
A coordinate system is a reference system used to represent the locations of geographic features,
imagery, and observations, such as Global Positioning System (GPS) locations, within a
planimetric coordinates of the earth and is projected onto a two-dimensional planar surface. It
uses feet or meter for projected coordinate systems or decimal degrees for latitude-longitude.
[21]
D. Google Maps
geographical regions and sites around the world. In addition to conventional road maps, Google
Maps offers aerial and satellite views of many places. It serves as a route planner that offers
13
directions on uses of public transport. Google Maps API makes it possible for Web site
administrators or designers to embed Google Maps on their applications. Google Street View
enables user to view and navigate through the horizontal and vertical panoramic street level
images. [22]
humans to read and write. It is easy for machines to parse and generate. JSON is a text format
that is completely language independent but uses conventions that are familiar to programmers
of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many
{ string 1 ; value 1, string 2 ; value 2, string ... ; value ... } <- object
list, or sequence.
14
An Android application and a remote MySQL database cannot communicate with each
other directly. By utilizing PHP to send query and return it in JSON format, it is possible for an
JSON
As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default.
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
Figure 4. Sample code snippet on converting arrays into JSON using PHP
{"a":1,"b":2,"c":3,"d":4,"e":5}
Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -
122.083739), which you can use to place markers or position the map. [24]
15
A Geocoding API request must be of the following form:
https://maps.googleapis.com/maps/api/geocode/output?parameters
{
"results" : [
{
"address_components" : [
{
"long_name" : "Manila",
"short_name" : "Manila",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Metro Manila",
"short_name" : "NCR",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Philippines",
"short_name" : "PH",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Manila, Metro Manila, Philippines",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 14.6390175,
"lng" : 121.0261686
},
"southwest" : {
"lat" : 14.5571256,
"lng" : 120.9331339
}
},
"location" : {
"lat" : 14.5995124,
"lng" : 120.9842195
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 14.6390175,
"lng" : 121.0261686
16
},
"southwest" : {
"lat" : 14.5571256,
"lng" : 120.9331339
}
}
},
"place_id" : "ChIJi8MeVwPKlzMRH8FpEHXV0Wk",
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
https://maps.googleapis.com/maps/api/geocode/json?address=manila
The values on lat and lng under “location” string will be used for Haversine computation.
Whenever possible the value to be used will be based on location type result base on the
following indicator:
"ROOFTOP" restricts the results to addresses for which we have location information
interpolated range generally indicates that rooftop geocodes are unavailable for a street
address.
[24]
17
G. Haversine
distances between two points on a sphere from their longitudes and latitudes. [25]
Haversine formula:
c = 2 * atan2(√a, √(1−a))
d=R*c
6,371km)
By using the latitude and longitude value we get on Google Geocoding API and this
formula we could determine the nearest veterinary clinic within the area.
18
IV. Design and Implementation
A. Context Diagram
Overall interaction of all external entities that have direct use and access to the
application is shown in Figure 7. SpotAVet have five main role types namely: Clinic Owner,
Veterinarian, Pet Owner, System Administrator, and the non-registered users or guests.
19
B. Data Flow Diagram
The top-level data flow diagram is shown in Figure 8. It represents the relationships
between the various components and entities that are included in the system
20
All users who intend to use the system go through the login process (refer to Figure 9:
Login Process). Credentials (username/password) assigned for each user are used during login
process. It is then check if same matches the data from database. The system notifies the user for
System administrator has full control on all accounts used to access the application.
Approval of new clinic account request, as well as activating and deactivating it are roles that the
Other users of the application (Clinic Secretary, Pet Owner and Veterinarian) are able to
update information associated to them. Editing information is only allowed for fields that is not
needed as unique (i.e., address). All changes on user information are subject to system
verification.
21
Figure 10. Sub-explosion Level 1 – 2.0 Manage User Account
allowed to make changes on its own schedule per servicing clinic. This is applicable to clinic
schedule or operating hours, only the clinic owner is allowed such change in schedule.
22
Figure 11. Sub-explosion Level 1 – 3.0 Manage Schedule
When the pet owner decides to make an appointment, it is required to do the search as
first step (refer to Sub-explosion Level 1 of Manage Search). At the end of the search, pet owner
chooses the veterinarian to set up schedule with, fill up all necessary information and make a
request.
When the veterinarian received an appointment request, the vet reviews the request and
decides whether to accept or decline the request. If a request is declined, the veterinarian needs to
provide information on why the request is declined and the appointment is updated.
23
Before a pet owner can set appointment it is required to register the pet that will undergo
examination/checkup. In the occurrence that pet information must be updated, pet owners have
Every after examination, veterinarians are required to update the pet information for the
result, this will serve as the medical history for the pet. In case of walk-in patient and
unregistered owner, veterinarians can create account for the owner and initial profile for the pet,
24
Pet owner is allowed to filter search conditions such as veterinarian name and clinic
name. This will then show list of clinic that have match on the set conditions. From the list,
select the clinic and the list of veterinarian and schedule is shown. Select the veterinarian and
from there you can set an appointment (refer to 4.0 Manage Appointments).
Non registered users can search clinic nearest to current location, but is not able to set
appointment.
25
Non-registered clinic owners can fill up registration form with desired account
information and then submit to the system. It is then queued to System Admin for approval (refer
to 2.0 Manage User Account). Upon approval the account can already be used to access the
application.
26
C. Entity Relationship Diagram
The system is following the specific design for database shown in Figure 16.
27
D. Database Table
The database consists of tables containing all information necessary for the system to
MEDICATION, LABORATORY and VACCINATION. Primary Key = (pk) and Foreign Key =
(fk).
28
approval
TABLE 2: USER contains all registered users of the system
29
TABLE 7: VET_ SPECIALIZATION contains details of all VETERINARIAN specialization
30
breed VARCHAR(50) Specific breed of pet.
name VARCHAR(50) Name of the pet.
age INTEGER(5) Age of the pet.
gender VARCHAR(20) Pet’s gender.
birthdate VARCHAR(50) Pet’s birthday (if applicable)
TABLE 11: PET contains all necessary pet information.
31
medicine VARCHAR(50) Medicine information.
dosage VARCHAR(50) Dosage of medicine.
date VARCHAR(50) Date the medication was prescribed.
TABLE 14: MEDICATION contains information for necessary medication for the pet.
E. Technical Architecture
The system is implemented using various technologies available today. The following are
1. Programming Language:
a. PHP 5.5.11
b. jQuery 1.11.0
32
c. Java
2. Web Server:
a. XAMPP 1.8.3
c. JSON
3. Database:
The system is available on Web and Android devices with OS v4.x, and requires internet
connection. The system is working and tested using Google Chrome as web browser.
33
V. Results
The home page of SpotAVet is shown in Figure 17. In this page, clinic owners may
choose to register their clinic to the system, and registered users may choose to login. Initially,
only clinic owners could request for a user account. It is then approved by the system
administrator.
Upon successful login to the system, users are directed to their specific page based on
their roles.
34
Figure 18. SpotAVet login page
If the user is an administrator, the page for administrator is displayed, as shown in Fig 19
35
Administrator is responsible for approval, activation and deactivation of clinic account.
By Viewing Clinic account the activation and deactivation menu will be available.
clicked, the clinic account is activated or deactivated respectively. See Figure 20 as reference.
When Clinic Requests button is clicked, list of clinics requesting account activation are
shown. See Figure 21. Clicking or icon will approve or disapprove the request
respectively.
36
Figure 21. Administrator – Clinic Requests page.
If the user is a Clinic Owner, the Clinic Owner homepage is displayed, as shown in
Figure 22
37
Clinic owners could navigate from personal profile, clinic profile and veterinarians within
the clinic. The clinic owner is the one responsible in creating account for every veterinarian
If the user role is a Veterinarian the vet homepage is displayed as shown in Figure 23.
Just like the clinic owner, Veterinarian could update personal profile and view clinic
information, maintains medical record for his/her patient and approve appointment request. Also,
Veterinarians are the one responsible in creating account for pet owners and their pets having
consultation for the first time. Both pet owners and pet details are added being when creating
38
account for pet owners. Appointment request coming from registered users can be viewed,
Lastly, if the user is a Pet Owner, they will be able to see their homepage as shown in
Figure 24.
View and update of own profile and pet information are the main functionality the owner
can do. Once account as pet owner was created, scheduling appointment via web will now be
39
B. Web-based application: System Functionality
Only clinic owners can applies for account for the system. By using the form shown in
Figure 25, any clinic owner could request for account to the system.
40
It will then need to be approved by system administrator. Once approved, veterinarian
account could now be created by the registered clinic. Only registered clinic can create new
veterinarian account with the use of the form shown in Figure 26. Accounts created for
veterinarians are pre-approved by the system and can already be used. It is advised to change
password after initial login to the system. Any user can change password by editing his/her own
profile.
41
In cases where the veterinarian has already an account and would only join a new clinic
to offer their services, clinic owner could search veterinary name or email, set up the schedule
and add the vet on clinic’s vet list. See Figure 27.
registration, veterinarian could already use the system. As a veterinarian, they are responsible in
maintaining the pet medical record for their patients. Every after consultation, veterinarians will
add the result of consultation to the system, result of laboratory if there is any and medication
details as well as vaccination history. In cases where the client/pet owner does not yet have the
42
account for the system veterinarians can create account for owner and profile for the pet. Refer to
43
Figure 29. Add new patient form
44
Pet owners that already have access to the system should register all his pets to the
system for the veterinarian. Pet owners are responsible on updating personal info as well as pet
information. When adding and updating the pet information, the form to be used is shown in
Figure 30.
Pet owners can also utilize the set appointment feature of the system. This will set up
appointment schedule for the desired clinic or veterinarian. Only the veterinarian chosen from
the selection will see the details of the request. See Figure 31 to have an idea how appointment is
requested.
45
Figure 31. Request appointment form
One of the unique features of mobile application is location awareness. SpotAVet for android
starts with the current location of the user. The search could be triggered at start to check if any
registered clinic is nearby. If none, you could either zoom out to widen the search perimeter or
touch in the map the location you want to start the search. See Figure 32 for reference on how the
UI looks like.
46
Figure 32. SpotAVet android
The application would notify the user if a clinic has been found or not. By clicking the
marker on the map, the name of the clinic would pop up. See figure 33 for reference.
47
Figure 33. SpotAVet Android: Clinic found
Tapping on the name of the clinic would give you the complete information about the clinic.
If no list of veterinarian is shown it means that the clinic has not added any veterinarians on
clinic profile. Tapping on the name of a veterinarian on list would give the user the complete
profile of the vet. See Figure 48 and Figure 49 for example.
48
Figure 34. SpotAVet android: Clinic Information
49
VI. Discussion
SpotAVet is a Web-based system application that provides support for pet owners to get
the service they need for their pets. With an extension to Android device that allows user to
search veterinary clinic base on location, the system becomes more flexible. Even though the
main functionality such as registration, appointment request and storage of pet medical record
are only available on Web, by using the Android extension, pet owners, registered or not
registered, could already have the idea on where the clinic is, as well as its schedule and its
veterinarians. Furthermore, information about veterinarians schedule and specialty are also
provided.
Aside from the information about the clinic and veterinarians, the system also provides
the capability to store pet medical records. Consultation result, medication given, and laboratory
results are examples of data the system stores as part of pet medical record. But, this information
Interested clinic could request for account to gain access to the system, this is done so
that administrator of the system have time to investigate legitimacy of the clinic applying for
system use. After the clinic account has been approved by system administrator, the clinic
owner could now add veterinarian account for veterinarians working in their clinic. Veterinarians
could later on create account for pet owners which would later on use the system for adding pet
To ensure that all clinic data are correct, System Administrator was given the privilege to
activate or deactivate a clinic account. In cases for example, if the clinic closes or stopped their
operation the system admin could immediately deactivate its clinic account.
50
VII. Conclusion
Utilizing the features provided by SpotAVet, with support from various veterinary
clinics, veterinarians and pet owners could improve the way we deal with some of the problems
associated with animals and pets. Getting the help we need when we need them, and the
information when we need them can be a key in solving problems associated with pet and
Also, SpotAVet, when enhanced, could greatly improve the way we handle pet medical
record. When this records are properly handled, it could soon be reused by veterinarians and
improve the way to deal with various diseases that pets or animals are suffering.
Furthermore, SpotAVet can also be used as template or reference for other similar
applications. As a location based application that works both in Web and Android platform it can
be considered as framework when developing similar applications. With the use of this kind of
Finally, with the use of current technology where fast and reliable information are greatly
51
VIII. Recommendations
SpotAVet allows pet owner to search by clinic name or veterinarian name and email
address whenever they want to set appointment. Improving the search option to more advance,
like by specialization or clinic services, would greatly improve the benefit users could attain by
using the system. Also, enabling the Android extension to allow setting-up appointment would
The current scope of the system is limited to veterinary clinic that is servicing outpatient
request, adding option for veterinary hospitals and inpatients services would broaden the scope.
This would give users more diverse selection and information when using the system.
Having a standard or more comprehensive form of capturing pet information and record
would greatly improve the information the system could provide its users. Identifying sensitive
information and doing encryption would secure users information and could boost confidence in
52
IX. Bibliography
[1] The Therapeutic & Health Benefits of Pets. (n.d.). Retrieved March 23, 2014, from
[2] Veterinary Public Health. (n.d.). Retrieved March 23, 2014, from WHO | World Health
Organization: http://www.who.int/zoonoses/vph/en/
[3] The Importance of Pets – 6 Benefits of Owning a Pet. (n.d.). Retrieved March 23, 2014, from
of-owning-a-pet/
[4] Mantovani, A. (1992). Collaborating Centre for Research and Training in Veterinary Public
[5] Dr. Ronald Hines, D. (n.d.). Diseases We Catch From Our Pets - Zoonotic Illnesses Of Dogs
http://www.2ndchance.info/zoonoses.htm
[6] Smith, R. D., & Williams, M. (2000, January). Applications of informatics in veterinary
[7] Alpi, K. M., & Kenan, W. J. (2009). Exploring the State of Veterinary Informatics. Library of
[8] Amarille, K. C., Seblos, C. R., Bustilla, N. F., Billones, J. C., & Asiñero, J. P. (2010). Web-
53
[9] Duchev, Z., Cong, T. V., & Groeneveld, E. (2010). CryoWEB: Web software for the
220.
[10] ESRI. (n.d.). Geographic Information Systems and Pandemic Influenza Planning and
http://www.esri.com/library/whitepapers/pdfs/gis-and-pandemic-planning.pdf
[11] Martirez, M. R. (2004). “Nearest Hospital Search and Inquiry System ". University of the
Philippines, Manila.
Philippines, Manila.
[13] Tsai, F. S. (2011). Web-based geographic search engine for location-aware search in
[15] MacEachren, A. M., Crawford, S., Akella, M., & Lengerich, G. (2008). Design and
[16] Hochmair, H. H., & Fu, Z. (2013). Web Based Bicycle Trip Planning for Broward County,
[17] Singhal, M., & Shukla, A. (2012). Implementation of Location based Services in Android
using GPS and Web Services. International Journal of Computer Science Issues.
54
[18] Parne, S. R. (2010). Android Application of Restaurant Finder. https://krex.k-
state.edu/dspace/bitstream/handle/2097/14061/SpoorthyReddyParne2012.pdf
[19] The Android Story. (n.d.). Retrieved April 21, 2015, from
https://www.android.com/intl/en_us/history/
[20] National Wildlife Coordinating Group. (2007, June). Chapter 3 : Geographic Location
http://www.nwcg.gov/pms/pubs/475/PMS475_chap3.pdf
[21] Coordinate systems, map projections, and geographic (datum) transformations. (n.d.).
http://resources.esri.com/help/9.3/arcgisengine/dotnet/89b720a5-7339-44b0-8b58-
0f5bf2843393.htm
http://whatis.techtarget.com/definition/Google-Maps
[23] Introducing JSON. (n.d.). Retrieved April 21, 2015, from http://json.org/
[24] The Google Geocoding API. (n.d.). Retrieved March 23, 2014, from Google Developers:
https://developers.google.com/maps/documentation/geocoding/
[25] Latitude & Longitude Haversine Formula. (n.d.). Retrieved March 23, 2014, from
http://www.longitudestore.com/haversine-formula.html
[26] Calculate distance, bearing and more between Latitude/Longitude points. (n.d.). Retrieved
March 23, 2014, from Movable Type - Information Design & Management:
http://www.movable-type.co.uk/scripts/latlong.html
55
[27] Dehling T, G. F. (2015). Exploring the Far Side of Mobile Health: Information Security and
Privacy of Mobile Health Apps on iOS and Android. JMIR mHealth and uHealth.
56
/************************************
X. Appendix ********************************************
*****************************************
* Unregistered Users
*************************************
********************************************
A. Source Code - PHP ****************************************/
public function login()
{
$data['title'] = 'Login';
Listing 1: controllers/main.php $data['status'] = $this-
>session->userdata('error_msg');
<?php if($this->session-
defined('BASEPATH') OR exit('No direct >userdata('isLoggedIn') == FALSE){
script access allowed'); $this->load-
>view('panels/header');
class Main extends CI_Controller { $this->load-
>view('login', $data);
public function __construct() $this->load-
{ >view('panels/footer');
parent::__construct(); $this->session-
>set_userdata('error_msg', "");
$this->load->helper('url'); } else {
$this->load->helper('form'); $this->home();
$this->load- }
>library('form_validation');
$this->load- }
>model('model_home');
} public function verify_login()
{
/** $username = $this->input-
* Index Page for this controller. >post('username');
* $password = $this->input-
* Maps to the following URL >post('password');
*
http://example.com/index.php/main if($this->model_home-
* - or - >isUser($username, $password)){
*
http://example.com/index.php/main/ind redirect('/main/home');
ex } else {
* - or - if($this->session-
* Since this controller is set as >userdata('isLoggedIn') == FALSE){
the default controller in
* config/routes.php, it's displayed redirect('/main/login');
at http://example.com/ } else {
*
* So any other public methods not redirect('/main/home');
prefixed with an underscore will }
* map to }
/index.php/welcome/<method_name> }
* @see
http://codeigniter.com/user_guide/general/ur public function delete_session()
ls.html {
*/ $sess_data = array(
public function index() 'username',
{ 'user_role',
$this->load- 'email',
>view('panels/header'); 'last_name',
$this->load- 'first_name',
>view('panels/sidebar'); 'middle_name',
$this->load->view('home'); 'contact_no',
$this->load- 'error_msg',
>view('panels/footer'); 'clinic_owner_id',
'clinic_id',
'vet_id',
'owner_id'
} );
$this->session-
>unset_userdata($sess_data);
57
$this->session-
>set_userdata('isLoggedIn', FALSE); $userRequest['last_name'] = $this-
} >input->post('last_name');
58
} }
else {
return TRUE; public function edit_profile()
} {
} if ( $this->session-
>userdata('isLoggedIn') == FALSE) {
public function check_schedule($str) redirect('/');
{ }
if ((preg_match("/[a-zA-
Z]{3}\s*~\s*[a-zA- $data['profile'] = $this-
Z]{3}\s*::\s*\d{1,2}:\d{1,2}\s*[ampAMP]{2}\s >model_home->get_profile($this->session-
*~\s*\d{1,2}:\d{1,2}\s*[ampAMP]{2}\s*/", >userdata('username'));
$str, $matches)) $data['specializations'] =
|| (preg_match("/[a-zA- $this->model_home->get_specializationlist();
Z]{3}\s*::\s*\d{1,2}:\d{1,2}\s*[ampAMP]{2}\s $data['license_no'] = $this-
*~\s*\d{1,2}:\d{1,2}\s*[ampAMP]{2}\s*/", >model_home->get_vetlicense($this->session-
$str, $matches))) { >userdata('username'));
return TRUE;
} else { $data['vet_special'] = $this-
$this- >model_home->get_specializations($this-
>form_validation- >session->userdata('vet_id'));
>set_message('check_schedule', 'Please
follow the format (WED ~ FRI :: 09:00 AM ~ $this->load-
05:00 PM)'); >view('panels/header');
return FALSE; $this->load-
} >view('panels/sidebar');
} $this->load-
>view('content/edit-profile', $data);
/************************************ $this->load-
******************************************** >view('panels/footer');
***************************************** }
* Registered Users
************************************* public function editting_profile()
******************************************** {
****************************************/ if ( $this->session-
>userdata('isLoggedIn') == FALSE) {
public function home() redirect('/');
{ }
if ( $this->session-
>userdata('isLoggedIn') == FALSE) { if ($_SESSION['user_role'] ==
redirect('/'); 3) {
} $this-
>form_validation->set_rules('license_no',
$this->load- 'license number', 'required');
>view('panels/header'); $this-
$this->load- >form_validation->set_rules('specialize[]',
>view('panels/sidebar'); 'specialization', 'required');
$this->load->view('home'); }
$this->load-
>view('panels/footer'); $this->form_validation-
} >set_rules('password', 'password',
'required');
public function view_profile() $this->form_validation-
{ >set_rules('confirm_password', 'confirm
if ( $this->session- password', 'required|matches[password]');
>userdata('isLoggedIn') == FALSE) { $this->form_validation-
redirect('/'); >set_rules('last_name', 'last name',
} 'required');
$this->form_validation-
$data['profile'] = $this- >set_rules('first_name', 'first name',
>model_home- 'required');
>get_profile($_SESSION['username']); $this->form_validation-
>set_rules('middle_name', 'middle name',
$this->load- 'required');
>view('panels/header'); $this->form_validation-
$this->load- >set_rules('contact_no', 'contact number',
>view('panels/sidebar-profile'); 'required');
$this->load-
>view('content/my-profile', $data); if ($this->form_validation-
$this->load- >run() == FALSE)
>view('panels/footer'); {
59
$this->edit_profile(); $this->delete_session();
}
else redirect('/');
{ }
$this->model_home- $clinic_id =
>update_userprofile($userRequest); $_POST['clinic_id'];
$this->view_profile(); $this->model_home-
} >update_activation($clinic_id);
}
$this->manage_clinics();
public function }
view_clinic($clinic_id)
{ public function clinic_requests()
if ( $this->session- {
>userdata('isLoggedIn') == FALSE) { if ($this->session-
redirect('/'); >userdata('isLoggedIn') == FALSE ||
} $_SESSION['user_role'] != 1) {
redirect('/');
$data['clinic'] = $this- }
>model_home->get_clinic_info($clinic_id);
$data['clinicsList'] = $this-
$this->load- >model_home->get_all_clinicrequests();
>view('panels/header');
$this->load- $this->load-
>view('panels/sidebar-clinic', $data); >view('panels/header');
$this->load- $this->load-
>view('content/my-clinic', $data); >view('panels/sidebar');
$this->load- $this->load-
>view('panels/footer'); >view('content/viewClinicRequests', $data);
} $this->load-
>view('panels/footer');
public function logout() }
{
60
public function
approve_request($username) $this->load-
{ >view('panels/header');
if ($this->session- $this->load-
>userdata('isLoggedIn') == FALSE || >view('panels/sidebar');
$_SESSION['user_role'] != 1) { $this->load-
redirect('/'); >view('content/edit-clinic', $data);
} $this->load-
>view('panels/footer');
$this->model_home- }
>approve_clinicrequest($username);
$this->clinic_requests(); public function editting_clinic()
} {
if ( $this->session-
public function >userdata('isLoggedIn') == FALSE) {
delete_request($username) redirect('/');
{ }
if ($this->session-
>userdata('isLoggedIn') == FALSE || $this->form_validation-
$_SESSION['user_role'] != 1) { >set_rules('clinic_email', 'e-mail address',
redirect('/'); 'required|valid_email');
} $this->form_validation-
>set_rules('contact_no', 'contact number',
$this->model_home- 'required');
>delete_clinicrequest($username); $this->form_validation-
$this->clinic_requests(); >set_rules('clinic_name', 'clinic name',
} 'required');
$this->form_validation-
/************************************ >set_rules('clinic_loc', 'clinic address',
******************************************** 'required');
***************************************** $this->form_validation-
* Clinic Owner exclusive >set_rules('clinic_hours', 'clinic
methods schedule',
************************************* 'required|callback_check_schedule');
********************************************
****************************************/ $this->form_validation-
>set_rules('placepicker', 'clinic location',
public function 'required');
view_myclinic($clinic_owner_id)
{ if ($this->form_validation-
if ( $this->session- >run() == FALSE)
>userdata('isLoggedIn') == FALSE || {
$_SESSION['user_role'] != 2) { $this->edit_clinic();
redirect('/'); }
} else
{
$data['clinic'] = $this- $clinic['clinic_name']
>model_home- = $this->input->post('clinic_name');
>get_myclinic_info($clinic_owner_id); $clinic['address']
= $this->input->post('clinic_loc');
$this->load- $clinic['schedule']
>view('panels/header'); = $this->input->post('clinic_hours');
$this->load- $clinic['contact_no']
>view('panels/sidebar-clinic', $data); = $this->input->post('contact_no');
$this->load- $clinic['email']
>view('content/my-clinic', $data); = $this->input->post('clinic_email');
$this->load- $clinic['lat']
>view('panels/footer'); = $this->input->post('lat');
} $clinic['lng']
= $this->input->post('lng');
public function edit_clinic() $this->model_home-
{ >update_clinicinfo($clinic, $this->session-
if ( $this->session- >userdata('clinic_owner_id'));
>userdata('isLoggedIn') == FALSE || $this-
$_SESSION['user_role'] != 2) { >view_clinic($this->session-
redirect('/'); >userdata('clinic_owner_id'));
} }
}
$data['clinic'] = $this-
>model_home->get_clinic_info($this->session- public function view_veterinarians()
>userdata('clinic_owner_id')); {
61
if ( $this->session- }
>userdata('isLoggedIn') == FALSE ||
$_SESSION['user_role'] != 2) { $query = $_POST['searchvet'];
redirect('/'); $data['vetsResult'] = $this-
} >model_home->search_vet($query);
62
'schedule',
$userRequest['username'] = $this- 'required|callback_check_schedule');
>input->post('username');
$this-
$userRequest['password'] = $this- >form_validation->set_rules('searchvet',
>input->post('password'); 'search', 'required');
$userRequest['role_id'] = 3; $this-
>view_veterinarians();
$userRequest['status'] = 1; }
}
$userRequest['license_no'] = $this- }
>input->post('license_no');
// add to user public function
(username, password, role_id = 3, email, check_vetinclinic($username)
last_name, first_name, middle_name, {
contact_no, status = 1) $vet_id = $this->model_home-
$this- >get_vetid($username);
>model_home->addUser($userRequest); if (array_filter($this-
>model_home-
// add to >get_veterinarian_schedule($vet_id,
veterinarian (username, license_no) vet_id $_SESSION['clinic_id']))) {
$this- $this-
>model_home->addVetDB($userRequest); >form_validation-
>set_message('check_vetinclinic', 'Vet is
// add to already in clinic\'s veterinarian list.');
clinic_vet (clinic_id, vet_id, schedule) return FALSE;
$clinic_id = }
$this->session->userdata('clinic_owner_id'); return TRUE;
$vet_id = }
$this->model_home-
>get_vetid($userRequest['username']);
$sched = /************************************
$_POST['schedule']; ********************************************
$this- *****************************************
>model_home->addClinicVet($clinic_id, * Veterinarian exclusive
$vet_id, $sched); methods
*************************************
$this- ********************************************
>model_home->add_vetspecialization($vet_id, ****************************************/
$_POST['specialize']);
public function view_clinics()
$this- {
>view_veterinarians(); if ( $this->session-
} >userdata('isLoggedIn') == FALSE ||
$_SESSION['user_role'] != 3) {
} else { redirect('/');
$this- }
>form_validation-
>set_rules('hidden_username', '', $data['clinicsList'] = $this-
'callback_check_vetinclinic'); >model_home-
$this- >get_vet_clinics($_SESSION['vet_id']);
>form_validation->set_rules('schedule',
63
$this->load- {
>view('panels/header'); if ( $this->session-
$this->load- >userdata('isLoggedIn') == FALSE ||
>view('panels/sidebar'); $_SESSION['user_role'] != 3) {
$this->load- redirect('/');
>view('content/my-clinics', $data); }
$this->load-
>view('panels/footer'); $data['petsList'] = $this-
} >model_home->get_patients($this->session-
>userdata('vet_id'));
public function
edit_clinic_sched($clinic_id) $data['clinics'] = $this-
{ >model_home-
if ( $this->session- >get_veterinarian_schedule($this->session-
>userdata('isLoggedIn') == FALSE || >userdata('vet_id'));
$_SESSION['user_role'] != 3) {
redirect('/'); $this->load-
} >view('panels/header');
$this->load-
$data['schedule'] = $this- >view('panels/sidebar');
>model_home->get_schedule_str($clinic_id, $this->load-
$_SESSION['vet_id'], 0); >view('content/my-patients', $data);
$data['clinic_id'] = $this->load-
$clinic_id; >view('panels/footer');
}
$this->load-
>view('panels/header'); public function add_patient()
$this->load- {
>view('panels/sidebar'); if ( $this->session-
$this->load- >userdata('isLoggedIn') == FALSE ||
>view('content/edit-vet-sched', $data); $_SESSION['user_role'] != 3) {
$this->load- redirect('/');
>view('panels/footer'); }
}
$data['clinics'] = $this-
public function update_vet_sched() >model_home-
{ >get_veterinarian_schedule($_SESSION['vet_id
if ( $this->session- ']);
>userdata('isLoggedIn') == FALSE ||
$_SESSION['user_role'] != 3) { $this->load-
redirect('/'); >view('panels/header');
} $this->load-
>view('panels/sidebar');
$this->form_validation- $this->load-
>set_rules('new_sched', 'vet schedule', >view('content/add-patient', $data);
'required|callback_check_schedule'); $this->load-
>view('panels/footer');
if ($this->form_validation- }
>run() == FALSE)
{ public function get_patient_list()
$this- {
>edit_clinic_sched($_POST['clinic_id']);
} $clinic_id =
else $_POST['clinic_id'];
{
$pet_list = $this-
$vet_sched['clinic_id'] = >model_home->get_patients($this->session-
$_POST['clinic_id']; >userdata('vet_id'), $clinic_id);
$vet_sched['vet_id']
= $_SESSION['vet_id']; $html_string = '<div>';
$vet_sched['schedule'] $html_string .= '<table
= $_POST['new_sched']; class="patient" "width="700" border="0"
style="font-family: Arial, Helvetica, sans-
$this->model_home- serif; font-size:14px;">
>update_vetclinicsched($vet_sched); <tr>
$this->view_clinics(); <th
} width="189" style="border: #C0C0C0 1px
} solid;"><strong>Pet Name</strong></th>
<th
public function width="189" style="border: #C0C0C0 1px
view_patients($clinic_id = 0) solid;"><strong>Specie</strong></th>
64
<th }
width="189" style="border: #C0C0C0 1px
solid;"><strong>Breed</strong></th> public function add_owner()
<th {
width="392" style="border: #C0C0C0 1px if ( $this->session-
solid;"> <strong>Owner</strong></th> >userdata('isLoggedIn') == FALSE ||
<th $_SESSION['user_role'] != 3) {
width="40" style="border: #C0C0C0 1px redirect('/');
solid;"><strong></strong></th> }
</tr>';
foreach ($pet_list as $pet) $this->form_validation-
{ >set_rules('consultation_date',
$pet_info = $this- 'consultation date', 'required');
>model_home->get_pet_info($pet['pet_id']); $this->form_validation-
$username = $this- >set_rules('complaints', 'chief complaints',
>model_home- 'required');
>get_owner_username($pet_info['owner_id']); $this->form_validation-
$owner = $this- >set_rules('diagnosis', 'diagnosis /
>model_home->get_profile($username); findings', 'required');
$html_string .= $this->form_validation-
'<tr>'; >set_rules('clinic_option', 'clinic',
$html_string .= 'required');
'<td style="border: #C0C0C0 1px
solid;">' . $pet_info['pet_name'] . '</td>'; if
$html_string .= ($_POST['hidden_medication']) {
'<td style="border: #C0C0C0 1px $this-
solid;">' . $pet_info['specie'] . '</td>'; >form_validation-
$html_string .= >set_rules('hidden_medication', '',
'<td style="border: #C0C0C0 1px 'required');
solid;">' . $pet_info['breed'] . '</td>'; $this-
$html_string .= >form_validation->set_rules('medicine',
'<td style="border: #C0C0C0 1px 'medicine', 'required');
solid;">' . $owner['first_name'] . ' ' . $this-
$owner['last_name'] . '</td>'; >form_validation->set_rules('dosage',
$html_string .= 'dosage', 'required');
'<td style="border: #C0C0C0 1px $this-
solid;"> >form_validation-
<a href >set_rules('medication_date',
= ' . "\"" . 'medication_date', 'required');
base_url("index.php/main/view_pet") . "/" . }
$pet['pet_id'] . "\"" . '>';
$html_string .= if
'<img src="' . ($_POST['hidden_vaccination']) {
base_url("resources/images/view.png") . '" $this-
title="View Pet Info"width="20" height="20" >form_validation-
/></a>'; >set_rules('hidden_vaccination', '',
'required');
$html_string .= $this-
'</td>'; >form_validation->set_rules('vaccine_type',
$html_string .= 'vaccine type', 'required');
'</tr>'; $this-
} >form_validation->set_rules('vaccine_name',
$html_string .= 'vaccine name', 'required');
'</table></div>'; $this-
echo $html_string; >form_validation-
} >set_rules('expiration_date',
'expiration_date', 'required');
public function search_patients() $this-
{ >form_validation-
if ( $this->session- >set_rules('next_vaccine_date',
>userdata('isLoggedIn') == FALSE || 'next_vaccine_date', 'required');
$_SESSION['user_role'] != 3) { }
redirect('/');
} if
($_POST['hidden_laboratory']) {
$query = $this-
$_POST['searchpatient']; >form_validation-
$data['patientsResult'] = >set_rules('hidden_laboratory', '',
$this->model_home->search_patient($query); 'required');
$this-
echo $data['patientsResult']; >form_validation-
65
>set_rules('laboratory_type', 'laboratory
type', 'required'); $userRequest['password'] =
$this- $_POST['password'];
>form_validation->set_rules('lab_findings',
'laboratory findings', 'required'); $userRequest['email'] =
$this- $_POST['email'];
>form_validation->set_rules('lab_date',
'laboratory date', 'required'); $userRequest['last_name'] =
} $_POST['last_name'];
$pet_id = $userRequest['first_name'] =
$_POST['hidden_info']; $_POST['first_name'];
if ($pet_id == 0) {
// pet owner fields $userRequest['middle_name'] =
$this- $_POST['middle_name'];
>form_validation->set_rules('username',
'username', $userRequest['contact_no'] =
'required|callback_check_username'); $_POST['contact_no'];
$this-
>form_validation->set_rules('password', $userRequest['role_id'] = 4;
'password',
'required|matches[confirm_password]'); $userRequest['status'] = 1;
$this- // add to user
>form_validation- (username, password, role_id = 4, email,
>set_rules('confirm_password', 'confirm last_name, first_name, middle_name,
password', 'required'); contact_no, status = 1)
$this- $this-
>form_validation->set_rules('email', >model_home->addUser($userRequest);
'email', $owner_id =
'required|valid_email|callback_check_email') $this->model_home-
; >addOwner($userRequest['username']);
$this-
>form_validation->set_rules('last_name', if ($owner_id)
'last name', 'required'); {
$this-
>form_validation->set_rules('first_name', $petRequest['owner_id'] =
'first name name', 'required'); $owner_id;
$this-
>form_validation->set_rules('middle_name', $petRequest['pet_name'] =
'middle name', 'required'); $_POST['pet_name'];
$this-
>form_validation->set_rules('contact_no', $petRequest['specie'] =
'contact number', 'required'); $_POST['specie'];
66
$consultation['consultation_date'] = $vaccination['next_due']
$_POST['consultation_date']; = $_POST['next_vaccine_date'];
$consultation['complaints'] =
$_POST['complaints'];
$this->model_home-
$consultation['diagnosis'] = >addVaccination($vaccination);
$_POST['diagnosis'];
}
$consultation['remarks'] =
$_POST['remarks'];
$consultation['next_consult_date'] = if ($_POST['hidden_laboratory']) {
$_POST['next_consultation'];
$laboratory['pet_id']
$consultation['schedule_appt_id'] = = $pet_id;
'';
$laboratory['consultation_id'] =
$consultation_id = $this->model_home- $consultation_id;
>addConsultation($consultation);
$laboratory['lab_type'] =
$_POST['laboratory_type'];
if ($consultation_id) {
$laboratory['lab_findings']
if ($_POST['hidden_medication']) { = $_POST['lab_findings'];
$medication['pet_id'] $laboratory['lab_date']
= $pet_id; = $_POST['lab_date'];
$medication['consultation_id'] = $this->model_home-
$consultation_id; >addLaboratory($laboratory);
$medication['medicine'] }
= $_POST['medicine'];
$medication['dosage']
= $_POST['dosage']; $this->view_patients();
$medication['med_date'] }
= $_POST['medication_date']; }
}
}
} else {
$this->model_home- $this-
>addMedication($medication); >form_validation->set_rules('searchpatient',
'search', 'required');
}
if ($this-
>form_validation->run() == FALSE)
{
if ($_POST['hidden_vaccination']) { $this-
>add_patient();
$vaccination['pet_id'] } else {
= $pet_id;
$consultation['pet_id'] =
$pet_id;
$vaccination['consultation_id'] =
$consultation_id; $consultation['vet_id'] =
$_SESSION['vet_id'];
$vaccination['vaccine_type']
= $_POST['vaccine_type']; $consultation['clinic_id'] =
$_POST['clinic_option'];
$vaccination['vaccine_name']
= $_POST['vaccine_name']; $consultation['consultation_date'] =
$_POST['consultation_date'];
$vaccination['expiration']
= $_POST['expiration_date']; $consultation['complaints'] =
$_POST['complaints'];
67
$consultation['diagnosis'] = $laboratory['pet_id'] =
$_POST['diagnosis']; $pet_id;
$consultation['remarks'] = $laboratory['consultation_id'] =
$_POST['remarks']; $consultation_id;
$consultation['next_consult_date'] = $laboratory['lab_type'] =
$_POST['next_consultation']; $_POST['laboratory_type'];
$consultation['schedule_appt_id'] = $laboratory['lab_findings'] =
''; $_POST['lab_findings'];
$laboratory['lab_date'] =
$consultation_id = $this->model_home- $_POST['lab_date'];
>addConsultation($consultation);
if $this->model_home-
($consultation_id) { >addLaboratory($laboratory);
if }
($_POST['hidden_medication']) {
$this-
$medication['pet_id'] = >view_patients();
$pet_id; }
}
$medication['consultation_id'] = }
$consultation_id; }
$vaccination['consultation_id'] = $this->load-
$consultation_id; >view('panels/header');
$this->load-
$vaccination['vaccine_type'] = >view('panels/sidebar');
$_POST['vaccine_type']; $this->load-
>view('content/view-appointments', $data);
$vaccination['vaccine_name'] = $this->load-
$_POST['vaccine_name']; >view('panels/footer');
$vaccination['expiration'] = }
$_POST['expiration_date'];
$vaccination['next_due'] = /************************************
$_POST['next_vaccine_date']; ********************************************
*****************************************
* Pet owner exclusive methods
$this->model_home- *************************************
>addVaccination($vaccination); ********************************************
} ****************************************/
if
($_POST['hidden_laboratory']) { public function view_pets()
{
68
if ( $this->session- $petRequest['breed']
>userdata('isLoggedIn') == FALSE || = $_POST['breed'];
$_SESSION['user_role'] != 4) {
redirect('/'); $petRequest['birthdate'] =
} $_POST['birthday'];
$petRequest['gender']
$data['petsList'] = $this- = $_POST['gender'];
>model_home-
>get_mypets($_SESSION['owner_id']); $petRequest['registry'] =
$_POST['registry'];
$this->load-
>view('panels/header'); $this->model_home-
$this->load- >addPet($petRequest);
>view('panels/sidebar'); $this->view_pets();
$this->load- }
>view('content/my-pets', $data); }
$this->load-
>view('panels/footer'); public function edit_pet($pet_id)
} {
if ( $this->session-
public function add_pet() >userdata('isLoggedIn') == FALSE ||
{ $_SESSION['user_role'] != 4) {
if ( $this->session- redirect('/');
>userdata('isLoggedIn') == FALSE || }
$_SESSION['user_role'] != 4) {
redirect('/'); $data['pet'] = $this-
} >model_home->get_pet_info($pet_id);
$this->load-
$this->load- >view('panels/header');
>view('panels/header'); $this->load-
$this->load- >view('panels/sidebar');
>view('panels/sidebar'); $this->load-
$this->load- >view('content/edit-pet', $data);
>view('content/add-pet'); $this->load-
$this->load- >view('panels/footer');
>view('panels/footer'); }
}
public function updatepet()
public function add_newpet() {
{ if ( $this->session-
if ( $this->session- >userdata('isLoggedIn') == FALSE ||
>userdata('isLoggedIn') == FALSE || $_SESSION['user_role'] != 4) {
$_SESSION['user_role'] != 4) { redirect('/');
redirect('/'); }
}
$this->form_validation-
$this->form_validation- >set_rules('pet_name', 'pet name',
>set_rules('pet_name', 'pet name', 'required');
'required'); $this->form_validation-
$this->form_validation- >set_rules('specie', 'specie', 'required');
>set_rules('specie', 'specie', 'required'); $this->form_validation-
$this->form_validation- >set_rules('breed', 'breed', 'required');
>set_rules('breed', 'breed', 'required'); $this->form_validation-
$this->form_validation- >set_rules('birthday', 'birthday',
>set_rules('birthday', 'birthday', 'required');
'required'); $this->form_validation-
$this->form_validation- >set_rules('gender', 'gender', 'required');
>set_rules('gender', 'gender', 'required'); $pet_id = $_POST['pet_id'];
if ($this->form_validation- if ($this->form_validation-
>run() == FALSE) { >run() == FALSE) {
$this->add_pet(); $this-
} else { >edit_pet($pet_id);
} else {
$petRequest['owner_id'] = $petRequest['pet_id']
$_SESSION['owner_id']; = $pet_id;
$petRequest['pet_name'] = $petRequest['owner_id'] =
$_POST['pet_name']; $_SESSION['owner_id'];
$petRequest['specie']
= $_POST['specie'];
69
$data['laboratoryList'] =
$petRequest['pet_name'] = $this->model_home-
$_POST['pet_name']; >get_consultation_laboratory($consultation_i
$petRequest['specie'] d);
= $_POST['specie']; $data['vaccinationList'] =
$petRequest['breed'] $this->model_home-
= $_POST['breed']; >get_consultation_vaccinations($consultation
_id);
$petRequest['birthdate'] =
$_POST['birthday']; $this->load-
$petRequest['gender'] >view('panels/header');
= $_POST['gender']; $this->load-
>view('panels/sidebar-pet');
$petRequest['registry'] = $this->load-
$_POST['registry']; >view('content/view-consultation', $data);
$this->load-
$this->model_home- >view('panels/footer');
>update_pet($petRequest); }
$this->view_pets();
} public function appointment_request()
} {
if ( $this->session-
public function view_pet($pet_id) >userdata('isLoggedIn') == FALSE ||
{ $_SESSION['user_role'] != 4) {
if ( $this->session- redirect('/');
>userdata('isLoggedIn') == FALSE) { }
redirect('/');
} $data['pets'] = $this-
>model_home-
$data['pet'] = $this- >get_mypets($_SESSION['owner_id']);
>model_home->get_pet_info($pet_id);
if ($_SESSION['user_role'] == $this->load-
4) >view('panels/header');
$this->load-
$data['consultationList'] = $this- >view('panels/sidebar');
>model_home- $this->load-
>get_consultation_history($pet_id); >view('content/add-appointment', $data);
else $this->load-
>view('panels/footer');
$data['consultationList'] = $this- }
>model_home-
>get_consultation_history($pet_id, public function search()
$_SESSION['vet_id']); {
if ( $this->session-
$data['pet_id'] = $pet_id; >userdata('isLoggedIn') == FALSE ||
$_SESSION['user_role'] != 4) {
$this->load- redirect('/');
>view('panels/header'); }
$this->load-
>view('panels/sidebar-pet'); $input = explode('::',
$this->load- $_POST['search']);
>view('content/my-pet', $data);
$this->load- $query = $input[0];
>view('panels/footer'); $option = $input[1];
}
if ($option == "Clinic") {
public function $data['result'] =
view_consultation($consultation_id) $this->model_home->search_clinic($query);
{ } else {
if ( $this->session- $data['result'] =
>userdata('isLoggedIn') == FALSE) { $this->model_home->search_vet($query);
redirect('/'); }
}
echo $data['result'];
$data['consultation'] = }
$this->model_home-
>get_consultation_info($consultation_id); public function getVetList()
$data['medicationList'] = {
$this->model_home- if ( $this->session-
>get_consultation_medications($consultation_ >userdata('isLoggedIn') == FALSE ||
id); $_SESSION['user_role'] != 4) {
70
redirect('/'); $result .= '<table><tr><td
} style="text-align:right"><font
size="2"><strong>License No:
$clinic_id = </strong></font></td><td><font size="2">' .
$_POST['clinic_id']; $this->model_home-
$vet_ids = $this- >get_vetlicense($vet_username) .
>model_home- '</font></td></tr><tr><td style="text-
>get_clinic_veterinarians($clinic_id); align:right"><font
size="2"><strong>Specialization:
$result = ""; </strong></font></td><td><font size="2">' .
foreach($vet_ids as $vet_id) $this->model_home-
{ >get_specializations_str($vet_id) .
$vet_username = $this- '</font></td></tr><tr><td style="text-
>model_home- align:right"><font
>get_veterinarian_info($vet_id['vet_id'])['u size="2"><strong>Schedule:
sername']; </strong></font></td><td><font size="2">' .
$vet_profile = $this- $this->model_home-
>model_home->get_profile($vet_username); >get_schedule_str($clinic_id, $vet_id, 0);
$result .= '<option $result .=
value="' . $vet_username . '">' . "</td></tr></table></div>";
$vet_profile['last_name'] . ', ' .
$vet_profile['first_name'] . ' ' . $data['result'] = $result;
$vet_profile['middle_name'] . '</option>'; echo $data['result'];
} }
$result = "<div>";
71
$this->form_validation- }
>set_rules('sched_time', 'time',
'required'); $this->model_home-
>confirm_appointment($appointment_id, 1);
if ($_POST['search_option'] $this->appointments();
== "Clinic") { }
$this-
>form_validation->set_rules('vet_option',
'veterinarian', 'required'); public function appointment_history()
} else { {
$this- if ($this->session-
>form_validation->set_rules('clinic_option', >userdata('isLoggedIn') == FALSE) {
'clinic', 'required'); redirect('/');
} }
$data['history'] = 1;
if ($this->form_validation- $data['appointments'] =
>run() == FALSE) { $this->model_home-
$this- >getAppointments($_SESSION['vet_id'],
>appointment_request(); $data['history']);
} else {
if $this->load-
($_POST['search_option'] == "Clinic") { >view('panels/header');
$clinic_id = $this->load-
$_POST['details']; >view('panels/sidebar');
$vet_username $this->load-
= $_POST['vet_option']; >view('content/view-appointments', $data);
} else { $this->load-
$vet_username >view('panels/footer');
= $_POST['details']; }
$clinic_id =
$_POST['clinic_option'];
} public function
disapprove_appointment()
$pet_id = {
$_POST['pet_option']; if ($this->session-
$vet_id = $this- >userdata('isLoggedIn') == FALSE) {
>model_home->get_vetid($vet_username); redirect('/');
}
$appointment['clinic_id'] = $remarks =
$clinic_id; $_POST['hidden_remarks'];
$appointment['vet_id']
= $vet_id; $appointment_id =
$_POST['schedule_appt_id'];
$appointment['owner_id'] =
$_SESSION['owner_id']; $this->model_home-
$appointment['pet_id'] >confirm_appointment($appointment_id, 2,
= $pet_id; $remarks);
$appointment['date'] $this->appointments();
= $_POST['sched_date']; }
$appointment['time'] }
= $_POST['sched_time'];
$appointment['remarks'] =
$_POST['reason'];
Listing 2: models/model_home.php
$appointment['confirmed'] = 0; <?php
class Model_home extends CI_Model {
$this->model_home-
>add_appointment($appointment); public function __construct()
$this->home(); {
} $this->load->database();
} }
72
************************************* else if
******************************************** ($row['role_id'] == 3) {
****************************************/ $vet_id
= $this->get_vetid($row['username']);
//for login
public function isUser($username, $newdata['vet_id'] = $vet_id;
$password) { }
//`password`='".md5($password)."'"
$query = "SELECT * FROM user else if
WHERE username = :username"; ($row['role_id'] == 4) {
$query_params =
array(':username' => $username); $owner_id = $this-
>get_ownerid($row['username']);
$stmt = $this->db->conn_id-
>prepare($query); $newdata['owner_id'] = $owner_id;
$result = $stmt- }
>execute($query_params);
$this-
//fetching all the rows from >session->set_userdata($newdata);
the query
$row = $stmt->fetch(); return true;
} else {
if ($row) { $newdata =
//if we encrypted the array();
password, we would unencrypt it here, but in if
our case we just ($row['status'] != 1) {
//compare the two
passwords $newdata['error_msg'] = "Clinic
if (($password === account not yet approved or has been
$row['password']) && ($row['status'] == 1)) suspended.";
{ } else {
return
$clinic_id = $this- $row['clinic_owner_id'];
>get_clinicid($clinic_owner_id); }
73
$query = "SELECT public function isEmailUsed($email) {
clinic.clinic_id FROM clinic WHERE $query = "SELECT * FROM user
clinic_owner_id = :clinic_owner_id"; WHERE email = :email";
$query_params = $query_params =
array(':clinic_owner_id' => array(':email' => $email);
$clinic_owner_id);
$stmt = $this->db->conn_id-
$stmt = $this->db->conn_id- >prepare($query);
>prepare($query); $result = $stmt-
$result = $stmt- >execute($query_params);
>execute($query_params);
$row = $stmt->fetch(); //fetching all the rows from
the query
return $row['clinic_id']; $row = $stmt->fetch();
} if ($row) {
return true;
public function get_vetid($username) }
{ return false;
$query = "SELECT }
veterinarian.vet_id FROM veterinarian WHERE
username = :username";
$query_params = public function addUser($userRequest)
array(':username' => $username); {
$query = "INSERT INTO user(
$stmt = $this->db->conn_id- username,
>prepare($query); password,
$result = $stmt- role_id,
>execute($query_params); email,
$row = $stmt->fetch(); last_name,
first_name,
return $row['vet_id']; middle_name,
} contact_no,
status
public function )
get_ownerid($username) { VALUES(
$query = "SELECT :username,
pet_owner.owner_id FROM pet_owner WHERE :password,
username = :username"; :role_id,
$query_params = :email,
array(':username' => $username); :last_name,
:first_name,
$stmt = $this->db->conn_id- :middle_name,
>prepare($query); :contact_no,
$result = $stmt- :status
>execute($query_params); )";
$row = $stmt->fetch();
$query_params = array(
return $row['owner_id']; ':username' =>
} $userRequest['username'],
':password' =>
public function $userRequest['password'],
isUsernameUsed($userName) { ':role_id' =>
$query = "SELECT * FROM user $userRequest['role_id'],
WHERE username = :username"; ':email' =>
$query_params = $userRequest['email'],
array(':username' => $userName); ':last_name' =>
$userRequest['last_name'],
$stmt = $this->db->conn_id- ':first_name' =>
>prepare($query); $userRequest['first_name'],
$result = $stmt- ':middle_name' =>
>execute($query_params); $userRequest['middle_name'],
':contact_no' =>
//fetching all the rows from $userRequest['contact_no'],
the query ':status' =>
$row = $stmt->fetch(); $userRequest['status']
if ($row) { );
return true;
} $stmt = $this->db->conn_id-
return false; >prepare($query);
} $result = $stmt-
>execute($query_params);
74
} $usertype = $stmt->fetch();
return $usertype['role'];
public function }
addClinicRequest($userRequest) {
$query = "INSERT INTO public function
clinic_request( get_profile($username) {
username, $query = "SELECT * FROM user
email, WHERE username=:username";
clinic_name, $query_params =
address, array(':username' => $username);
contact_no,
schedule, $stmt = $this->db->conn_id-
x, >prepare($query);
y $result = $stmt-
) >execute($query_params);
VALUES(
:username, return $stmt->fetch();
:email, }
:clinic_name,
:address, public function
:contact_no, get_vetlicense($username) {
:schedule, $query = "SELECT * FROM
:x, veterinarian WHERE username=:username";
:y $query_params =
)"; array(':username' => $username);
75
$query = "SELECT * FROM $query_params = array(
specialization WHERE spec_id=:spec_id"; ':license_no' =>
$query_params = $license_no,
array(':spec_id' => $spec_id); ':username' =>
$username
$stmt = $this->db->conn_id- );
>prepare($query);
$result = $stmt- $stmt = $this->db->conn_id-
>execute($query_params); >prepare($query);
$result = $stmt-
return $stmt->fetch(); >execute($query_params);
} }
76
}
public function
public function update_activation($clinic_id) {
get_schedule_str($clinic_id, $vet_id , $br) $query = "SELECT
{ clinic.status FROM clinic where clinic_id =
$schedule = ""; :clinic_id";
foreach ($this- $query_params =
>get_veterinarian_schedule($vet_id, array(':clinic_id' => $clinic_id);
$clinic_id) as $row) {
$details = $stmt = $this->db->conn_id-
explode("::", $row['schedule']); >prepare($query);
if ($br) $result = $stmt-
$schedule .= >execute($query_params);
trim ($details[0]) . "<br /> (" . trim
($details[1]) . ")<br />"; $row = $stmt->fetch();
else
$schedule .= $query = "UPDATE clinic SET
trim ($details[0]) . " (" . trim status = ". ($row['status'] == 1 ? 2: 1) . "
($details[1]) . ")"; WHERE clinic.clinic_id = :clinic_id";
} $query_params =
return $schedule; array(':clinic_id' => $clinic_id);
}
$stmt = $this->db->conn_id-
public function >prepare($query);
get_veterinarian_schedule($vet_id, $result = $stmt-
$clinic_id = 0) { >execute($query_params);
if ($clinic_id != 0)
{ $clinic_info = $this-
$query = "SELECT * >get_clinic_info($clinic_id);
FROM clinic_vet WHERE clinic_id=:clinic_id $clinic_owner_username =
AND vet_id=:vet_id"; $this-
$query_params = >get_clinicowner_username($clinic_info['clin
array(':clinic_id' => $clinic_id, ':vet_id' ic_owner_id']);
=> $vet_id);
} else { $query = "UPDATE user SET
$query = "SELECT * status = ". ($row['status'] == 1 ? 2 : 1) .
FROM clinic_vet WHERE vet_id=:vet_id"; " WHERE username = :username";
$query_params = $query_params =
array(':vet_id' => $vet_id); array(':username' =>
} $clinic_owner_username);
$stmt = $this->db->conn_id-
$stmt = $this->db->conn_id- >prepare($query);
>prepare($query); $result = $stmt-
$result = $stmt- >execute($query_params);
>execute($query_params); }
77
$stmt = $this->db->conn_id- {
>prepare($query); $query = "INSERT INTO clinic(
$result = $stmt->execute(); clinic_name,
clinic_owner_id,
return $stmt->fetchAll(); address,
} schedule,
contact_no,
public function email,
approve_clinicrequest($username) x,
{ y,
// update user.status status
$status = 1; )
$this- VALUES(
>updateUserStatus($username, $status); :clinic_name,
// insert clinic owner then :clinic_owner_id,
get clinic_owner_id :address,
$this- :schedule,
>addClinicOwner($username); :contact_no,
$clinic_owner_id = $this- :email,
>get_clinicownerid($username); :x,
// get info from :y,
clinic_request then insert to clinic :status
$clinic = $this- )";
>getClinicInfo($username);
$clinic['clinic_owner_id'] = $query_params = array(
$clinic_owner_id; ':clinic_name' =>
$this->addClinic($clinic); $clinic['clinic_name'],
// delete info from ':clinic_owner_id' =>
clinic_request $clinic['clinic_owner_id'],
$this- ':address' =>
>delete_clinicrequest($username); $clinic['address'],
} ':schedule' =>
$clinic['schedule'],
public function ':contact_no' =>
updateUserStatus($username, $status) $clinic['contact_no'],
{ ':email' =>
$query = "UPDATE user SET $clinic['email'],
status = :status WHERE username = ':x' =>
:username"; $clinic['x'],
':y' =>
$query_params = array( $clinic['y'],
':status' => ':status' =>
$status, 1
':username' => );
$username
); $stmt = $this->db->conn_id-
>prepare($query);
$stmt = $this->db->conn_id- $result = $stmt-
>prepare($query); >execute($query_params);
$result = $stmt- }
>execute($query_params);
} public function
addClinicOwner($username)
public function {
getClinicInfo($username) $query = "INSERT INTO
{ clinic_owner (username) VALUES (:username)";
$query = "SELECT * FROM
clinic_request WHERE username = :username"; $query_params =
$query_params = array(':username' => $username);
array(':username' => $username);
$stmt = $this->db->conn_id-
$stmt = $this->db->conn_id- >prepare($query);
>prepare($query); $result = $stmt-
$result = $stmt- >execute($query_params);
>execute($query_params); }
$row = $stmt->fetch();
public function
return $row; delete_clinicrequest($username)
} {
$query = "DELETE FROM
public function addClinic($clinic) clinic_request WHERE username = :username";
78
$query_params = ':clinic_owner_id' =>
array(':username' => $username); $clinic_owner_id
);
$stmt = $this->db->conn_id-
>prepare($query); $stmt = $this->db->conn_id-
$result = $stmt- >prepare($query);
>execute($query_params); $result = $stmt-
} >execute($query_params);
}
/************************************
******************************************** public function
***************************************** get_clinic_veterinarians($clinic_id) {
* Clinic Owner exclusive $query = "SELECT DISTINCT
methods vet_id FROM clinic_vet WHERE
************************************* clinic_id=:clinic_id";
******************************************** $query_params =
****************************************/ array(':clinic_id' => $clinic_id);
79
$b_username = ':vet_id' =>
'<strong>'.$search_string.'</strong>'; $vet_id,
$b_email = ':schedule' =>
'<strong>'.$search_string.'</strong>'; $sched
$final_username = );
str_ireplace($search_string, $b_username,
$name); $stmt = $this->db->conn_id-
$final_email = >prepare($query);
str_ireplace($search_string, $b_email, $result = $stmt-
$email); >execute($query_params);
}
$vetresult .= '<div
class="show" id = "' . $row['username'] .'" /************************************
align="left"> ********************************************
<img id="img" src="' . *****************************************
base_url("resources/images/default.gif") . * Veterinarian exclusive
'" style="width:50px; height:50px; methods
float:left; margin-right:6px;" /> *************************************
<span class="name" ********************************************
id="test">' . $final_username . ****************************************/
'</span> <br/>' . $final_email . '
<br/>' .
$row['contact_no'] . '<br/> public function
</div>'; get_vet_clinics($vet_id) {
} $query = "SELECT DISTINCT
clinic_id FROM clinic_vet WHERE
return $vetresult; vet_id=:vet_id";
} $query_params =
array(':vet_id' => $vet_id);
public function
addVetDB($userRequest) { $stmt = $this->db->conn_id-
$query = "INSERT INTO >prepare($query);
veterinarian( $result = $stmt-
username, >execute($query_params);
license_no
) return $stmt->fetchAll();
VALUES( }
:username,
:license_no public function
)"; update_vetclinicsched($vet_sched)
{
$query_params = array( $query = "UPDATE clinic_vet
':username' => SET
$userRequest['username'], schedule = :schedule
':license_no' => WHERE
$userRequest['license_no'] clinic_id =
); :clinic_id AND
vet_id = :vet_id";
$stmt = $this->db->conn_id-
>prepare($query); $query_params = array(
$result = $stmt- ':schedule' =>
>execute($query_params); $vet_sched['schedule'],
} ':clinic_id' =>
$vet_sched['clinic_id'],
public function ':vet_id' =>
addClinicVet($clinic_id, $vet_id, $sched) { $vet_sched['vet_id']
$query = "INSERT INTO );
clinic_vet(
clinic_id, $stmt = $this->db->conn_id-
vet_id, >prepare($query);
schedule $result = $stmt-
) >execute($query_params);
VALUES( }
:clinic_id,
:vet_id, public function get_patients($vet_id,
:schedule $clinic_id = 0) {
)"; if ($clinic_id == 0)
{
$query_params = array( $query = "SELECT
':clinic_id' => DISTINCT pet_id FROM consultation_history
$clinic_id, WHERE vet_id=:vet_id";
80
$query_params = public function
array(':vet_id' => $vet_id); get_owner_username($owner_id) {
} else { $query = "SELECT * FROM
$query = "SELECT pet_owner WHERE owner_id=:owner_id";
DISTINCT pet_id FROM consultation_history $query_params =
WHERE vet_id=:vet_id AND clinic_id = array(':owner_id' => $owner_id);
:clinic_id";
$query_params = $stmt = $this->db->conn_id-
array(':vet_id' => $vet_id, ':clinic_id' => >prepare($query);
$clinic_id); $result = $stmt-
} >execute($query_params);
81
':pet_name' => ':complaint'
$petRequest['pet_name'], => $consultation['complaints'],
':specie' => ':diagnosis'
$petRequest['specie'], => $consultation['diagnosis'],
':breed' => ':remarks'
$petRequest['breed'], => $consultation['remarks'],
':birthdate' => ':next_consult_date'
$petRequest['birthdate'], => $consultation['next_consult_date'],
':gender' => ':schedule_appt_id'
$petRequest['gender'], => $consultation['schedule_appt_id']
':registration_no' => );
$petRequest['registry']
); $stmt = $this->db->conn_id-
>prepare($query);
$stmt = $this->db->conn_id- $result = $stmt-
>prepare($query); >execute($query_params);
$result = $stmt-
>execute($query_params); if ($result) {
$query = "SELECT MAX(
if ($result) { consultation_id ) AS max_cons_id FROM
$query = "SELECT MAX( consultation_history";
pet_id ) AS max_id FROM pet"; $stmt = $this->db-
$stmt = $this->db- >conn_id->prepare($query);
>conn_id->prepare($query); $result = $stmt-
$result = $stmt- >execute($query_params);
>execute($query_params); $row = $stmt->fetch();
$row = $stmt->fetch();
if ($result) {
if ($result) { return
return $row['max_cons_id'];
$row['max_id']; }
} }
} return 0;
return 0; }
}
public function
public function addMedication($medication) {
addConsultation($consultation) { $query = "INSERT INTO
$query = "INSERT INTO medication(
consultation_history( pet_id,
pet_id, consultation_id,
vet_id, medicine,
clinic_id, dosage,
consultation_date, med_date
complaint, )
diagnosis, VALUES(
remarks, :pet_id,
next_consult_date, :consultation_id,
schedule_appt_id :medicine,
) :dosage,
VALUES( :med_date
:pet_id, )";
:vet_id,
:clinic_id, $query_params = array(
:consultation_date, ':pet_id'
:complaint, => $medication['pet_id'],
:diagnosis, ':consultation_id'
:remarks, => $medication['consultation_id'],
:next_consult_date, ':medicine'
:schedule_appt_id => $medication['medicine'],
)"; ':dosage'
=> $medication['dosage'],
$query_params = array( ':med_date'
':pet_id' => $medication['med_date']
=> $consultation['pet_id'], );
':vet_id'
=> $consultation['vet_id'], $stmt = $this->db->conn_id-
':clinic_id' >prepare($query);
=> $consultation['clinic_id'], $result = $stmt-
':consultation_date' >execute($query_params);
=> $consultation['consultation_date'], }
82
);
public function
addVaccination($vaccination) { $stmt = $this->db->conn_id-
$query = "INSERT INTO >prepare($query);
vaccination( $result = $stmt-
pet_id, >execute($query_params);
consultation_id, }
vaccine_type,
vaccine_name,
expiration, // history = 0 - veterinarian for
next_due approval of appointments
) // history = 1 - appointments history
VALUES( vet view
:pet_id, // history = 2 - appointment history
:consultation_id, owner view
:vaccine_type, public function getAppointments($id,
:vaccine_name, $history = 0) {
:expiration,
:next_due if ($history == 0)
)"; $query = "SELECT *
FROM schedule_appt WHERE vet_id = :vet_id
$query_params = array( AND date >= DATE(:date) AND confirmed = 0";
':pet_id' else if ($history == 1)
=> $vaccination['pet_id'], $query = "SELECT *
':consultation_id' FROM schedule_appt WHERE vet_id = :vet_id
=> $vaccination['consultation_id'], AND date <= DATE(:date) AND confirmed = 1";
':vaccine_type' else
=> $vaccination['vaccine_type'], $query = "SELECT *
':vaccine_name' FROM schedule_appt WHERE owner_id =
=> $vaccination['vaccine_name'], :owner_id";
':expiration'
=> $vaccination['expiration'], if ($history == 2) {
':next_due' $query_params = array(
=> $vaccination['next_due']
); ':owner_id' => $id
$stmt = $this->db->conn_id-
>prepare($query); );
$result = $stmt- } else {
>execute($query_params); $date = date('Y-m-d');
}
$query_params = array(
public function
addLaboratory($laboratory) { ':vet_id' => $id,
$query = "INSERT INTO
laboratory( ':date' => $date
pet_id,
consultation_id, );
lab_type, }
lab_findings,
lab_date
) $stmt = $this->db->conn_id-
VALUES( >prepare($query);
:pet_id, $result = $stmt-
:consultation_id, >execute($query_params);
:lab_type,
:lab_findings, return $stmt->fetchAll();
:lab_date }
)";
83
$query = "SELECT * FROM pet {
WHERE owner_id=:owner_id"; $today = getdate();
$query_params =
array(':owner_id' => $owner_id); $target = explode("-", $dob);
$query_params = array( }
':pet_name' =>
$petRequest['pet_name'], $age = "";
':specie' => $age .= $years;
$petRequest['specie'], $age .= ($years > 1) ? '
':breed' => years ' : ' year ';
$petRequest['breed'], $age .= $months;
':birthdate' => $age .= ($months > 1) ? '
$petRequest['birthdate'], months ' : ' month ';
':gender' => $age .= $days;
$petRequest['gender'], $age .= ($days > 1) ? ' days
':registration_no' => ' : ' day ';
$petRequest['registry'],
':pet_id' => return $age;
$petRequest['pet_id'] }
);
public function
$stmt = $this->db->conn_id- get_consultation_history($pet_id, $vet_id =
>prepare($query); 0) {
$result = $stmt- if ($vet_id == 0) {
>execute($query_params); $query = "SELECT *
} FROM consultation_history WHERE
pet_id=:pet_id";
public function get_pet_info($pet_id) $query_params =
{ array(':pet_id' => $pet_id);
$query = "SELECT * FROM pet }
WHERE pet_id=:pet_id"; else {
$query_params = $query = "SELECT *
array(':pet_id' => $pet_id); FROM consultation_history WHERE
pet_id=:pet_id AND vet_id=:vet_id";
$stmt = $this->db->conn_id- $query_params =
>prepare($query); array(':pet_id' => $pet_id, ':vet_id' =>
$result = $stmt- $vet_id);
>execute($query_params); }
84
return $stmt->fetchAll(); return $stmt->fetchAll();
} }
85
':clinic_id' => $stmt = $this->db->conn_id-
$appointment['clinic_id'], >prepare($query);
':vet_id' => $result = $stmt-
$appointment['vet_id'], >execute($query_params);
':owner_id' => }
$appointment['owner_id'], }
':pet_id' => ?>
$appointment['pet_id'],
':date' =>
$appointment['date'],
':time' =>
Listing 3: views/home.php
$appointment['time'],
':remarks' => <div class="homepage">
$appointment['remarks'], <h2>Hello <?php echo
':confirmed' => $this->session-
$appointment['confirmed'] >userdata('username');?>!</h2>
); <h3>Welcome to the
echo ($appointment['time']); SpotAVet Website.</h3>
$stmt = $this->db->conn_id- <p>
>prepare($query); SpotAVet is a
$result = $stmt- Web-based system application that provides
>execute($query_params); support for pet owners to get the service
} they need for their pets. With an extension
to Android device that allows user to search
veterinary clinic base on location, the
public function system becomes more flexible.
confirm_appointment($appointment_id, </p>
$confirmed, $remarks = "") { <p>
if ($confirmed === 1) { By using the
$query = "UPDATE Android extension of this application, pet
schedule_appt SET owners, registered or not registered, could
already have the idea on where the clinic
confirmed = :confirmed is, as well as its schedule and its
WHERE veterinarians.
</p>
schedule_appt_id = <p>
:schedule_appt_id"; Please
download the SpotAvet for Android to start
$query_params = array( searching near clinics using your Android
':confirmed' device.
=> $confirmed, </p>
</div>
':schedule_appt_id' =>
$appointment_id
); Listing 4: views/login.php
} else {
86
.placepicker-map {
<td><input type="password" width: 100%;
name="password" id="password" height: 300px;
placeholder="Password" class="text_box" }
style="width:300px; height:25px;"/></td>
</tr> .field_label {
<tr> width: 200px;
<td height: 30px;
class="txt_fields"> </td> }
<td> .field_text {
width: 700px;
<div class="error" style="width: height: 30px;
310px; display:<?php echo $status == "" ? }
"none" : "block"; ?>" > </style>
87
<input </td>
name="password" value="<?php echo </tr>
set_value('password'); ?>" type="password" <tr>
class="txt_fields txt_width" id="password" <td
placeholder="Password"/> class="field_label">*Middle Name:</td>
<?php echo <td
form_error('password', '<div class="field_text">
class="error">', '</div>'); ?> <input
</td> name="middle_name" value="<?php echo
set_value('middle_name'); ?>" type="text"
class="txt_fields txt_width"
</tr> id="middle_name" placeholder="Middle Name"/>
<tr> <?php echo
<td form_error('middle_name', '<div
class="field_label">*Confirm Password:</td> class="error">', '</div>'); ?>
<td </td>
class="field_text"> </tr>
<input <tr>
name="confirm_password" value="<?php echo <td
set_value('confirm_password'); ?>" class="field_label">*Contact #:</td>
type="password" class="txt_fields txt_width" <td
id="confirm_password" placeholder="Confirm class="field_text">
Password"/> <input
<?php echo name="contact_no" value="<?php echo
form_error('confirm_password', '<div set_value('contact_no'); ?>" type="text"
class="error">', '</div>'); ?> class="txt_fields txt_width" id="contact_no"
</td> placeholder="Contact"/>
</tr> <?php echo
<tr> form_error('contact_no', '<div
<td class="error">', '</div>'); ?>
class="field_label">*Email:</td> </td>
<td </tr>
class="field_text"> </table>
<input </fieldset>
name="email" value="<?php echo
set_value('email'); ?>" type="text" <fieldset>
class="txt_fields txt_width" id="email" <legend>Clinic
placeholder="Email"/> Information</legend>
<?php echo <table width="800"
form_error('email', '<div class="error">', border="0">
'</div>'); ?> <tr>
</td> <td
</tr> class="field_label">*Clinic Name:</td>
<tr> <td
<td class="field_text">
class="field_label">*Last Name:</td> <input
<td name="clinic_name" value="<?php echo
class="field_text"> set_value('clinic_name'); ?>" type="text"
<input class="txt_fields txt_width"
name="last_name" value="<?php echo id="clinic_name" placeholder="Clinic Name"/>
set_value('last_name'); ?>" type="text" <?php echo
class="txt_fields txt_width" id="last_name" form_error('clinic_name', '<div
placeholder="Last Name"/> class="error">', '</div>'); ?>
<?php echo </td>
form_error('last_name', '<div </tr>
class="error">', '</div>'); ?> <tr>
</td> <td
</tr> class="field_label">*Clinic Address:</td>
<tr> <td
<td class="field_text">
class="field_label">*First Name:</td> <input
<td name="clinic_addr" value="<?php echo
class="field_text"> set_value('clinic_addr'); ?>" type="text"
<input class="txt_fields txt_width"
name="first_name" value="<?php echo id="clinic_addr" placeholder="Clinic
set_value('first_name'); ?>" type="text" Address"/>
class="txt_fields txt_width" id="first_name" <?php echo
placeholder="First Name"/> form_error('clinic_addr', '<div
<?php echo class="error">', '</div>'); ?>
form_error('first_name', '<div </td>
class="error">', '</div>'); ?> </tr>
88
<tr>
<td <?php
class="field_label">*Operating Hours:</td> $this->load->helper('url');
<td ?>
class="field_text">
<input <head>
name="clinic_hours" value="<?php echo <meta http-equiv="Content-
set_value('clinic_hours'); ?>" type="text" Type" content="text/html; charset=utf-8" />
class="txt_fields txt_width" <script
id="clinic_hours" placeholder="(Mon ~ Fri :: type="text/javascript" src="<?php echo
8:00 AM ~ 5:00 PM)"/> base_url("resources/js/jquery-
<?php echo 1.11.3.min.js");?>"></script>
form_error('clinic_hours', '<div <script
class="error">', '</div>'); ?> type="text/javascript"
</td> src="https://maps.googleapis.com/maps/api/js
</tr> ?sensor=true&libraries=places®ion=PH&v=3"
</table> ></script>
</fieldset> <script
type="text/javascript" src="<?php echo
<br /><br /> base_url("resources/js/jquery.placepicker.js
<fieldset> ");?>"></script>
<legend>Clinic Location
Details</legend> <link rel="stylesheet"
<div type="text/css" href="<?php echo
class="col-md-6"> base_url("resources/css/style.css");?>"
*<input media="screen"/>
name="placepicker" id="placepicker"
class="placepicker" data-map-container- <title><?php
id="collapseOne" value = "<?php echo if(isSet($title)) { echo $title; } else {
set_value('placepicker'); ?>" /> echo "SpotAVet"; } ?></title>
<div </head>
id="collapseOne" class="collapse"> <body>
89
base_url("index.php/main/view_profile") .
"\""; ?>>My Profile</a></li>
Listing 7: panels/sidebar-profile.php
<li><a
href=<?php echo "\"" . <div class="inner
base_url("index.php/main/view_clinic") . "/" user_design_l" id="left_content"
. $this->session- style="width:250px; background:#E5EEFE; ">
>userdata('clinic_owner_id') . "\""; ?>>My <h3>PROFILE</h3>
Clinic</a></li> <p><img src=" <?=
<li><a href=<?php echo "\"" base_url("resources/images/default.gif") ?>
. " width="200" height="250" /></p>
base_url("index.php/main/view_veterinarians" <hr>
) . "\""; ?>>My Veterinarians</a></li> </div>
<?php } else if
($this->session->userdata('user_role') == 3) Listing 8: panels/sidebar-clinic.php
{ ?>
<li><a
href=<?php echo "\"" . <div class="inner
base_url("index.php/main/view_profile") . user_design_l" id="left_content"
"\""; ?>>My Profile</a></li> style="width:250px; background:#E5EEFE; ">
<li><a href=<?php echo "\"" <h3>LOCATION MAP</h3>
. base_url("index.php/main/view_clinics") .
"\""; ?>>My Clinics</a></li> <div id="map-canvas"
<li><a href=<?php echo "\"" style="width:250px;height:200px;"></div>
. base_url("index.php/main/view_patients") . <hr>
"\""; ?>>My Patients</a></li> </div>
<li><a
href=<?php echo "\"" . <script>
base_url("index.php/main/appointments") . var map;
"\""; ?>>My Appointments</a></li> function initialize() {
var myLatlng = new
<?php } else if google.maps.LatLng(<?= $clinic['x']?>, <?=
($this->session->userdata('user_role') == 4) $clinic['y']?>);
{ ?> var mapOptions = {
<li><a href=<?php echo "\"" zoom: 14,
. base_url("index.php/main/view_profile") . center: myLatlng,
"\""; ?>>My Profile</a></li> disableDefaultUI: true
<li><a href=<?php echo "\"" };
. base_url("index.php/main/view_pets") . map = new
"\""; ?>>My Pets</a></li> google.maps.Map(document.getElementById('map
<li><a -canvas'),
href=<?php echo "\"" . mapOptions);
base_url("index.php/main/appointments") .
"\""; ?>>Appointments</a></li> var marker = new
<?php } ?> google.maps.Marker({
<?php if($this- position: myLatlng,
>session->userdata('isLoggedIn') == TRUE) { map: map,
?> title: 'Hello World!'
});
<li><a href=<?php echo "\"" . }
base_url("index.php/main/logout") . "\"";
?>>Log out</a></li> google.maps.event.addDomListener(wind
<?php } ?> ow, 'load', initialize);
</ul>
<?php if($this- </script>
>session->userdata('isLoggedIn') == TRUE) :
?> <style>
<div #map-canvas {
style="position:absolute; top:0; right:0;"> height: 100%;
You are margin: 0px;
currently logged in as <strong><?php echo padding: 0px
$this->model_home- }
>get_usertype();?></strong>| </style>
</div>
<?php endif; ?>
</div> Listing 9: panels/sidebar-pet.php
</div>
90
<h3>PET</h3>
<p><img src=" <?php <?php echo
//base_url("resources/images/paw.png") ?> " form_error('search_option', '<div
width="180" height="220" /></p> class="error">', '</div>'); ?>
<hr>
</div>
<div id="search_result"></div>
Listing 10: panels/footer.php <?php echo form_error('search', '<div
class="error">', '</div>'); ?>
</div> </div>
<div id="clear"></div>
<div id="footer"> </div>
<div> </fieldset>
<p> <br> </br>
<fieldset>
cjgaleng © 2015 | All rights <table>
reserved. <tr>
</p>
</div> <td> </td>
</div> </tr>
</body> <tr>
</html> <td
class="vet" style="width:120px; text-
align:right">
Listing 11: content/add-appointment.php <label><font size="2">VETERINARIAN:
</font></label>
<div id="right_content" </td>
class="right_design border" <td
style="width:700px;"> colspan="5" class="vet">
<?php
echo <select name="vet_option"
form_open('main/add_appointment'); id="vet_option" class="vet_option"
style="height:30px; width:475px">
date_default_timezone_set("Asia/Kuala
_Lumpur"); <!-- for loop -->
?>
<h3> APPOINTMENT </select><em>*</em>
REQUEST </h3>
<div id="clear"></div> <?php echo form_error('vet_option',
<fieldset> '<div class="error">', '</div>'); ?>
</td>
<input <td
type="hidden" name="details" id="details" class="clinic" style="display: none; text-
value="<?= set_value('details') ?>"/> align:right">
<div
id="search_field"> <label><font size="2">CLINIC NAME:
<div </font></label>
class="content_search"> </td>
<td
<input type="text" name="search" colspan="5" class="clinic" style="display:
class="search" id="search" none">
placeholder="Enter name to begin search."
value="<?= set_value('search') ?>" <select name="clinic_option"
autocomplete="off"/> id="clinic_option" class="clinic_option"
style="height:30px; width:475px">
<select name="search_option" <!--for loop clinic -->
id="search_option" class="search_option">
</select><em>*</em>
<option value ="Clinic" <?php echo
set_select('search_option', 'Clinic', TRUE); <?php echo
?>>Clinic</option> form_error('clinic_option', '<div
class="error">', '</div>'); ?>
<option value ="Veterinarian" <?php </td>
echo set_select('search_option', </tr>
'Veterinarian'); ?> >Veterinarian</option> <tr>
</select><em>*</em> <td> </td>
91
<td date('H:i:s')); ?>" style="height:30px;
colspan="5"> width:120px"><em>*</em>
</select><em>*</em> <table>
<tr>
<?php echo form_error('pet_option',
'<div class="error">', '</div>'); ?> <td><input type="submit"
</td> name="button" id="button" value="Submit
<td Request" class="search_button"
style="text-align:right"> style="width:120px; height:40px;"
/> </td>
<label><font size="2">DATE: </tr>
</font></label> </table>
</td> </div>
<td>
<script language="Javascript">
92
data:
dataString, $('.vet').show();
cache:
false, $('.clinic').hide();
jQuery("#search_result").fadeOut(); .trigger('change');
} }
});
$('#details').on('change',
function() {
$('#search').click(function(){
if ($( "#search_option
jQuery("#search_result").fadeIn(); option:selected" ).text() == "Clinic") {
}); var clinic_id
= $('#details').val();
$.ajax({
$('#search_option').on('change', type:
function() { "POST",
if (this.value == url:
"Veterinarian") { <?php echo "\"" .
base_url("index.php/main/getVetList") .
$('.vet').hide(); "\""; ?>,
data: {
$('.clinic').show(); clinic_id: clinic_id },
cache:
$(".clinic_option") false,
93
.end() .find('div')
.append(html) .remove()
.trigger('change') .end()
; .append(html)
} ;
}); }
} else { });
var });
vet_username = $('#details').val();
$.ajax({
type: $('.clinic_option').on('change',
"POST", function() {
url: var clinic_id =
<?php echo "\"" . $('.clinic_option').val();
base_url("index.php/main/getClinicList") . var vet_username =
"\""; ?>, $("#details").val();
data: {
vet_username: vet_username }, $.ajax({
cache: type: "POST",
false, url: <?php
echo "\"" .
success: function(html) base_url("index.php/main/getClinicDetails")
{ . "\""; ?>,
data: {
$(".clinic_option") vet_username: vet_username,
94
function check_date() { user_temp =
var usrdate = usrtime.split(":");
$('#sched_date').val(); var user_hr =
var user_temp = new user_temp[0];
Array(); var user_min =
user_temp[1];
user_temp = var user_ss =
usrdate.split("-"); user_temp[2];
var user_year =
user_temp[0]; var curtime = "<?php
var user_month = echo date('H:i:s') ?>";
user_temp[1]; var cur_temp = new
var user_day = Array();
user_temp[2]; cur_temp =
curtime.split(":");
var curdate = "<?php var cur_hr =
echo date('Y-m-d') ?>"; cur_temp[0];
var cur_temp = new var cur_min =
Array(); cur_temp[1];
cur_temp = var cur_ss =
curdate.split("-"); cur_temp[2];
var cur_year =
cur_temp[0]; if (cur_hr + 1 <=
var cur_month = user_hr) {
cur_temp[1]; return true;
var cur_day = }
cur_temp[2]; else if (cur_hr + 1 ==
user_hr) {
if (user_year > if (cur_min +
cur_year) { 1 <= user_min) {
return true; return true;
} else { }
if (user_month return false;
> cur_month) { }
if }
(user_year == cur_year) { });
</script>
return true;
} else <style type="text/css">
{ .content_search{
width: 600px;
return false; margin: 0 auto;
} }
} else { #search
if {
(user_day > cur_day) { width:420px;
border:solid 1px #000;
if ((user_month >= cur_month) && padding:10px;
(user_year >= cur_year)){ font-size:14px;
}
return true;
#search_option
} else { {
width:130px;
return false; border:solid 1px #000;
padding:10px;
} font-size:14px;
} }
}
} #search_result
return false; {
} position:absolute;
width:420px;
function check_time() { max-height:300px;
var usrtime = padding:10px;
$('#sched_time').val(); display:none;
var user_temp = new margin-top:-1px;
Array(); border-top:0px;
overflow-y:auto;
border:1px #CCC solid;
background-color: white;
95
}
.show <td>Register As:</td>
{
padding:10px; <td>
border-bottom:1px #999 dashed;
font-size:15px; <select name="role"
height:50px; class="txt_fields txt_width"
} style="height:30px; width:408px;" id="role"
.show:hover disabled>
{
background:#4c66a4; <option
color:#FFF; value="clinic">Pet Owner</option>
cursor:pointer;
} </select>
em {
color: rgb(255,0,0); </td>
}
</style> </tr>
<tr>
Listing 12: content/add-patient.php <td width="129">*Username:</td>
<tr> </tr>
96
set_value('contact_no') ?>"
<tr> class="txt_fields" />
</td> <h3>Pet
Information</h3>
</tr> <table
width="611" border="0">
<tr>
<tr>
<td>*Last Name:</td>
<td width="129">*Pet Name: </td>
<td><input type="text"
name="last_name" id="last_name" value="<?= <td>
set_value('last_name') ?>"
class="txt_fields" /> <input type="text"
name="pet_name" id="pet_name" value="<?=
<?php echo form_error('last_name', set_value('pet_name') ?>" class="txt_fields"
'<div class="error">', '</div>'); ?> />
<tr> </td>
97
<br> </br>
<tr> <fieldset>
<table>
<td>*Birth Date: </td> <tr>
<td
<td><input type="date" class="clinic" style="text-align:right">
name="birthday" id="birthday" value="<?=
set_value('birthday') ?>" class="txt_fields" <label><em>*</em>Clinic: </label>
/> </td>
<td
<?php echo class="clinic">
form_error('birthday', '<div
class="error">', '</div>'); ?> <select name="clinic_option"
id="clinic_option" class="clinic_option"
</td> style="height:30px; width:495px">
98
<td>*Chief Complaints: </td> </td>
<td> </tr>
<td> <tr>
<tr> </td>
<td> <tr>
<tr> </td>
<td> <tr>
99
name="expiration_date" id="expiration_date"
<?php echo value="<?= set_value('expiration_date') ?>"
form_error('medication_date', '<div class="txt_fields" />
class="error">', '</div>'); ?>
<?php echo
</td> form_error('expiration_date', '<div
class="error">', '</div>'); ?>
</tr>
</td>
</table>
</fieldset> </tr>
</div>
<tr>
<div id="vaccination"
style="display: none"> <td>*Next Vaccination Date: </td>
<br> </br>
<input <td>
type="hidden" name="hidden_vaccination"
id="hidden_vaccination" value="<?= <input type="date"
set_value('hidden_vaccination', 0) ?>"/> name="next_vaccine_date"
<fieldset> id="next_vaccine_date" value="<?=
set_value('next_vaccine_date') ?>"
<legend>Vaccination Details</legend> class="txt_fields" />
<table
width="611" border="0"> <?php echo
form_error('next_vaccine_date', '<div
<tr> class="error">', '</div>'); ?>
<td> </tr>
<td> <tr>
100
<td>*Findings: </td> <script language="Javascript">
<td> $(document).ready(function() {
if($('#r1').is(':checked')) {
<input type="text"
name="lab_findings" id="lab_findings" document.getElementById("B").style.di
value="<?= set_value('lab_findings') ?>" splay="none";
class="txt_fields" />
document.getElementById("A").style.di
<?php echo splay="block";
form_error('lab_findings', '<div } else {
class="error">', '</div>'); ?>
document.getElementById("A").style.di
</td> splay="none";
</tr> document.getElementById("B").style.di
splay="block";
<tr> }
if
<td>*Laboratory Date: </td> ($('#hidden_medication').val() == 1) {
<td> document.getElementById("medication")
.style.display="block";
<input type="date" } else {
name="lab_date" id="lab_date" value="<?=
set_value('lab_date') ?>" class="txt_fields" document.getElementById("medication")
/> .style.display="none";
}
<?php echo
form_error('lab_date', '<div if
class="error">', '</div>'); ?> ($('#hidden_laboratory').val() == 1) {
</td> document.getElementById("laboratory")
.style.display="block";
</tr> } else {
</table> document.getElementById("laboratory")
</fieldset> .style.display="none";
</div> }
<table> if
<tr> ($('#hidden_vaccination').val() == 1) {
<td
width="120px"> </td> document.getElementById("vaccination"
).style.display="block";
<td><input type="button" } else {
name="button" id="med"
onclick="toggle_visibility('medication');" document.getElementById("vaccination"
value="Medication" class="search_button" ).style.display="none";
style="height:40px;" /> </td> }
});
<td><input type="button"
name="button" id="med" function toggle_visibility(id) {
onclick="toggle_visibility('vaccination');" var e = document.getElementById(id);
value="Vaccination" class="search_button" if(e.style.display == 'block') {
style="height:40px;" /> </td> e.style.display = 'none';
$("#hidden_" + id).val(0);
<td><input type="button" } else {
name="button" id="button" e.style.display = 'block';
onclick="toggle_visibility('laboratory');" $("#hidden_" + id).val(1);
value="Laboratory" class="search_button" }
style="height:40px;" /> </td> }
101
document.getElementById("B").style.di $("#hidden_info").val(this.id);
splay="block"; });
$("#hidden_info").val(''); $(document).on("click",
} function(e) {
} var $clicked =
$(e.target);
function hideB(x) if (!
{ $clicked.hasClass("searchpatient")){
if (x.checked)
{ jQuery("#result_searchpatient").fadeO
ut();
document.getElementById("B").style.di }
splay="none"; });
document.getElementById("A").style.di
splay="block"; $('#searchpatient').click(function(){
$("#hidden_info").val(''); jQuery("#result_searchpatient").fadeI
} n();
} });
});
$(function(){ </script>
$('#searchpatient').val(decoded);
});
Listing 13: content/add-pet.php
$(document).on("click",
".show", function(e) {
102
<div id="right_content"
class="right_design border" <select name="gender" id="gender"
style="width:700px;"> class="txt_fields" style="height:30px;
<h3>Pet width:408px;" >
Information</h3>
<?php <option value ="" <?php echo
echo set_select('gender', '', TRUE); ?>></option>
form_open('main/add_newpet');
?> <option value ="Male" <?php echo
<table width="701" set_select('gender', 'Male');
border="0" style="font-family:Arial, ?>>Male</option>
Helvetica, sans-serif; font-size:16px;">
<tr> <option value ="Female" <?php echo
set_select('gender', 'Female'); ?>
<td>*Name:</td> >Female</option>
<td>
</select>
<input type="text" name="pet_name"
id="pet_name" value="<?= <?php echo form_error('gender', '<div
set_value('pet_name') ?>" class="txt_fields" class="error">', '</div>'); ?>
/> </td>
</tr>
<?php echo form_error('pet_name', <tr>
'<div class="error">', '</div>'); ?> <td
</td> width="128">Registration No.:</td>
</tr> <td
<tr> width="563">
103
<input id="r2"
type="radio" onchange="hideA(this)" <td>*Password:</td>
name="aorb" value="2" <?php echo
set_radio('aorb', '2'); ?> > Add new <td><input type="password"
veterinarian account name="password" id="password" value="<?=
<input set_value('password') ?>" class="txt_fields"
type="hidden" name="hidden_username" />
id="hidden_username" value="<?=
set_value('hidden_username') ?>"/> <?php echo form_error('password',
<div id="A"> '<div class="error">', '</div>'); ?>
<div
class="content_searchvet"> </td>
<tr> </tr>
104
set_value('first_name') ?>"
class="txt_fields" /> <tr>
<tr> </td>
105
base_url("index.php/main/search_vets") .
document.getElementById("B").style.di "\""; ?>,
splay="none"; data:
dataString,
document.getElementById("A").style.di cache:
splay="block"; false,
} else {
success: function(html)
document.getElementById("A").style.di {
splay="none";
$("#result_searchvet").html(html).sho
document.getElementById("B").style.di w();
splay="block"; }
});
document.getElementById("C").style.di } return false;
splay="block"; });
}
}); $(document).on("click",
"#result_searchvet", function(e){
function hideA(x) var $clicked =
{ $(e.target);
if (x.checked) var $name =
{ $clicked.find('.name').html();
var decoded =
document.getElementById("A").style.di $("<div/>").html($name).text();
splay="none";
$('#searchvet').val(decoded);
document.getElementById("B").style.di });
splay="block";
$(document).on("click",
document.getElementById("C").style.di ".show", function(e) {
splay="block";
$("#hidden_username").val(this.id);
$("#hidden_username").val(""); });
} $(document).on("click",
} function(e) {
var $clicked =
function hideB(x) $(e.target);
{ if (!
if (x.checked) $clicked.hasClass("searchvet")){
{
jQuery("#result_searchvet").fadeOut()
document.getElementById("C").style.di ;
splay="none"; }
});
document.getElementById("B").style.di
splay="none";
$('#searchvet').click(function(){
document.getElementById("A").style.di
splay="block"; jQuery("#result_searchvet").fadeIn();
});
$("#hidden_username").val(""); });
} </script>
}
<style type="text/css">
$(function(){ .content_searchvet{
width:611px;
$(".searchvet").keyup(function() margin:0 auto;
{ }
var searchid = #searchvet
$(this).val(); {
var dataString = width:500px;
'searchvet='+ searchid; border:solid 1px #000;
if(searchid!='') padding:10px;
{ font-size:14px;
$.ajax({ }
type: #result_searchvet
"POST", {
url: position:absolute;
<?php echo "\"" . width:500px;
106
max-height:300px; }
padding:10px;
display:none; </style>
margin-top:-1px;
border-top:0px; <div id="right_content"
overflow-y:auto; class="border" style="width:700px;">
border:1px #CCC solid; <h3>Clinic
background-color: white; Information</h3>
} <div class="pet_info">
.show <?php
{ echo
padding:10px; form_open('main/editting_clinic'); ?>
border-bottom:1px #999 dashed; <table
font-size:15px; width="611" border="0">
height:50px; <tr>
}
.show:hover <td width="129">Clinic Name:</td>
{
background:#4c66a4; <td>
color:#FFF;
cursor:pointer; <input type="text" name="clinic_name"
} id="clinic_name" value="<?=
</style> set_value('clinic_name',
$clinic['clinic_name']) ?>"
class="txt_fields" />
Listing 15: content/edit-clinic.php <?php echo form_error('clinic_name',
'<div class="error">', '</div>'); ?>
<script>
</td>
$(document).ready(function() { </tr>
<tr>
// Basic usage
<td>Location:</td>
$(".placepicker").each(function() {
<td><input type="text"
var placepicker = name="clinic_loc" id="clinic_loc" value="<?=
$(this).placepicker({ set_value('clinic_loc', $clinic['address'])
latitude: ?>" class="txt_fields" />
document.getElementById('lat').value,
longitude : <?php echo form_error('clinic_loc',
document.getElementById('lng').value, '<div class="error">', '</div>'); ?>
placeChanged: </td>
function(place) { </tr>
var <tr>
location = this.getLocation();
<td>Contact No:</td>
document.getElementById('lat').value
= location['latitude'] ; <td><input type="text"
name="contact_no" id="contact_no" value="<?=
document.getElementById('lng').value set_value('contact_no',
= location['longitude'] ; $clinic['contact_no']) ?>"
class="txt_fields" />
console.log("place changed: ",
place.formatted_address, <?php echo form_error('contact_no',
this.getLocation()); '<div class="error">', '</div>'); ?>
} </td>
</tr>
}).data('placepicker'); <tr>
});
<td>Email Address:</td>
}); // END document.ready
<td><input type="text"
</script> name="clinic_email" id="clinic_email"
<style> value="<?= set_value('clinic_email',
$clinic['email']) ?>" class="txt_fields" />
.placepicker-map {
width: 100%; <?php echo form_error('clinic_email',
height: 300px; '<div class="error">', '</div>'); ?>
107
echo
</td> form_open('main/updatepet/');
</tr> ?>
<tr> <input type="hidden"
name="pet_id" id="pet_id" value="<?=
<td>Operating Hours:</td> set_value('pet_id', $pet['pet_id']) ?>"/>
<table width="701"
<td><input type="text" border="0" style="font-family:Arial,
name="clinic_hours" id="clinic_hours" Helvetica, sans-serif; font-size:16px;">
value="<?= set_value('clinic_hours', <tr>
$clinic['schedule']) ?>" class="txt_fields"
/> <td>*Name:</td>
<td>
<?php echo form_error('clinic_hours',
'<div class="error">', '</div>'); ?> <input type="text" name="pet_name"
id="pet_name" value="<?=
</td> set_value('pet_name', $pet['pet_name']) ?>"
</tr> class="txt_fields" />
</table>
<?php echo form_error('pet_name',
<br /><br /> '<div class="error">', '</div>'); ?>
<fieldset> </td>
</tr>
<legend>Location details</legend> <tr>
<div
class="col-md-6"> <td>*Specie:</td>
<td>
*<input name="placepicker"
id="placepicker" class="placepicker" data- <input type="text" name="specie"
map-container-id="collapseOne" value = id="specie" value="<?= set_value('specie',
"<?php echo set_value('placepicker'); ?>" /> $pet['specie']) ?>" class="txt_fields" />
108
<td
<option value ="" <?php echo width="563">
set_select('gender', ''); ?>></option> <input
type="text" name="username" id="username"
<option value ="Male" <?php value="<?= $profile['username'] ?>"
if($pet['gender'] == "Male") echo class="txt_fields" readonly />
"selected"; ?> <?php echo <?php
set_select('gender', 'Male'); echo form_error('username', '<div
?>>Male</option> class="error">', '</div>'); ?>
</td>
<option value ="Female" <?php </tr>
if($pet['gender'] == "Female") echo <tr>
"selected"; ?> <?php echo
set_select('gender', 'Female'); ?> <td>*Password:</td>
>Female</option>
<td><input type="password"
</select> name="password" id="password" value="<?=
set_value('password', $profile['password'])
<?php echo form_error('gender', '<div ?>" class="txt_fields"/>
class="error">', '</div>'); ?> <?php
</td> echo form_error('password', '<div
</tr> class="error">', '</div>'); ?>
<tr> </td>
<td </tr>
width="128">Registration No.:</td> <tr>
<td
width="563"> <td>*Confirm Password:</td>
109
set_value('first_name',
$profile['first_name']) ?>" <?php $checked = 0; foreach
class="txt_fields" /> ($vet_special as $vet) : ?>
<?php
echo form_error('first_name', '<div <?php $checked =
class="error">', '</div>'); ?> $vet['spec_id'] == $specialize['spec_id'] ?
</td> 1 : 0; ?>
</tr>
<tr> <?php if ($checked == 1) : ?>
<td>*Contact No.:</td>
110
>get_clinic_info($clinic_id)['clinic_name'] </strong><?php echo $clinic['clinic_name'];
?>" :</h3> ?></li>
<table width="701"
border="0" style="font-family:Arial, <li><strong>Location: </strong> <?php
Helvetica, sans-serif; font-size:16px;"> echo $clinic['address']; ?></li>
<tr>
<li><strong>Telephone: </strong><?php
<td>Current Schedule:</td> echo $clinic['contact_no']; ?></li>
<td>
<li><strong>Email: </strong><?php
<label class="sched"> echo $clinic['email']; ?></li>
111
<th <div id="clear"><br
width="60" style="border: #C0C0C0 1px solid; /></div>
text-align: center;"><strong></strong></th> <fieldset>
</tr> <table>
<?php foreach <tr>
($clinicsList as $clinic) : ?> <td
<tr> class="clinic" style="text-align:right">
<td
style="border: #C0C0C0 1px solid;"> <?php <label><em>*</em>Clinic: </label>
</td>
$clinic = $this->model_home- <td
>get_clinic_info($clinic['clinic_id']); class="clinic">
</table> $('.clinic_option').on('change',
</div> function() {
var clinic_id =
$('.clinic_option').val();
Listing 21: content/my-patients.php $.ajax({
type: "POST",
<div id="right_content" url: <?php echo "\"" .
class="right_design border" base_url("index.php/main/get_patient_list")
style="width:700px;"> . "\""; ?>,
<a href=<?php echo data: { clinic_id:
"\"" . clinic_id },
base_url("index.php/main/add_patient") . cache: false,
"\""; ?> class="search_button" success:
style="font- function(html)
family:Arial, Helvetica, sans- {
serif;padding:5px; text-
decoration:none;margin-bottom:10px;">Add $("div.patient")
Patient Record</a>
.find('div')
112
size:14px;color:#333; border:#69C 1px solid;
.remove() padding:8px;">Consultation History</h3>
.end()
<table width="710"
.append(html) border="0" style="font-family: Arial,
; Helvetica, sans-serif; font-size:14px;">
}
}); <tr>
}); <th
</script> width="189" style="border: #C0C0C0 1px
solid;"><strong>Date</strong></th>
<th
width="189" style="border: #C0C0C0 1px
Listing 22: content/my-pet.php solid;"><strong>Diagnosis</strong></th>
<th
width="189" style="border: #C0C0C0 1px
<div id="right_content" solid;"><strong>Remarks</strong></th>
class="inner user_design_r" <th
style="width:700px;" > width="80" style="border: #C0C0C0 1px
<h3 solid;"><strong></strong></th>
style="background:#6CF; font- </tr>
size:14px;color:#333; border:#69C 1px solid; <?php foreach
padding:8px;">Pet Information</h3> ($consultationList as $consultation) :
<div class="pet_info"> ?>
<tr>
<li><strong>Pet Name:</strong><?php <td
echo $pet['pet_name']; ?></li> style="border: #C0C0C0 1px solid;"> <?=
$consultation['consultation_date'] ?> </td>
<li><strong>Registration <td
No.:</strong> <?php echo style="border: #C0C0C0 1px solid;"> <?=
$pet['registration_no'] != '' ? $consultation['diagnosis'] ?> </td>
$pet['registration_no'] : '< Not registered <td
>'; ?></li> style="border: #C0C0C0 1px solid;"> <?=
$consultation['remarks'] == "" ? "< No
<li><strong>Specie: </strong><?php remarks >" : $consultation['remarks'] ?>
echo $pet['specie']; ?></li> </td>
<td
<li><strong>Breed: </strong><?php style="border: #C0C0C0 1px solid;">
echo $pet['breed']; ?></li>
<a href = <?php echo "\"" .
<li><strong>Birth date: base_url("index.php/main/view_consultation")
</strong><?php echo $pet['birthdate']; . "/" . $consultation['consultation_id'] .
?></li> "\""; ?> >
<hr> </td>
<?php </tr>
if($_SESSION['user_role'] == 4) : ?>
<br> </br> <?php endforeach; ?>
<a href=<?php
echo "\"" . </table>
base_url("index.php/main/edit_pet") . "/" . <?php endif; ?>
$pet_id . "\""; ?> " class="search_button" <div id="clear"
style="padding:10px; text-decoration:none; style="padding-bottom:10px;"></div>
height:40px;">Edit Pet Info</a> <a href="<?php
<?php endif; echo base_url("index.php/main/"); ?>"
?> class="search_button" style="padding:10px;
<br> </br> text-decoration:none;
</div> background:#F93;">Back</a>
<?php if </div>
(array_filter($consultationList)) : ?>
<div id="clear"><br
/></div>
<h3
style="background:#6CF; font-
113
Listing 23: content/my-pets.php <li><strong>Email Address:</strong>
<?php echo $profile['email']; ?></li>
<div id="right_content"
class="right_design border" <li><strong>Last Name: </strong><?php
style="width:700px;"> echo $profile['last_name']; ?></li>
<?php foreach ($petsList as
$pet) : ?> <li><strong>First Name:
</strong><?php echo $profile['first_name'];
<div id="admin_box" ?></li>
style = "display:inline-block; width:180px;
height:100px"> <li><strong>Middle Name:
<table> </strong><?php echo $profile['middle_name'];
<tr> ?></li>
</div>
Listing 25: content/my-vet.php
Listing 24: content/my-profile.php <div id="right_content"
class="inner user_design_r"
<div id="right_content" style="width:650px;" >
class="inner user_design_r" <h3
style="width:650px;" > style="background:#6CF; font-
<h3 size:14px;color:#333; border:#69C 1px solid;
style="background:#6CF; font- padding:8px;">My Veterinarian
size:14px;color:#333; border:#69C 1px solid; Information</h3>
padding:8px;">User Information</h3> <div class="pet_info">
<div class="pet_info">
<li><strong>Username: </strong><?php
<li><strong>Username:</strong><?php echo $profile['username']; ?></li>
echo $profile['username']; ?></li>
<li><strong>Email Address: </strong>
<?php echo $profile['email']; ?></li>
114
<th
<li><strong>Last Name: </strong><?php width="200" style="border: #C0C0C0 1px
echo $profile['last_name']; ?></li> solid;"> <strong>Schedule</strong></th>
<th
<li><strong>First Name: width="20" style="border: #C0C0C0 1px solid;
</strong><?php echo $profile['first_name']; text-align: center;"><strong></strong></th>
?></li> </tr>
<?php foreach
<li><strong>Middle Name: ($vetsList as $vet) : ?>
</strong><?php echo $profile['middle_name']; <tr>
?></li> <td
style="border: #C0C0C0 1px solid;"> <?php
<li><strong>Contact No.:
</strong><?php echo $profile['contact_no']; $username = $this->model_home-
?></li> >get_veterinarian_info($vet['vet_id'])['user
name'];
<li><strong>License No:
</strong><?php echo $vet_info['license_no']; $profile = $this->model_home-
?></li> >get_profile($username);
115
<?php if ($history == <?php
0) : ?> elseif ($history == 2) : ?>
<a href=<?php echo <th
"\"" . width="20" style="border: #C0C0C0 1px solid;
base_url("index.php/main/appointment_history text-align:
") . "\""; ?> class="search_button" center;"><strong>Status</strong></th>
style="font- <?php
family:Arial, Helvetica, sans- endif; ?>
serif;padding:5px; text- </tr>
decoration:none;margin-bottom:10px;">View <?php foreach
Appointment History</a> ($appointments as $appointment) : ?>
<?php elseif($history <tr>
== 2) : ?> <td
<a href=<?php echo style="border: #C0C0C0 1px solid; text-
"\"" . align: center;"> <?= $appointment['date'] ?>
base_url("index.php/main/appointment_request </td>
") . "\""; ?> class="search_button" <td
style="font- style="border: #C0C0C0 1px solid; text-
family:Arial, Helvetica, sans- align: center;"> <?=
serif;padding:5px; text- substr($appointment['time'], 0, 8); ?> </td>
decoration:none;margin-bottom:10px;">Request <?php if
Appointment</a> ($_SESSION['user_role'] == 3) : ?>
<?php else : ?> <td
<h3 style="border: #C0C0C0 1px solid; text-
style="background:#6CF; font- align: center;"> <?php
size:14px;color:#333; border:#69C 1px solid;
padding:8px;">Appointment History</h3> $username = $this->model_home-
<?php endif; ?> >get_owner_username($appointment['owner_id']
<div id="clear"><br );
/></div>
<table width="710" $profile = $this->model_home-
border="0" style="font-family: Arial, >get_profile($username);
Helvetica, sans-serif; font-size:14px;">
echo $profile['first_name'] . " " .
<tr > $profile['last_name']; ?> </td>
<th <?php endif;
width="90" style="border: #C0C0C0 1px if ($_SESSION['user_role'] == 4) : ?>
solid;"><strong>Date</strong></th>
<th <!--
width="70" style="border: #C0C0C0 1px Clinic name -->
solid;"><strong>Time</strong></th> <td
<?php if style="border: #C0C0C0 1px solid; text-
($_SESSION['user_role'] == 3) : ?> align: center;"> <?php
116
>get_pet_info($appointment['pet_id'])['pet_n $('#approve').click(function(){
ame']; ?> </td> var check = confirm("Approve
appointment request?");
<td if (check == false) {
style="border: #C0C0C0 1px solid; text- return false;
align: center;"> <?= $appointment['remarks'] } else {
?> </td> return true;
<?php }
if ($history == 0) : ?> });
<td </script>
style="border: #C0C0C0 1px solid;" id =
"test_approve">
117
<td
<a href=<?php echo "\"" . style="border: #C0C0C0 1px solid;"> <?=
base_url("index.php/main/delete_request") . $clinic['clinic_name'] ?> </td>
"/" . $clinic['username'] . "\""; ?> > <td
style="border: #C0C0C0 1px solid;"> <?=
<img src=<?php echo "\"" . $clinic['address'] ?> </td>
base_url("resources/images/delete.png") . <td
"\""; ?> width="20" height="20" /> </a> style="border: #C0C0C0 1px solid;"> <?=
</td> $clinic['contact_no'] ?> </td>
</tr> <td
style="border: #C0C0C0 1px solid;"> <?=
<?php endforeach; ?> ($clinic['status'] == 1 ? "Active" :
</table> "Deactivated") ?> </td>
</div> <td
<script> style="border: #C0C0C0 1px solid;">
118
<h2 </tr>
style="background:#6CF; font- <?php foreach
size:14px;color:#333; border:#69C 1px solid; ($medicationList as $medication) : ?>
padding:8px;">Consultation Information</h2> <tr>
<div class="pet_info">
<td style="border: #C0C0C0 1px
<li><strong>Consultation solid;"> <?= $medication['med_date'] ?>
Date:</strong><?php echo </td>
$consultation['consultation_date']; ?></li>
<td style="border: #C0C0C0 1px
<li><strong>Chief Complaint:</strong> solid;"> <?= $medication['medicine'] ?>
<?php echo $consultation['complaint']; </td>
?></li>
<td style="border: #C0C0C0 1px
<li><strong>Diagnosis: </strong><?php solid;"> <?= $medication['dosage'] ?> </td>
echo $consultation['diagnosis']; ?></li> </tr>
<?php
<li><strong>Remarks: </strong><?php endforeach; ?>
echo $consultation['remarks'] == "" ? "< No </table>
remarks >" : $consultation['remarks'];
?></li> <hr>
119
</table> <div id="clear"
<hr> style="padding-bottom:10px;"><br /><br
</div> /></div>
<?php endif; ?> <a href="<?php echo
<?php if base_url("index.php/main/view_pet") . "/" .
(array_filter($vaccinationList)) : ?> $consultation['pet_id']; ?>"
<div id="clear"><br class="search_button" style="padding:10px;
/><br /></div> text-decoration:none;
background:#F93;">Back</a>
<div class="pet_info
border"> </div>
<h2
style="background:#6CF; font-
size:14px;color:#333; border:#69C 1px solid;
padding:8px;">Vaccinations</h2><br />
<table
Listing 31: resources/css/style.css
width="710" border="0" style="font-family:
Arial, Helvetica, sans-serif; font- @charset "utf-8";
size:14px;">
<tr> /* CSS Document */
120
} width:600px;
float: left;
#header .section ul li { padding:10px;
background: url(../images/bg-nav- min-height:320px;
right.gif) no-repeat top right; margin-bottom:50px;
display: inline-block; }
float: left; .left_design{
list-style: none; background:#F9F9F9;
margin: 0 10px; border-top: #09C 40px solid;
padding: 0; border-radius: 5px 5px 0px 0px;
}
#header .section ul li a { }
background: url(../images/bg-nav- .left_design ul{
left.gif) top left; /*no-repeat */ padding-top:7px;
color: #fff; padding-left:5px;
display: inline-block; }
font-size: 16px; .left_design ul li{
height: 30px; display: block;
letter-spacing: 0.05em; color: white;
line-height: 30px; margin: 3px;
margin: 0; background: #FC6;
padding: 0 15px; padding:7px;
text-align: center; border-radius:3px;
text-decoration: none; font-family:Arial, Helvetica, sans-
text-transform: uppercase; serif;
} font-size:16px;
#header .section ul li a:hover { }
color: #ccc; .left_design ul li a{
} color:#666;
#header .section ul li.selected { text-decoration:none;
background: url(../images/bg-nav- }
right-selected.gif) top right; /*no-repeat .table_name{
*/ font-family:Arial, Helvetica, sans-
} serif;
#header .section ul li.selected a { font-size:17px;
background: url(../images/bg-nav- padding:5px;
left-selected.gif) top left; /*no-repeat */ color: #6C6C6C;
} }
/**************END*************************/ .txt_width{
width:400px;
.head_design{ height:20px;
font-family: "Trebuchet MS", Arial, padding:5px;
Helvetica, sans-serif;
font-size:40px; }
color:#F60;
margin-top:20px; /***********LEFT SIDEBAR**************/
}
.list{ .content #content_left {
background: #FCFCFC; width: 70px;
border height: 178px;
background: #519194;
} border: 5px solid #5fb3bd;
.search_button{ border-radius: 4px;
background:#36C; float: none;
height:50px; margin: 0;
color:#FFF; padding: 30px 15px 19px 210px;
border:#36C; position: relative;
border-radius:3px; /*margin-left: -55px;*/
width:100px; }
margin-top:15px; .content #content_left img {
} display: block;
.content{ left: 0;
width: 1000px; margin: 0;
margin: 0 auto; padding: 0;
margin-top: 60px; position: absolute;
padding: 5px; top: -13px;
} z-index: 5;
.border{ }
border:#CCC 1px solid;
} /**************END*************************/
#right_content{
121
/***********RIGHT SIDEBAR**************/ border: #A9A9A9 1px solid;
border-radius:5px;
.content #content_right { width:590px;
background: #fff; font-family:Arial, Helvetica, sans-
border: 3px solid #5fb3bd; serif;
border-radius: 4px; font-size:16px;
min-height: 350px; padding:5px;
padding: 45px 15px 15px; color: #ACACAC;
position: relative; }
width: 650px; #left_content{
} width:300px;
.content #content_right h2 { float: left;
text-align: center; padding:10px;
} }
.content #content_right h3 { .right_design{
color: #354057; background:#F9F9F9;
font-size: 20px; border-top: #09C 40px solid;
font-weight: normal; margin-left:10px;
margin: 0; border-radius: 5px 5px 0px 0px;
padding: 10px 0 0; }
text-transform: none; #clear{
} clear:both;
#body div .featured img { }
display: block;
float: left; #footer {
margin: 10px 30px 25px 0; background: #4c8f96;
padding: 0; border-top: 1px solid #9bd9e0;
} margin: 0;
#body div .featured p { padding: 0;
clear: both; }
color: #464646; #footer > div {
font-size: 12px; margin: 0 auto;
line-height: 24px; padding: 30px 0 28px;
margin: 0 0 24px; overflow: hidden;
padding: 0; text-align: center;
} width: 960px;
#body div .featured p a { }
color: #464646; #footer div p {
} color: #ededed;
#body div .featured p a:hover { display: inline-block;
color: #252525; float: right;
} font-size: 12px;
letter-spacing: 0.05em;
/**************END*************************/ margin: 0;
padding: 27px 0 0;
.user_design_l{ text-align: center;
width: 250px;border: #CCC 1px solid; }
} #footer div .connect {
.user_design_r{ background: #387a82;
width:650px;border:#CCC 1px solid; float: right;
} height: 18px;
.inner{ margin: 0 20px 0 150px;
background: #F7F7F7; padding: 22px 20px;
font-size:14px; overflow: hidden;
font-family:Arial, Helvetica, sans- width: 144px;
serif; }
color:#333; #footer div .connect span {
margin-right:5px; color: #ededed;
} display: inline-block;
.text_box{ float: left;
height:40px; font-size: 12px;
border: #A9A9A9 1px solid; height: 19px;
border-radius:5px; line-height: 21px;
width:580px; margin: 0;
font-family:Arial, Helvetica, sans- padding: 0 0 0 39px;
serif; }
font-size:16px; #footer div .connect a {
padding:5px; background: url(../images/icons.png)
} no-repeat;
.se_lect{ display: block;
height:50px; float: left;
122
height: 20px; font-family:Arial, Helvetica, sans-
margin: 0 8px; serif;
padding: 0; font-size:16px;
text-indent: -99999px; /*color:#6C6C6C;*/
width: 20px; height:25px;
} padding:2px;
#footer div .connect #twitter { width:400px;
background-position: 0 -32px;
} }
#footer div .connect #twitter:hover { /**************END*************************/
background-position: -25px -32px;
} /***********REGISTRATION**************/
#footer div .connect #facebook {
background-position: 0 -57px; .content #registration {
} background: #fff;
#footer div .connect #facebook:hover { border: 3px solid #5fb3bd;
background-position: -25px -57px; border-radius: 4px;
} margin: 25px auto 28px;
#footer div .connect #googleplus { overflow: hidden;
background-position: 0 -82px; padding: 0;
} width: 936px;
#footer div .connect #googleplus:hover { }
background-position: -25px -82px; .content #registration img {
} display: block;
#footer div .connect #pinterest { float: left;
background-position: 0 -107px; margin: 0 50px 0 0;
} padding: 0;
#footer div .connect #pinterest:hover { }
background-position: -25px -107px; .content #registration h1 {
} color: #1b2130;
font-family: 'ChangaOne';
/***********LOGIN FOR USER**************/ font-size: 40px;
.content h2 { font-weight: normal;
background: url(../images/bg- margin: 0;
featured.png) repeat-x; line-height: 50px;
color: #fff; padding: 20px 20px 20px;
font-family: 'Comfortaa-Regular'; }
font-size: 20px;
font-weight: normal; /**************END*************************/
height: 47px;
letter-spacing: 0.1em; /***********HOMEPAGE**************/
left: 15px;
line-height: 47px; .content .homepage {
margin: 0; background: #fff;
padding: 0 25px; border: 5px solid #5fb3bd;
position: absolute; border-radius: 4px;
text-transform: capitalize; min-height: 250px;
top: -14px; padding: 45px 15px 15px;
} position: relative;
.content #login { width: 620px;
width: 460px; margin-bottom: 30px;
background: #519194; }
border: 5px solid #5fb3bd; .content .homepage h2 {
border-radius: 4px; text-align: center;
float: none; }
margin: 0; .content .homepage h3 {
position: relative; color: #354057;
} font-size: 20px;
.content #login { font-weight: normal;
color: #f5f5f5; margin: 0;
height: 175px; padding: 10px 0 0;
margin-bottom: 35px; text-transform: none;
padding: 55px 15px 20px; }
text-align: right; #body div .featured img {
} display: block;
.content #login h2 { float: left;
text-align: left; margin: 10px 30px 25px 0;
} padding: 0;
}
.txt_fields{ #body div .featured p {
clear: both;
123
color: #464646;
font-size: 12px; }
line-height: 24px; #pet_list{
margin: 0 0 24px; width:625px;
padding: 0; border: #EBEBEB 1px solid;
} margin-top:20px;
#body div .featured p a { background: #FBFBFB;
color: #464646; padding:10px;
} }
#body div .featured p a:hover {
color: #252525;
}
Listing 32: resources/js/
/**************END*************************/ jquery.placepicker.js
// obtained originally from
/**********Warning and success http://www.jqueryscript.net/form/jQuery-
message**************/ Location-Autocomplete-with-Google-Maps-
.warning{ Places-Library-Placepicker.html
background:#FFCC99; +(function ( $, window) {
border:#FF6600 1px solid; var pluginName = "placepicker";
font-family:Arial, Helvetica, sans-
serif; var defaults = {
color: #333333; map: "",
padding:5px; mapOptions: {
width:381px; zoom: 15
} },
.success{ places: {
background: #FFC; icons: false
border: #0C0 1px solid; },
font-family:Arial, Helvetica, sans- autoCompleteOptions: {
serif; },
color: #333333; // callbacks
padding:5px; placeChanged: null,
width:381px; location: null,
} preventSubmit: true
.error { };
color: #D8000C;
background-color: #FFBABA; function PlacePicker(element,
width: 400px; options) {
padding: 2px;
} var instance = this;
.error_div {
color: #ff0000; var geocoder = null;
size: 2;
} var mapElement, map, marker;
/******************************************/
/*******user settings*************/ var service = null;
#admin_box{
width:180px; var autocomplete;
border:#CCC 1px solid;
background:#FFC; // stores the current place
margin: 10px; var _place = null;
padding:10px; var _latLng = null;
float:left;
font-family:Arial, Helvetica, sans- /**
serif; * Generates a piece of HTML
font-size:16px; that is used to replace the input element
border-radius:3px; * with one that also contains
} a globe button.
.pet_info{ */
padding:5px; function template() {
color:#333; var templateString =
line-height:20px; "<div class=\"input-
font-size:12px; group\">" +
color:#369; "<span class=\"input-
overflow-x:auto; group-btn\">" +
} "<button data-
.pet_info li{ toggle=\"collapse\" href=\"#" +
display: list-item;
124
options.mapContainerId + "\" class=\"btn
btn-default\">" + }
"<span }
class=\"glyphicon glyphicon-globe\"></span>" });
+ }
"</button>" + }
"</span>" +
"</div>"; function codeLatLng(latlng) {
return;
autocomplete.bindTo("bounds", map);
125
google.maps.event.addListener(map, $(e.target).css("display", "");
"click", function(e) { });
var pos = }
e.latLng;
function initAutoComplete() {
marker.setPosition(pos); autocomplete = new
google.maps.places.Autocomplete(element,
map.panTo(pos); options.autoCompleteOptions);
element.blur(); google.maps.event.addListener(autocom
plete, "place_changed", function() {
codeLatLng(pos); var place =
}); autocomplete.getPlace();
if
marker = new (place.geometry) {
google.maps.Marker({
map: map, setPlace(place);
draggable: }
true });
}); }
google.maps.event.addListener(marker, if (options.latitude
'dragend', function(e) { && options.longitude) {
var pos =
e.latLng; $(options.mapOptions).prop("center",
new google.maps.LatLng(options.latitude,
marker.setPosition(pos); options.longitude));
}
map.panTo(pos);
initDomElements();
element.blur(); initAutoComplete();
initMap();
codeLatLng(pos);
}); if (!element.value) {
var lat =
service = new options.latitude ||
google.maps.places.PlacesService(map); $(options.latitudeInput).prop("value");
var lng =
// When the map is options.longitude ||
made visible, if we have no location set $(options.longitudeInput).prop("value");
then if (lat &&
// attempt lng) {
geolocation. The css() calls ensure that the
map is instance.setLocation(lat, lng);
// refreshed. }
else {
$(mapElement).parent().on("show.bs.co
llapse", function(e) { instance.geoLocation();
}
$(e.target).css("display", "block"); } else {
if codePlace(element.value);
(!element.value) { }
instance.geoLocation(); $(window).on("resize",
} else { resizeHandler);
126
if anchor:
(options.preventSubmit && e.keyCode === 13) new google.maps.Point(17, 34),
{
scaledSize: new google.maps.Size(35,
e.preventDefault(); 35)
};
e.stopImmediatePropagation();
} marker.setIcon(iconOptions);
}); }
}
marker.setPosition(pos);
function setPlace(place,
updateMap) { marker.setVisible(true);
updateMap = typeof
updateMap === "undefined" ? true : false;
_place = place; }
instance.resize(); this.setValue =
function(value) {
var pos = element.value = value;
place.geometry.location; codePlace(value);
};
if (updateMap) {
this.getValue = function() {
updatePosition(pos); return element.value;
} };
this.setLocation =
$(options.latitudeInput).prop("value" function(latitude, longitude) {
, pos.lat()); var latLng = new
google.maps.LatLng(latitude, longitude);
$(options.longitudeInput).prop("value
", pos.lng()); this.setLatLng(latLng);
};
// update inputs
if (!updateMap) { this.getLocation = function()
element.value {
= place.formatted_address; var latLng =
} this.getLatLng();
if (latLng) {
if (typeof return {
options.placeChanged === "function") {
latitude: latLng.lat(),
options.placeChanged.call(instance,
place); longitude: latLng.lng()
} };
} }
};
function updatePosition(pos)
{ this.setLatLng =
function(latLng) {
if (!map) { _latLng = latLng;
return; codeLatLng(_latLng);
} };
127
return this.each(function() {
codePlace(element.value); if
} (!$(this).data(pluginName)) {
};
$(this).data(pluginName, new
this.resize = function() { pluginClass(this, $.extend({}, defaults,
if (map) { options, $(this).data())));
var center = }
map.getCenter(); return $(this);
});
google.maps.event.trigger(map, };
"resize");
})( jQuery, window );
map.setCenter(center);
}
};
Listing 34:
init.call(this);
} src/main/AndroidManifest.xml
var pluginClass = PlacePicker;
128
package="ph.edu.upm.cjgaleng.spotavet" >
android:screenOrientation="portrait" >
<uses-feature <intent-filter>
android:glEsVersion="0x00020000" <action
android:required="true" /> android:name="android.intent.action.MAIN" />
129
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem; public class MainActivity extends
import android.view.View; AppCompatActivity implements
import android.view.View.OnClickListener; ConnectionCallbacks,
import android.widget.Button; OnConnectionFailedListener,
import android.widget.ImageButton; LocationListener, OnClickListener,
import android.widget.TextView; OnMapClickListener, OnCameraChangeListener {
import android.widget.Toast;
private GoogleMap gMap;
import MarkerOptions marker;
com.google.android.gms.common.ConnectionResu private Button btnChangeAddress,
lt; btnMapList, btnFilter;
import private ImageButton btnSearchClinic,
com.google.android.gms.common.GooglePlayServ btnShowLocation;
icesUtil; private TextView txtLatlng, txtAddress;
import private ProgressDialog pDialog;
com.google.android.gms.common.api.GoogleApiC
lient; // server IP address
import private static final String CLINICS_URL
com.google.android.gms.common.api.GoogleApiC =
lient.ConnectionCallbacks; "http://192.168.43.149:80/SpotAVet/resources
import /json/nearest-clinics.php";
com.google.android.gms.common.api.GoogleApiC
lient.OnConnectionFailedListener; // JSON parser class
import JSONParser jsonParser = new
com.google.android.gms.location.LocationRequ JSONParser();
est;
import private static final String TAG =
com.google.android.gms.location.LocationServ MainActivity.class.getSimpleName();
ices; private final static int
import PLAY_SERVICES_RESOLUTION_REQUEST = 1000;
com.google.android.gms.location.LocationList
ener; private Location mLastLocation;
import private GoogleApiClient
com.google.android.gms.maps.CameraUpdateFact mGoogleApiClient;
ory; double myLat, myLng;
import
com.google.android.gms.maps.GoogleMap;
import static ArrayList<HashMap<String,
com.google.android.gms.maps.GoogleMap.OnMapC String>> clinicsList;
lickListener;
import LatLng upperLeft, lowerRight;
com.google.android.gms.maps.GoogleMap.OnCame
raChangeListener; private LocationRequest
import mLocationRequest;
com.google.android.gms.maps.MapFragment;
import // Location updates intervals in sec
com.google.android.gms.maps.SupportMapFragme private static int UPDATE_INTERVAL =
nt; 10000; // 10 sec
import private static int FASTEST_INTERVAL =
com.google.android.gms.maps.model.BitmapDesc 5000; // 5 sec
riptorFactory; private static int DISPLACEMENT = 10; //
import 10 meters
com.google.android.gms.maps.model.CameraPosi
tion; ConnectionDetector connectionDetector;
import // flag for Internet connection status
com.google.android.gms.maps.model.LatLng; Boolean isInternetPresent = false;
import // Alert Dialog Manager
com.google.android.gms.maps.model.Marker; AlertDialogManager alert = new
import AlertDialogManager();
com.google.android.gms.maps.model.MarkerOpti
ons; @Override
import protected void onCreate(Bundle
com.google.android.gms.maps.model.VisibleReg savedInstanceState) {
ion; super.onCreate(savedInstanceState);
130
btnSearchClinic = (ImageButton)
findViewById(R.id.btnSearchClinic); new
btnShowLocation = (ImageButton) NearestClinics().execute();
findViewById(R.id.btnShowLocation); break;
btnMapList = (Button) case R.id.btnShowLocation:
findViewById(R.id.btnMapList); displayLocation();
btnFilter = (Button) createLocationRequest();
findViewById(R.id.btnFilter); break;
case R.id.btnMapList:
txtLatlng = break;
(TextView)findViewById(R.id.textView_latLng) case R.id.btnFilter:
; i = new Intent(this,
txtAddress = ListNearestClinicsActivity.class);
(TextView)findViewById(R.id.textView_address startActivity(i);
); break;
txtLatlng.bringToFront(); default:
txtAddress.bringToFront(); }
}
btnChangeAddress.setOnClickListener(this); @Override
public void onMapClick(LatLng latLng) {
btnSearchClinic.setOnClickListener(this); btnFilter.setEnabled(false);
btnShowLocation.setOnClickListener(this); gMap.setOnCameraChangeListener(this);
btnMapList.setOnClickListener(this);
btnFilter.setOnClickListener(this); myLat = latLng.latitude;
myLng = latLng.longitude;
connectionDetector = new gMap.clear();
ConnectionDetector(getApplicationContext());
alert.showAlertDialog(MainActivity.this, marker.icon(BitmapDescriptorFactory.fromReso
"Internet Connection Error", urce(R.drawable.userlocation));
"Please connect to gMap.addMarker(marker);
working Internet connection", false);
// stop executing code by return new
return; GetAddressFromLatLng().execute();
} }
if(checkPlayServices()) { @Override
buildGoogleApiClient(); public void
createLocationRequest(); onCameraChange(CameraPosition
} cameraPosition) {
VisibleRegion vr =
setUpMapIfNeeded(); gMap.getProjection().getVisibleRegion();
}
LatLng topLeft = vr.farLeft;
@Override LatLng bottomRight = vr.nearRight;
public void onClick(View v) {
Intent i; if (((myLat > topLeft.latitude) ||
switch (v.getId()) { (myLat < bottomRight.latitude)) ||
case R.id.btnChangeAddress : ((myLng < topLeft.longitude)
i = new Intent(this, || (myLng > bottomRight.longitude))) {
SearchMapActivity.class);
startActivity(i); btnSearchClinic.setEnabled(false);
// }
startActivityForResult(nextScreen, 0); else {
break;
case R.id.btnSearchClinic : btnSearchClinic.setEnabled(true);
VisibleRegion visibleRegion }
= gMap.getProjection().getVisibleRegion(); }
upperLeft =
visibleRegion.farLeft; /**
lowerRight =
visibleRegion.nearRight;
131
* Sets up the map if it is possible to
do so (i.e., the Google Play services APK is gMap.setMyLocationEnabled(true);
correctly
* installed) and the map has not
already been instantiated.. This will ensure gMap.getUiSettings().setZoomControlsEnabled(
that we only ever true);
* call {@link #setUpMap()} once when
{@link #gMap} is not null. gMap.getUiSettings().setCompassEnabled(false
* <p/> );
* If it isn't installed {@link
SupportMapFragment} (and gMap.getUiSettings().setRotateGesturesEnable
* {@link d(false);
com.google.android.gms.maps.MapView
MapView}) will show a prompt for the user to
* install/update the Google Play gMap.getUiSettings().setMyLocationButtonEnab
services APK on their device. led(false);
* <p/>
* A user can return to this gMap.setOnMapClickListener(this);
FragmentActivity after following the prompt
and correctly gMap.setOnCameraChangeListener(this);
* installing/updating/enabling the }
Google Play services. Since the
FragmentActivity may not /**
* have been completely destroyed during * Method to verify google play services
this process (it is likely that it would on the device
only be * @return
* stopped or paused), {@link */
#onCreate(Bundle)} may not be called again private boolean checkPlayServices() {
so we should call this int resultCode =
* method in {@link #onResume()} to GooglePlayServicesUtil.isGooglePlayServicesA
guarantee that it will be called. vailable(this);
*/
private void setUpMapIfNeeded() { if (resultCode !=
// Do a null check to confirm that ConnectionResult.SUCCESS) {
we have not already instantiated the map. if
if (gMap == null) { (GooglePlayServicesUtil.isUserRecoverableErr
// Try to obtain the map from or(resultCode)) {
the SupportMapFragment.
gMap = ((MapFragment) GooglePlayServicesUtil.getErrorDialog(result
getFragmentManager().findFragmentById(R.id.m Code, this,
ap)) PLAY_SERVICES_RESOLUTION_REQUEST).show();
.getMap(); }
// Check if we were successful else {
in obtaining the map.
if (gMap != null) { Toast.makeText(getApplicationContext(),
setUpMap(); "This device is not supported.",
} Toast.LENGTH_LONG).show();
} finish();
} }
return false;
/** }
* This is where we can add markers or return true;
lines, add listeners or move the camera. In }
this case, we
* just add a marker near Africa. /**
* <p/> * Creating google api client object
* This should only be called once and */
when we are sure that {@link #gMap} is not protected synchronized void
null. buildGoogleApiClient() {
*/ mGoogleApiClient = new
private void setUpMap() { GoogleApiClient.Builder(this)
gMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); .addConnectionCallbacks(this)
132
mLastLocation = sb.append("Postal Code :
LocationServices.FusedLocationApi.getLastLoc ").append(address.getPostalCode()).append("\
ation(mGoogleApiClient); n");
btnFilter.setEnabled(false); sb.append("Country :
//btnSearchClinic.setEnabled(false); ").append(address.getCountryName());
result = sb.toString();
gMap.setOnCameraChangeListener(this); }
return result;
if (mLastLocation != null) { } catch (IOException e) {
myLat= e.printStackTrace();
mLastLocation.getLatitude(); }
myLng=
mLastLocation.getLongitude(); return null;
}
gMap.clear();
@Override
gMap.moveCamera(CameraUpdateFactory.newLatLn protected void onPostExecute(String
gZoom(new LatLng(myLat, myLng), 15)); result) {
marker = new
MarkerOptions().position(new LatLng(myLat, btnSearchClinic.setEnabled(true);
myLng)); txtLatlng.setText("Lat: " +
(float) myLat + " Lng: " + (float) myLng);
marker.icon(BitmapDescriptorFactory.fromReso if (result != null) {
urce(R.drawable.userlocation)); result = "\nAddress:\n" +
gMap.addMarker(marker); result;
new txtAddress.setText(mainAddress);
GetAddressFromLatLng().execute(); } else {
} result = "\n Unable to get
} address for this lat-long.";
}
private class GetAddressFromLatLng }
extends AsyncTask<String, String, String> { }
sb.append(address.getAddressLine(i)).append( @Override
", "); protected String
} doInBackground(String... args) {
mainAddress = // Check for success tag
sb.toString(); int success;
sb = new try {
StringBuilder(); // Building Parameters
sb.append("Locality : List<NameValuePair> params =
").append(address.getLocality()).append("\n" new ArrayList<NameValuePair>();
);
133
params.add(new map.put("clinic_id",
BasicNameValuePair("north", clinic_id);
Double.toString(upperLeft.latitude)));
params.add(new map.put("clinic_name", clinic_name);
BasicNameValuePair("south", map.put("address",
Double.toString(lowerRight.latitude))); address);
params.add(new map.put("x", lat);
BasicNameValuePair("west", map.put("y", lng);
Double.toString(upperLeft.longitude)));
params.add(new // adding HashList
BasicNameValuePair("east", to ArrayList
Double.toString(lowerRight.longitude)));
params.add(new clinicsList.add(map);
BasicNameValuePair("mylat",
Double.toString(myLat))); Double latitude =
params.add(new Double.parseDouble(lat);
BasicNameValuePair("mylng", Double longitude =
Double.toString(myLng))); Double.parseDouble(lng);
clinicsList = new
ArrayList<HashMap<String, String>>(); clinicMarkers.put(new LatLng(latitude,
clinicMarkers = new longitude), clinic_id);
HashMap<>(); }
Log.d("request!",
"starting"); return
json.getString("message");
// getting product details } else {
by making HTTP request Log.d("No clinics in
JSONObject json = area", json.getString("message"));
jsonParser.makeHttpRequest( return
CLINICS_URL , json.getString("message");
"POST", params);
}
// check your log for json } catch (JSONException e) {
response e.printStackTrace();
Log.d("Search clinics }
attempt", json.toString());
return null;
// json success tag }
success =
json.getInt("success"); /**
if (success == 1) { * After completing background task,
clinicArray = dismiss the progress dialog
json.getJSONArray("clinics"); * @param file_url
*/
for (int i = 0; i < protected void onPostExecute(String
clinicArray.length(); i++) { file_url) {
JSONObject c = // dismiss the dialog once
clinicArray.getJSONObject(i); product deleted
pDialog.dismiss();
// Storing each json
item in variable Toast.makeText(getApplicationContext(),
String clinic_id = file_url, Toast.LENGTH_SHORT).show();
c.getString("clinic_id"); btnFilter.setEnabled(true);
String clinic_name =
c.getString("clinic_name");
String address = gMap.setOnCameraChangeListener(null);
c.getString("address"); gMap.clear();
String lat =
c.getString("x"); marker = new
String lng = MarkerOptions().position(new LatLng(myLat,
c.getString("y"); myLng));
134
final HashMap<String, }
String> clinic_info = clinicsList.get(i);
double lat = @Override
Double.parseDouble(clinic_info.get("x")); public boolean
double lng = onOptionsItemSelected(MenuItem item) {
Double.parseDouble(clinic_info.get("y")); // Handle action bar item clicks
here. The action bar will
marker = new // automatically handle clicks on
MarkerOptions().position(new LatLng(lat, the Home/Up button, so long
lng)); // as you specify a parent activity
in AndroidManifest.xml.
marker.icon(BitmapDescriptorFactory.defaultM int id = item.getItemId();
arker(BitmapDescriptorFactory.HUE_AZURE));
if (i == 0) //noinspection
SimplifiableIfStatement
marker.icon(BitmapDescriptorFactory.defaultM if (id == R.id.action_settings) {
arker(BitmapDescriptorFactory.HUE_ROSE)); return true;
}
marker.title(clinic_info.get("clinic_name"))
; return
super.onOptionsItemSelected(item);
marker.snippet(clinic_info.get("address")); }
gMap.addMarker(marker);
}
@Override
protected void onStart() {
gMap.setOnInfoWindowClickListener(new super.onStart();
GoogleMap.OnInfoWindowClickListener() { if (mGoogleApiClient != null) {
@Override mGoogleApiClient.connect();
public void }
onInfoWindowClick(Marker marker) { }
Intent nextScreen = new
Intent(MainActivity.this, @Override
ClinicInfoActivity.class); protected void onResume() {
super.onResume();
nextScreen.putExtra("clinic_id", setUpMapIfNeeded();
clinicMarkers.get(marker.getPosition())); checkPlayServices();
}
startActivity(nextScreen); @Override
} protected void onPause() {
}); super.onPause();
}
/*gMap.setInfoWindowAdapter(new
GoogleMap.InfoWindowAdapter() { @Override
public View public void onConnectionSuspended(int
getInfoWindow(Marker arg0) { arg0) {
View v = mGoogleApiClient.connect();
getLayoutInflater().inflate(R.layout.custom_ }
infowindow, null);
return v; /**
} * Google api callback methods
*/
@Override @Override
public View public void
getInfoContents(Marker marker) { onConnectionFailed(ConnectionResult result)
return null; {
} Log.i(TAG, "Connection failed:
});*/ ConnectionResult.getErrorCode() = "
} + result.getErrorCode());
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu public void onConnected(Bundle arg0) {
menu) {
// Inflate the menu; this adds items // Once connected with google api,
to the action bar if it is present. get the location
displayLocation();
//getMenuInflater().inflate(R.menu.menu_main
, menu); }
return true;
135
/**
* Creating location request object // Setting Dialog Message
* */ alertDialog.setMessage(message);
protected void createLocationRequest() {
mLocationRequest = new // Setting OK Button
LocationRequest(); alertDialog.setButton("OK", new
DialogInterface.OnClickListener() {
mLocationRequest.setInterval(UPDATE_INTERVAL public void
); onClick(DialogInterface dialog, int which) {
}
mLocationRequest.setFastestInterval(FASTEST_ });
INTERVAL);
// Showing Alert Message
mLocationRequest.setPriority(LocationRequest alertDialog.show();
.PRIORITY_HIGH_ACCURACY); }
}
mLocationRequest.setSmallestDisplacement(DIS
PLACEMENT); // 10 meters
}
@Override
Listing 37: ClinicInfoActivity.java
public void onLocationChanged(Location
location) { package ph.edu.upm.cjgaleng.spotavet;
// Assign the new location
mLastLocation = location; import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
Toast.makeText(getApplicationContext(), import android.content.Intent;
"Location changed!", import android.os.AsyncTask;
Toast.LENGTH_SHORT).show(); import android.os.Bundle;
import
// Displaying the new location on UI android.support.v7.app.AppCompatActivity;
displayLocation(); import android.util.Log;
} import android.view.Menu;
} import android.view.MenuItem;
import android.widget.EditText;
import org.apache.http.NameValuePair;
import
Listing 36: AlertDialogManager.java org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
package ph.edu.upm.cjgaleng.spotavet; import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context; import java.util.ArrayList;
import android.content.DialogInterface; import java.util.HashMap;
import java.util.List;
/**
* Created by CJ on 6/4/2015.
*/ public class ClinicInfoActivity extends
public class AlertDialogManager { AppCompatActivity {
/** EditText txtCName, txtCAddress,
* Function to display simple Alert txtCSchedule, txtCContactNo,txtCEmail;
Dialog private ProgressDialog pDialog;
* @param context - application context
* @param title - alert dialog title // change to server IP address
* @param message - alert message private static final String CLINICS_URL
* @param status - success/failure (used =
to set icon) "http://192.168.43.149:80/SpotAVet/resources
* - pass null if you /json/clinic-info.php";
don't want icon
* */ // JSON parser class
public void showAlertDialog(Context JSONParser jsonParser = new
context, String title, String message, JSONParser();
Boolean
status) { private String clinic_id;
AlertDialog alertDialog = new
AlertDialog.Builder(context).create(); @Override
protected void onCreate(Bundle
// Setting Dialog Title savedInstanceState) {
alertDialog.setTitle(title); super.onCreate(savedInstanceState);
136
Log.d("request!",
setContentView(R.layout.activity_clinic_info "starting");
);
// getting product details
ListVetsFragment listVetsFragment = by making HTTP request
new ListVetsFragment(); JSONObject json =
jsonParser.makeHttpRequest(
getSupportActionBar().hide(); CLINICS_URL ,
FragmentManager fm = "POST", params);
getFragmentManager();
FragmentTransaction ft = // check your log for json
fm.beginTransaction(); response
ft.add(R.id.linearLayout1, Log.d("Clinic info attempt",
listVetsFragment); json.toString());
ft.commit();
// json success tag
txtCName = (EditText) success =
findViewById(R.id.txtCName); json.getInt("success");
txtCAddress = (EditText) if (success == 1) {
findViewById(R.id.txtCAddress); // Storing each json
txtCSchedule = (EditText) item in variable
findViewById(R.id.txtCSchedule); String clinic_id =
txtCContactNo = (EditText) json.getString("clinic_id");
findViewById(R.id.txtCContactNo); String clinic_name =
txtCEmail = (EditText) json.getString("clinic_name");
findViewById(R.id.txtCEmail); String address =
json.getString("address");
Intent intent = getIntent(); String schedule =
clinic_id = json.getString("schedule");
intent.getStringExtra("clinic_id"); String contact_no =
json.getString("contact_no");
new ClinicInformation().execute(); String email =
} json.getString("email");
137
// dismiss the dialog once public ConnectionDetector(Context
product deleted context){
pDialog.dismiss(); this._context = context;
}
txtCName.setText(clinicInfo.get("clinic_name /**
")); * Checking for all possible internet
providers
txtCAddress.setText(clinicInfo.get("address" * **/
)); public boolean isConnectingToInternet(){
ConnectivityManager connectivity =
txtCSchedule.setText(clinicInfo.get("schedul (ConnectivityManager)
e")); _context.getSystemService(Context.CONNECTIVI
TY_SERVICE);
txtCContactNo.setText(clinicInfo.get("contac if (connectivity != null)
t_no")); {
NetworkInfo[] info =
txtCEmail.setText(clinicInfo.get("email")); connectivity.getAllNetworkInfo();
if (info != null)
} for (int i = 0; i <
} info.length; i++)
if (info[i].getState()
@Override == NetworkInfo.State.CONNECTED)
public boolean onCreateOptionsMenu(Menu {
menu) { return true;
// Inflate the menu; this adds items }
to the action bar if it is present. }
return false;
getMenuInflater().inflate(R.menu.menu_clinic }
_info, menu);
return true; }
}
@Override
public boolean
onOptionsItemSelected(MenuItem item) {
Listing 39: GPlaceAPI.java
// Handle action bar item clicks
here. The action bar will package ph.edu.upm.cjgaleng.spotavet;
// automatically handle clicks on
the Home/Up button, so long import android.util.Log;
// as you specify a parent activity
in AndroidManifest.xml. import org.json.JSONArray;
int id = item.getItemId(); import org.json.JSONException;
import org.json.JSONObject;
//noinspection
SimplifiableIfStatement import java.io.IOException;
if (id == R.id.action_settings) { import java.io.InputStreamReader;
return true; import java.net.HttpURLConnection;
} import java.net.MalformedURLException;
import java.net.URL;
return import java.net.URLEncoder;
super.onOptionsItemSelected(item); import java.util.ArrayList;
}
} /**
* Created by CJ on 6/4/2015.
*/
public class GPlaceAPI {
private static final String TAG =
Listing 38: ConnectionDetector.java GPlaceAPI.class.getSimpleName();
138
// Go to resultList = new
https://console.developers.google.com/ and ArrayList<String>(predsJsonArray.length());
get your Android API Key for (int i = 0; i <
// example : private static final String predsJsonArray.length(); i++) {
API_KEY = "AIzaSyBdVl-
cTICSwYKrZ95SuvNw7dbMuDt1KG0" resultList.add(predsJsonArray.getJSONObject(
private static final String API_KEY = i).getString("description"));
""; place_id =
public String place_id; predsJsonArray.getJSONObject(i).getString("p
lace_id");
public ArrayList<String> autocomplete }
(String input) { } catch (JSONException e) {
ArrayList<String> resultList = null; Log.e(TAG, "Cannot process JSON
place_id = ""; results", e);
}
HttpURLConnection conn = null; return resultList;
StringBuilder jsonResults = new }
StringBuilder(); }
try {
StringBuilder sb = new
StringBuilder(PLACES_API_BASE +
TYPE_AUTOCOMPLETE + OUT_JSON);
Listing 40: JSONParser.java
sb.append("?key=" + API_KEY);
sb.append("&types=geocode"); package ph.edu.upm.cjgaleng.spotavet;
sb.append("&input=" +
URLEncoder.encode(input, "utf8")); import java.io.BufferedReader;
import java.io.IOException;
URL url = new import java.io.InputStream;
URL(sb.toString()); import java.io.InputStreamReader;
conn = (HttpURLConnection) import java.io.UnsupportedEncodingException;
url.openConnection(); import java.util.List;
InputStreamReader in = new
InputStreamReader(conn.getInputStream()); import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
// Load the results into a import org.apache.http.NameValuePair;
StringBuilder import
int read; org.apache.http.client.ClientProtocolExcepti
char[] buff = new char[1024]; on;
while ((read = in.read(buff)) != import
-1) { org.apache.http.client.entity.UrlEncodedForm
jsonResults.append(buff, 0, Entity;
read); import
} org.apache.http.client.methods.HttpGet;
} catch (MalformedURLException e) { import
Log.e(TAG, "Error processing org.apache.http.client.methods.HttpPost;
Places API URL", e); import
return resultList; org.apache.http.client.utils.URLEncodedUtils
} catch (IOException e) { ;
Log.e(TAG, "Error connecting to import
Places API", e); org.apache.http.impl.client.DefaultHttpClien
return resultList; t;
} finally { import org.json.JSONException;
if (conn != null) { import org.json.JSONObject;
conn.disconnect();
} import android.util.Log;
}
public class JSONParser {
try { static InputStream is = null;
// Log.d(TAG, static JSONObject jObj = null;
jsonResults.toString()); static String json = "";
139
// try parse the string to a JSON
List<NameValuePair> params) { object
try {
// Making HTTP request jObj = new JSONObject(json);
try { } catch (JSONException e) {
Log.e("JSON Parser", "Error
// check for request method parsing data " + e.toString());
if(method.equals("POST")){ }
// request method is POST
// defaultHttpClient // return JSON String
DefaultHttpClient httpClient return jObj;
= new DefaultHttpClient();
HttpPost httpPost = new }
HttpPost(url);
httpPost.setEntity(new }
UrlEncodedFormEntity(params));
HttpResponse httpResponse =
httpClient.execute(httpPost);
HttpEntity httpEntity =
Listing 41:
httpResponse.getEntity(); ListNearestClinicsActivity.java
is =
httpEntity.getContent();
package ph.edu.upm.cjgaleng.spotavet;
}else if(method.equals("GET")){
// request method is GET import android.app.FragmentManager;
DefaultHttpClient httpClient import android.app.FragmentTransaction;
= new DefaultHttpClient(); import android.content.Intent;
String paramString = import
URLEncodedUtils.format(params, "utf-8"); android.support.v7.app.ActionBarActivity;
url += "?" + paramString; import android.os.Bundle;
HttpGet httpGet = new import
HttpGet(url); android.support.v7.app.AppCompatActivity;
import android.view.Menu;
HttpResponse httpResponse = import android.view.MenuItem;
httpClient.execute(httpGet); import android.view.View;
HttpEntity httpEntity = import android.widget.Button;
httpResponse.getEntity();
is =
httpEntity.getContent(); public class ListNearestClinicsActivity
} extends AppCompatActivity implements
View.OnClickListener {
} catch private Button btnMapList2, btnFilter2;
(UnsupportedEncodingException e) {
e.printStackTrace(); @Override
} catch (ClientProtocolException e) protected void onCreate(Bundle
{ savedInstanceState) {
e.printStackTrace(); super.onCreate(savedInstanceState);
} catch (IOException e) {
e.printStackTrace(); setContentView(R.layout.activity_list_neares
} t_clinics);
btnMapList2 = (Button)
try { findViewById(R.id.btnMapList2);
BufferedReader reader = new
BufferedReader(new InputStreamReader( btnMapList2.setOnClickListener(this);
is, "iso-8859-1"), 8);
StringBuilder sb = new ListNearestClinicsActivityFragment
StringBuilder(); listNearestClinicsActivityFragment = new
String line = null; ListNearestClinicsActivityFragment();
while ((line = FragmentManager fm =
reader.readLine()) != null) { getFragmentManager();
sb.append(line + "\n"); FragmentTransaction ft =
} fm.beginTransaction();
is.close();
json = sb.toString(); ft.add(R.id.layoutNearestClinicsList,
} catch (Exception e) { listNearestClinicsActivityFragment);
Log.e("Buffer Error", "Error ft.commit();
converting result " + e.toString());
} }
140
@Override
public boolean onCreateOptionsMenu(Menu import org.apache.http.NameValuePair;
menu) { import
// Inflate the menu; this adds items org.apache.http.message.BasicNameValuePair;
to the action bar if it is present. import org.json.JSONArray;
import org.json.JSONException;
getMenuInflater().inflate(R.menu.menu_list_n import org.json.JSONObject;
earest_clinics, menu);
return true; import java.util.ArrayList;
} import java.util.HashMap;
import java.util.List;
@Override
public boolean
onOptionsItemSelected(MenuItem item) { /**
// Handle action bar item clicks * A placeholder fragment containing a
here. The action bar will simple view.
// automatically handle clicks on */
the Home/Up button, so long public class
// as you specify a parent activity ListNearestClinicsActivityFragment extends
in AndroidManifest.xml. ListFragment {
int id = item.getItemId(); private ProgressDialog pDialog;
private Button btnMapList2, btnFilter2;
//noinspection
SimplifiableIfStatement public
if (id == R.id.action_settings) { ListNearestClinicsActivityFragment() {
return true; }
}
@Override
return public View onCreateView(LayoutInflater
super.onOptionsItemSelected(item); inflater, ViewGroup container,
} Bundle
savedInstanceState) {
@Override View myInflatedView =
public void onClick(View v) { inflater.inflate(R.layout.fragment_list_near
Intent i; est_clinics, container,false);
switch (v.getId()) {
case R.id.btnMapList2: return myInflatedView;
finish(); }
break;
case R.id.btnFilter2: @Override
break; public void onActivityCreated (Bundle
default: savedInstanceState){
}
} super.onActivityCreated(savedInstanceState);
} btnMapList2 = (Button)
getActivity().findViewById(R.id.btnMapList2)
;
btnFilter2 = (Button)
getActivity().findViewById(R.id.btnFilter2);
}
Listing 42:
ListNearestClinicsActivityFragment.java public void onResume() {
// TODO Auto-generated method stub
super.onResume();
package ph.edu.upm.cjgaleng.spotavet;
//loading the comments via AsyncTask
import android.app.ListFragment; new GetClinicList().execute();
import android.app.ProgressDialog; }
import android.content.Intent;
import android.os.AsyncTask; @Override
import android.support.v4.app.Fragment; public void onListItemClick(ListView l,
import android.os.Bundle; View v, int position, long id) {
import android.util.Log; Intent nextScreen = new
import android.view.LayoutInflater; Intent(getActivity().getApplicationContext()
import android.view.View; , ClinicInfoActivity.class);
import android.view.ViewGroup; nextScreen.putExtra("clinic_id",
import android.widget.Button; MainActivity.clinicsList.get(position).get("
import android.widget.ListAdapter; clinic_id"));
import android.widget.ListView;
import android.widget.SimpleAdapter; startActivity(nextScreen);
import android.widget.Toast; }
141
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
class GetClinicList extends import android.widget.Filter;
AsyncTask<String, String, String> { import android.widget.Filterable;
import android.widget.ImageView;
/** import android.widget.TextView;
* Before starting background thread
Show Progress Dialog import java.util.ArrayList;
* */
/**
@Override * Created by CJ on 6/4/2015.
protected void onPreExecute() { */
super.onPreExecute(); public class PlacesAutoCompleteAdapter
btnMapList2.setEnabled(false); extends ArrayAdapter<String> implements
Filterable {
pDialog = new ArrayList<String> resultList;
ProgressDialog(getActivity());
pDialog.setMessage("Loading Context mContext;
clinics list..."); int mResource;
pDialog.setIndeterminate(false);
pDialog.setCancelable(false); GPlaceAPI mPlaceAPI = new GPlaceAPI();
pDialog.show();
} public PlacesAutoCompleteAdapter(Context
context, int resource) {
@Override super(context, resource);
protected String
doInBackground(String... args) { mContext = context;
// Check for success tag mResource = resource;
return null; }
}
@Override
/** public int getCount() {
* After completing background task, // Last item will be the footer
dismiss the progress dialog return resultList.size();
* @param file_url }
*/
protected void onPostExecute(String @Override
file_url) { public String getItem(int position) {
super.onPostExecute(file_url); return resultList.get(position);
// dismiss the dialog once }
product deleted
pDialog.dismiss(); @Override
btnMapList2.setEnabled(true); public Filter getFilter() {
Filter filter = new Filter() {
ListAdapter adapter = new @Override
SimpleAdapter(getActivity(), protected FilterResults
MainActivity.clinicsList, performFiltering(CharSequence constraint) {
R.layout.fragment_list_nearest_clinics_item, FilterResults filterResults
new = new FilterResults();
String[]{"clinic_name", "address", },
new return filterResults;
int[]{R.id.txtListCName, }
R.id.txtListCAddress});
@Override
setListAdapter(adapter); protected void
} publishResults(CharSequence constraint,
} FilterResults results) {
} }
};
return filter;
}
Listing 43:
PlacesAutoCompleteAdapter.java @Override
public View getView(int position, View
convertView, ViewGroup parent) {
package ph.edu.upm.cjgaleng.spotavet; View view;
import android.content.Context; LayoutInflater inflater =
import android.view.LayoutInflater; (LayoutInflater)
import android.view.View;
142
mContext.getSystemService(Context.LAYOUT_INF Handler mThreadHandler;
LATER_SERVICE);
autocompleteView.setOnItemClickListener(this
public class SearchMapActivity extends );
AppCompatActivity implements autocompleteView.setThreshold(3);
OnItemClickListener, TextWatcher {
private static String TAG = autocompleteView.setAdapter(mAdapter);
SearchMapActivity.class.getSimpleName(); }
private PlacesAutoCompleteAdapter
mAdapter; @Override
private String place_id1; public void
beforeTextChanged(CharSequence s, int start,
HandlerThread mHandlerThread; int count, int after) {
143
}
}
return
@Override super.onOptionsItemSelected(item);
public void onTextChanged(CharSequence }
s, int start, int before, int count) {
final String value = s.toString(); @Override
public void onItemClick(AdapterView<?>
// Remove all callbacks and messages parent, View view, int position, long id) {
// Get data associated with the
mThreadHandler.removeCallbacksAndMessages(nu specified position
ll); // in the list (AdapterView)
String description = (String)
// Now add a new one parent.getItemAtPosition(position);
mThreadHandler.postDelayed(new
Runnable() { Toast.makeText(getApplicationContext(),
place_id1, Toast.LENGTH_SHORT).show();
@Override
public void run() { }
// Background thread
mAdapter.resultList =
mAdapter.mPlaceAPI.autocomplete(value); @Override
place_id1 = public void onDestroy() {
mAdapter.mPlaceAPI.place_id; super.onDestroy();
@Override
public void afterTextChanged(Editable s)
{
Listing 45:
SearchMapActivityFragment.java
}
144
return return true;
inflater.inflate(R.layout.fragment_search_ma }
p, container, false);
} return
} super.onOptionsItemSelected(item);
}
}
145
public View onCreateView(LayoutInflater class GetVetInfo extends
inflater, ViewGroup container, AsyncTask<String, String, String> {
Bundle private String specialization = "";
savedInstanceState) { private String schedule = "";
// Inflate the layout for this
fragment /**
* Before starting background thread
// -- inflate the layout for this Show Progress Dialog
fragment * */
View myInflatedView = @Override
inflater.inflate(R.layout.fragment_vetinfo, protected void onPreExecute() {
container,false); super.onPreExecute();
pDialog = new
// Set the Text to try this out ProgressDialog(getActivity());
txtCardVName = (TextView) pDialog.setMessage("Loading vet
myInflatedView.findViewById(R.id.txtCardVNam info...");
e); pDialog.setIndeterminate(false);
txtCardVLicense = (TextView) pDialog.setCancelable(false);
myInflatedView.findViewById(R.id.txtCardVLic pDialog.show();
ense); }
txtCardVEmail = (TextView)
myInflatedView.findViewById(R.id.txtCardVEma @Override
il); protected String
txtCardVContact = (TextView) doInBackground(String... args) {
myInflatedView.findViewById(R.id.txtCardVCon // Check for success tag
tact); int success;
txtCardVSpecialization = (TextView)
myInflatedView.findViewById(R.id.txtCardVSpe try {
cialization);
txtCardVSchedule = (TextView) // Building Parameters
myInflatedView.findViewById(R.id.txtCardVSch List<NameValuePair> params =
edule); new ArrayList<NameValuePair>();
params.add(new
BasicNameValuePair("clinic_id",
txtCardVName.setText(getActivity().getIntent
().getExtras().getString("name")); getActivity().getIntent().getExtras().getStr
String license_no = ing("clinic_id")));
getActivity().getIntent().getExtras().getStr params.add(new
ing("license_no"); BasicNameValuePair("vet_id",
txtCardVLicense.setText(Html.fromHtml("<stro getActivity().getIntent().getExtras().getStr
ng>License No. : </strong> " + ing("vet_id")));
license_no));
String email =
getActivity().getIntent().getExtras().getStr Log.d("request!",
ing("email"); "starting");
} return
json.getString("message");
} else {
146
Log.d("Vet not found!", public class ListVetsFragment extends
json.getString("message")); ListFragment {
return
json.getString("message"); // change to server IP address
private static final String LOGIN_URL =
} "http://192.168.43.149:80/SpotAVet/resources
} catch (JSONException e) { /json/clinic-vets.php";
e.printStackTrace(); private ListView listViewVets;
} ArrayList<HashMap<String, String>>
vetsList;
return null;
} private ProgressDialog pDialog;
txtCardVSpecialization.setText(specializatio @Override
n); public View onCreateView(LayoutInflater
inflater, ViewGroup container, Bundle
txtCardVSchedule.setText(Html.fromHtml(sched savedInstanceState) {
ule)); return
} inflater.inflate(R.layout.fragment_listvets,
} container, false);
} }
@Override
public void onActivityCreated(Bundle
savedState) {
Listing 48: ListVetsFragment.java super.onActivityCreated(savedState);
147
intent.putExtra("contact_no", Log.d("Get vets
vetsList.get(position).get("contact_no")); attempt", json.toString());
intent.putExtra("vet_id",
vetsList.get(position).get("vet_id")); // json success tag
intent.putExtra("clinic_id", success =
getActivity().getIntent().getExtras().getStr json.getInt("success");
ing("clinic_id")); if (success == 1) {
// looping through
startActivity(intent); All messages
} for (int i = 0; i <
vetsArray.length(); i++) {
JSONObject c =
class GetVets extends AsyncTask<String, vetsArray.getJSONObject(i);
String, String> {
// Storing each
/** json item in variable
* Before starting background thread String vet_id =
Show Progress Dialog c.getString("vet_id");
* */ String
boolean failure = false; license_no = c.getString("license_no");
private String loginRole; String name =
c.getString("first_name") + " " +
@Override c.getString("last_name");
protected void onPreExecute() { String email =
super.onPreExecute(); c.getString("email");
pDialog = new String
ProgressDialog(getActivity()); contact_no = c.getString("contact_no");
pDialog.setMessage("Loading
users list..."); // creating new
pDialog.setIndeterminate(false); HashMap
pDialog.setCancelable(false); HashMap<String,
pDialog.show(); String> map = new HashMap<String, String>();
}
// adding each
@Override child node to HashMap key => value
protected String
doInBackground(String... args) { map.put("vet_id", vet_id);
// Check for success tag
int success; map.put("license_no", license_no);
map.put("name",
JSONArray vetsArray = null; name);
map.put("email",
email);
try {
map.put("contact_no", contact_no);
// Building Parameters
List<NameValuePair> params = // adding
new ArrayList<NameValuePair>(); HashList to ArrayList
params.add(new
BasicNameValuePair("clinic_id", vetsList.add(map);
}
getActivity().getIntent().getExtras().getStr
ing("clinic_id"))); return
json.getString("message");
Log.d("request!", } else {
"starting"); Log.d("No result!",
json.getString("message"));
// getting product details return
by making HTTP request json.getString("message");
JSONObject json =
jsonParser.makeHttpRequest( }
LOGIN_URL, "POST", }
params); } catch (JSONException e) {
e.printStackTrace();
if }
(json.has("veterinarians")) {
vetsArray = return null;
json.getJSONArray("veterinarians"); }
148
* After completing background task, <TextView
dismiss the progress dialog
* @param file_url style="@style/Base.TextAppearance.AppCompat.
*/ Headline"
protected void onPostExecute(String
file_url) { android:layout_width="match_parent"
// dismiss the dialog once
product deleted android:layout_height="wrap_content"
pDialog.dismiss();
android:textAppearance="?android:attr/textAp
ListAdapter adapter = new pearanceLarge"
SimpleAdapter(getActivity(), vetsList, android:text="Clinic
R.layout.fragment_listvets_item, Information"
new String[]{"name", android:id="@+id/textView2"
"email", "license_no", },
new int[]{R.id.txtVName, android:background="#ffcc5d00" />
R.id.txtVEmail, R.id.txtVLicense});
<LinearLayout
setListAdapter(adapter);
} android:layout_width="fill_parent"
}
android:layout_height="wrap_content"
}
android:orientation="horizontal" >
<TextView
Listing 49: android:layout_width="0dp"
res/layout/activity_clinic_info.xml
android:layout_height="wrap_content"
<LinearLayout android:layout_weight="0.2"
xmlns:android="http://schemas.android.com/ap android:text="Clinic
k/res/android" Name :"
xmlns:tools="http://schemas.android.com/tool android:layout_gravity="center" />
s" android:layout_width="match_parent" <EditText
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizon style="@style/Base.TextAppearance.AppCompat.
tal_margin" Subhead"
android:paddingRight="@dimen/activity_horizo android:layout_width="0dp"
ntal_margin"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_vertical
_margin" android:layout_weight="0.8"
android:paddingBottom="@dimen/activity_verti android:id="@+id/txtCName"
cal_margin" android:editable="false"
android:orientation="vertical"
android:clickable="false"
tools:context="ph.edu.upm.cjgaleng.ClinicInf
oActivity"> android:focusable="false" />
</LinearLayout>
<android.support.v7.widget.CardView
<LinearLayout
xmlns:card_view="http://schemas.android.com/
apk/res-auto" android:layout_width="fill_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
card_view:contentPadding="8dp"
card_view:cardElevation="2dp" android:orientation="horizontal"
card_view:cardCornerRadius="5dp" >
android:layout_gravity="center">
<LinearLayout
<TextView
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"> android:layout_height="wrap_content"
149
android:layout_weight="0.2" android:layout_height="wrap_content"
android:text="Address :
" /> android:layout_weight="0.2"
<EditText android:text="Contact #
:" />
style="@style/Base.TextAppearance.AppCompat. <EditText
Subhead"
style="@style/Base.TextAppearance.AppCompat.
android:layout_width="0dp" Subhead"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_weight="0.8" android:layout_height="wrap_content"
android:id="@+id/txtCAddress" android:layout_weight="0.8"
android:editable="false"
android:id="@+id/txtCContactNo"
android:clickable="false" android:editable="false"
android:layout_width="fill_parent" <LinearLayout
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_width="0dp" <TextView
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_weight="0.2" android:layout_height="wrap_content"
android:text="Schedule :
" /> android:layout_weight="0.2"
<EditText android:text="Email : "
/>
style="@style/Base.TextAppearance.AppCompat. <EditText
Subhead"
style="@style/Base.TextAppearance.AppCompat.
android:layout_width="0dp" Subhead"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_weight="0.8" android:layout_height="wrap_content"
android:id="@+id/txtCSchedule" android:layout_weight="0.8"
android:editable="false"
android:id="@+id/txtCEmail"
android:clickable="false" android:editable="false"
android:layout_height="wrap_content" <android.support.v7.widget.CardView
150
card_view:cardCornerRadius="5dp" >
<LinearLayout
Listing 51: res/layout/activity_main.xml
android:id="@+id/linearLayout1"
android:layout_width="fill_parent" <RelativeLayout
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/ap
android:orientation="horizontal"> k/res/android"
xmlns:tools="http://schemas.android.com/tool
</LinearLayout> s"
</android.support.v7.widget.CardView> xmlns:app="http://schemas.android.com/apk/re
s-auto"
</LinearLayout> android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
Listing 50: xmlns:android="http://schemas.android.com/ap
res/layout/activity_list_nearest_clinics.xm k/res/android"
l xmlns:map="http://schemas.android.com/apk/re
s-auto"
<FrameLayout
xmlns:tools="http://schemas.android.com/tool
xmlns:android="http://schemas.android.com/ap
s" tools:context=".MainActivity"
k/res/android"
android:id="@+id/map"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_height="fill_parent">
<LinearLayout
android:name="com.google.android.gms.maps.Ma
android:orientation="horizontal"
pFragment"/>
android:layout_width="fill_parent"
android:layout_height="465dp"
<ImageButton
android:id="@+id/btnShowLocation"
android:id="@+id/layoutNearestClinicsList">
android:src="@drawable/location"
</LinearLayout>
android:layout_width="60dp"
android:layout_height="60dp"
<LinearLayout
android:scaleType="fitCenter"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_above="@+id/linearLayout"
android:layout_height="45dip"
android:weightSum="2"
android:layout_toRightOf="@+id/btnChangeAddr
ess"
android:layout_gravity="center_horizontal|bo
ttom">
android:layout_toEndOf="@+id/btnChangeAddres
<Button
s"
android:layout_width="0dip"
/>
android:layout_height="fill_parent"
android:layout_weight="1"
<TextView
android:text="Map"
android:layout_width="wrap_content"
android:id="@+id/btnMapList2"
android:layout_height="wrap_content"
android:background="@drawable/buttonshape"
android:textAppearance="?android:attr/textAp
android:enabled="false" />
pearanceSmall"
<Button
android:text="Latitude : x,
android:layout_width="0dip"
Longitude : y"
android:layout_height="fill_parent"
android:id="@+id/textView_latLng"
android:layout_weight="1"
android:gravity="center|top"
android:text="List"
android:typeface="sans"
android:id="@+id/btnFilter2"
android:layout_toLeftOf="@+id/btnSearchClini
android:background="@drawable/buttonshape"
c"
android:enabled="false" />
android:layout_alignParentTop="true"
</LinearLayout>
</FrameLayout>
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:textColor="#ffcc5d00"
android:layout_marginTop="10dp"
android:textSize="11sp" />
151
<Button android:textColor="#ff000000" />
android:id="@+id/btnChangeAddress" </LinearLayout>
android:layout_width="wrap_content"
android:layout_height="60dp" <TextView
android:layout_alignParentTop="true" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btnSearchClini
c" android:textAppearance="?android:attr/textAp
pearanceMedium"
android:layout_toStartOf="@+id/btnSearchClin android:text="This is my address"
ic" android:id="@+id/textView_address"
android:layout_alignParentStart="true" android:layout_below="@+id/textView_latLng"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:background="@drawable/buttonshape" android:layout_alignParentStart="true"
android:textAlignment="center" />
android:layout_toLeftOf="@+id/btnSearchClini
<ImageButton c"
android:layout_width="60dp"
android:layout_height="60dp" android:layout_toStartOf="@+id/btnSearchClin
android:src="@drawable/search2" ic"
android:id="@+id/btnSearchClinic" android:typeface="serif"
android:scaleType="fitCenter" android:textAlignment="center"
android:maxLines="1"
android:layout_alignParentRight="true" android:gravity="center|bottom"
android:layout_alignParentEnd="true" android:textStyle="bold"
android:layout_alignParentTop="true"
/> android:layout_alignBottom="@+id/btnChangeAd
dress"
<LinearLayout android:layout_marginBottom="8dp"
android:orientation="horizontal" android:textSize="16sp"
android:layout_width="fill_parent" android:ellipsize="end" />
android:layout_height="45dip" </RelativeLayout>
android:weightSum="2"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
Listing 52:
res/layout/activity_search_map.xml
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true" <fragment
android:id="@+id/linearLayout" xmlns:android="http://schemas.android.com/ap
k/res/android"
android:layout_alignParentRight="false"
xmlns:tools="http://schemas.android.com/tool
android:layout_alignWithParentIfMissing="fal s" android:id="@+id/fragment"
se">
<Button android:name="ph.edu.upm.cjgaleng.spotavet.S
android:layout_width="0dip" earchMapActivityFragment"
android:layout_height="fill_parent" tools:layout="@layout/fragment_search_map"
android:layout_weight="1" android:layout_width="match_parent"
android:text="Map" android:layout_height="match_parent" />
android:id="@+id/btnMapList"
android:background="@drawable/buttonshape"
android:enabled="false" Listing 53: res/layout/
android:textColor="#ff000000" />
<Button activity_vet_info.xml
android:layout_width="0dip"
<RelativeLayout
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/ap
android:layout_weight="1" k/res/android"
android:text="List"
android:id="@+id/btnFilter" xmlns:tools="http://schemas.android.com/tool
s" android:layout_width="match_parent"
android:background="@drawable/buttonshape" android:layout_height="match_parent"
android:enabled="false" android:id="@+id/layoutVetActivity"
152
android:layout_width="fill_parent"
tools:context="ph.edu.upm.cjgaleng.VetInfoAc android:layout_height="wrap_content"
tivity"> />
</RelativeLayout> </LinearLayout>
ml android:layout_below="@id/txtListCName"/>
<LinearLayout </RelativeLayout>
xmlns:android="http://schemas.android.com/ap
k/res/android"
153
android:textAppearance="?android:attr/textAp xmlns:tools="http://schemas.android.com/tool
pearanceLarge" s" android:layout_width="match_parent"
android:text="Veterinarians : " android:layout_height="match_parent"
android:id="@+id/textView" android:paddingLeft="@dimen/activity_horizon
android:background="#ffcc5d00" /> tal_margin"
<ListView android:paddingRight="@dimen/activity_horizo
android:id="@android:id/list" ntal_margin"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:paddingTop="@dimen/activity_vertical
/> _margin"
</LinearLayout> android:paddingBottom="@dimen/activity_verti
cal_margin"
tools:context="ph.edu.upm.cjgaleng.spotavet.
SearchMapActivityFragment">
Listing 59:
res/layout/fragment_listvets_item.xml <!-- City and Country Selector -->
<AutoCompleteTextView
android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?> android:layout_height="wrap_content"
<RelativeLayout android:id="@+id/autocomplete"
xmlns:android="http://schemas.android.com/ap android:hint="Type in your Location"
k/res/android" />
xmlns:tools="http://schemas.android.com/tool <Button
s"
android:layout_width="fill_parent" android:id="@+id/clearable_button_clear"
android:layout_height="wrap_content" android:layout_width="30dip"
android:orientation="vertical" > android:layout_height="30dip"
<TextView android:background="@android:drawable/ic_men
android:id="@+id/txtVName" u_close_clear_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignBottom="@+id/autocomplet
android:paddingTop="8dip" e"
android:paddingLeft="8dip"
android:paddingBottom="4dip" android:layout_alignRight="@+id/autocomplete
android:textSize="20dip" "
android:textStyle="bold" />
android:layout_alignEnd="@+id/autocomplete"
<TextView android:id="@+id/txtVEmail" android:layout_marginRight="11dp"
android:layout_height="wrap_content" android:layout_marginBottom="5dp"
android:layout_width="wrap_content" android:layout_alignParentTop="true"
android:paddingLeft="8dip"
android:paddingBottom="6dip" android:layout_alignParentLeft="false"
android:textSize="15dip"
android:layout_alignParentBottom="false"
android:layout_below="@id/txtVName"/>
android:layout_alignParentRight="true" />
<TextView android:id="@+id/txtVLicense"
android:layout_width="wrap_content" </RelativeLayout>
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:padding="8dip"/>/
Listing 61:
</RelativeLayout>
res/layout/fragment_vetinfo.xml
<LinearLayout
xmlns:android="http://schemas.android.com/ap
Listing 60: k/res/android"
res/layout/fragment_search_map.xml
xmlns:tools="http://schemas.android.com/tool
s"
<RelativeLayout android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/ap android:layout_height="wrap_content"
k/res/android" android:paddingLeft="8dp"
154
android:paddingRight="8dp"
android:paddingTop="8dp" android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/txtCardVLicense"
tools:context="ph.edu.upm.cjgaleng.VetInfoFr android:text="License #
agment"> : PRC# 1234" />
<android.support.v7.widget.CardView <TextView
xmlns:android="http://schemas.android.com/ap style="@style/Base.TextAppearance.AppCompat.
k/res/android" Subhead"
xmlns:card_view="http://schemas.android.com/ android:layout_width="fill_parent"
apk/res-auto"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content"
card_view:contentPadding="16dp" android:id="@+id/txtCardVEmail"
card_view:cardElevation="4dp" android:text="Email :
card_view:cardCornerRadius="5dp" > email@email.com" />
<LinearLayout <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" style="@style/Base.TextAppearance.AppCompat.
android:orientation="vertical"> Subhead"
<LinearLayout android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txtCardVContact"
android:text="Contact #
android:orientation="horizontal"> : 09191234567" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="90dp" </LinearLayout>
android:src="@drawable/defaultimg"
android:layout_weight="0.25" <TextView
android:scaleType="fitXY"/>
style="@style/Base.TextAppearance.AppCompat.
<LinearLayout Subhead"
android:layout_width="0dp"
android:layout_weight="0.8" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Specialization : "
android:layout_marginLeft="10dp" android:textStyle="bold"
android:layout_marginTop="10dp"
android:orientation="vertical"> />
<TextView <TextView
style="@style/Base.TextAppearance.AppCompat. style="@style/Base.TextAppearance.AppCompat.
Headline" Body1"
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:id="@+id/txtCardVName"
android:id="@+id/txtCardVSpecialization"
android:text="Veterinarian Name" /> android:text="Specialization" />
<TextView <TextView
style="@style/Base.TextAppearance.AppCompat. style="@style/Base.TextAppearance.AppCompat.
Subhead" Subhead"
android:layout_width="fill_parent" android:layout_width="fill_parent"
155
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Schedule :"
android:textStyle="bold" />
<TextView
style="@style/Base.TextAppearance.AppCompat.
Body1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:id="@+id/txtCardVSchedule"
android:text="Schedule" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
156
XI. Acknowledgement
Yehey! It’s my turn now to say “Finally”! Yehey dahil siyempre FINALLY tapos ko na
lahat ng comsci subjects ko, konti na lang graduation na weee.. after many years. Also happy ako
kasi freestyle ang page na to, ubos na ubos na kasi English ko from the previous pages.
My Special Problem is indeed an accomplishment for me. Para sa tulad ko na hindi magaling sa
Firstly, I would like to give my big thanks to my adviser Ma’am Sheila, sobrang thank
you po sa paulit ulit niyong pagtanggap sa akin, kahit minsan isang taon bago ako magpakita ulit
sa inyo. Hehe. Isa po kayo sa nakapagpa push sa akin na tapusin ito. Yung mga words niyo po
nakakatulong, though mahina pa rin po talaga ang loob ko sa ganito. Ayuuun tapos na po ang
Sa blockmates ko, salamat sa friendship and everything, nung undergrad years natin or
should I say nung may klase pa tayo. Naenjoy ko ang college life dahil sa inyo. ♥ I admit na
hindi ako masyadong nagpapakita after our supposedly graduation year. Miss na miss ko na
kayong lahat. Pagkatapos nito, sana naaalala niyo pa din ako. Dahil… sasama na ko sa mga
outings, YAY. Tagal ko na naiinggit gusto ko talaga sumama Thank you mommy JJ, Auradee
lobster, sa paulit ulit na pag-aya sa akin kahit ang madalas kong sagot ay no. Tina, Hii
Rialabs!!!! Kayo yung mga paulit ulit nangangamusta sakin kahit di ako nakakapagreply. See
Ate Naji, JM, Gela, Patrick, Luwi, Ian, magkikita tayo after this.. I insist. I need to catch
up with you guysss. Pero sagot niyo muna food and “tea?”, bigtime na kayo e :D
Keisha, Lorielyn, Axl, thank you din sa pag motivate sa aking tapusin to, I will meet you
all soon.
157
Mica, piggie frieeend, thank you ng marami sa morale support, food support, words
support sa pagsusulat ng papers, haha lahat na. You’ve been there for me from the start of my
final topic (haha) and never left me, kahit ilang breakdown na at pagpapanic na ang nangyari sa
akin. Your friendship means so much to me. Ililibre kita after this, woo.
sobrang tagal na din pala to nasakin. At kita mo na, pati yung laptop ang lawak na ng ngiti for
me. Ipapaayos ko na lang to pag kaya pang ayusin. Goodluck sa remaining years mo sa BS
Nursing. Mag grad ka ng regular ah, sumablay ka sa 2017, wag mo ko tularan hehe. Make us
Mama, Tatay, eto na po, pagkatapos ng ilang taon niyong pangungulit, this is for you.
Kahit nagtampo po ako nung una kasi pinagresign niyo ako para tapusin ang SP, ehh gusto ko pa
nga magwork. Pero narealize ko naman para sakin din talaga yun, para magkaroon ako ng
diploma. Salamat po sa lahat, sa pagpapaaral, sa allowances, sa trust. Mama, sorry kung wala
ako masyado time makipag-usap sa bahay lately. Pero thank you sa paglalaba ng ilan kong gamit
lately, dahil wala na akong time maglaba. I love you mama. ♥ Be strong, and always be healthy,
Mama. Masusuot mo na yung mga binili mong damit, mama donya. Advanced happy birthday
Tay, I think this is the best gift I could give you on Father’s day. Lolol. Eto sana yung
birthday gift ko sa’yo.. kaso naudlot. Hehe ang mahalaga naman po diba tapos na? Diba po?
Hehe. Finally eto na po nakapagpatapos na kayo. Eto na po yung dream niyo na makagraduate. I
158