Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature remove ajax #102

Merged
merged 9 commits into from
Dec 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions churchinfo/Include/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,52 @@
<script language="javascript" type="text/javascript">
$("document").ready(function(){
$(".searchPerson").autocomplete({
source: "ajax/SearchMembers.php?searchtype=person",
minLength: 2,
select: function(event, ui) {
var location = 'PersonView.php?PersonID='+ui.item.id;
window.location.replace(location);
$('#add_per_ID').val(ui.item.id);
}
source: function (request, response) {
$.ajax({
url: 'api/persons/search/'+request.term,
dataType: 'json',
type: 'GET',
success: function (data) {
response($.map(data.persons, function (item) {
return {
label: item.fullName,
value: item.id
}
}));
}
})
},
select: function (event, ui) {
var location = 'PersonView.php?PersonID='+ui.item.value;
window.location.replace(location);
return false;
},
minLength: 2
});

$(".searchFamily").autocomplete({
source: function (request, response) {
$.ajax({
url: 'api/families/search/'+request.term,
dataType: 'json',
type: 'GET',
success: function (data) {
response($.map(data.families, function (item) {
return {
label: item.displayName,
value: item.id
}
}));
}
})
},
select: function (event, ui) {
var location = 'FamilyView.php?FamilyID='+ui.item.value;
window.location.replace(location);
return false;
},
minLength: 2
});
});
</script>
</body>
Expand Down
10 changes: 8 additions & 2 deletions churchinfo/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,26 @@


<div class="row">
<div class="col-lg-12 col-md-6 col-sm-4">
<div class="col-lg-6 col-md-3 col-sm-4">
<div class="box box-solid">
<div class="box-body clearfix">
<i class="fa fa-search"></i><input type="text" class="search searchPerson" placeholder="Search..." onfocus="ClearFieldOnce(this);"/>

<a href="PersonEditor.php" class="btn btn-primary">
<i class="fa fa-plus-circle fa-md"></i> Add Person
</a>
</div>
</div>
</div>
<div class="col-lg-6 col-md-3 col-sm-4">
<div class="box box-solid">
<div class="box-body clearfix">
<i class="fa fa-search"></i><input type="text" class="search searchFamily" placeholder="Search..." onfocus="ClearFieldOnce(this);"/>

<a href="FamilyEditor.php" class="btn btn-primary">
<i class="fa fa-plus-circle fa-md"></i> Add Family
</a>
</div>
</header>
</div>
</div>
</div>
Expand Down
21 changes: 17 additions & 4 deletions churchinfo/PledgeEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,22 @@
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#FamilyName").autocomplete({
source: "../ajax/SearchMembers.php?f=famlist_s",
minLength: 3,
source: function (request, response) {
$.ajax({
url: 'api/families/search/'+request.term,
dataType: 'json',
type: 'GET',
success: function (data) {
response($.map(data.families, function (item) {
return {
value: item.displayName,
id: item.id
}
}));
}
})
},
minLength: 2,
select: function(event,ui) {
$('[name=FamilyName]').val(ui.item.value);
$('[name=FamilyID]:eq(1)').val(ui.item.id);
Expand All @@ -659,8 +673,7 @@
});
</script>
<input style='width:350px;' type="text" id="FamilyName" name="FamilyName" value='<?php echo $sFamilyName; ?>' />
<input type="hidden" name="FamilyID" value='<?php echo $iFamily; ?>'>
</select>
<input type="hidden" id="FamilyID" name="FamilyID" value='<?php echo $iFamily; ?>'>
</td>
</tr>

Expand Down
30 changes: 0 additions & 30 deletions churchinfo/ajax/LastEditedFamilies.php

This file was deleted.

52 changes: 0 additions & 52 deletions churchinfo/ajax/SearchFamily.php

This file was deleted.

52 changes: 0 additions & 52 deletions churchinfo/ajax/SearchMembers.php

This file was deleted.

2 changes: 1 addition & 1 deletion churchinfo/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
});

$app->group('/families', function () use ($app) {
$app->get('/:query', function ($query) use ($app) {
$app->get('/search/:query', function ($query) use ($app) {
try {
$app->FamilyService->search($query);
} catch (Exception $e) {
Expand Down
4 changes: 3 additions & 1 deletion churchinfo/api/services/FamilyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function search($searchTerm) {
$families = array();
while($row=mysql_fetch_array($result)) {
$row_array['id']=$row['fam_ID'];
$row_array['fam_name']=$row['fam_Name'];
$row_array['familyName']=$row['fam_Name'];
$row_array['city']=$row['fam_City'];
$row_array['displayName']=$row['fam_Name']." - ".$row['fam_City'];

array_push($families,$row_array);
}
Expand Down
10 changes: 5 additions & 5 deletions churchinfo/api/services/PersonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ function getGravatar($email, $s = 60, $d = '404', $r = 'g', $img = false, $atts

function search($searchTerm)
{
$fetch = 'SELECT per_ID, per_FirstName, per_LastName, CONCAT_WS(" ",per_FirstName,per_LastName) AS fullname, per_fam_ID FROM person_per WHERE per_FirstName LIKE \'%' . $searchTerm . '%\' OR per_LastName LIKE \'%' . $searchTerm . '%\' OR per_Email LIKE \'%' . $searchTerm . '%\' OR CONCAT_WS(" ",per_FirstName,per_LastName) LIKE \'%' . $searchTerm . '%\' LIMIT 15';
$fetch = 'SELECT per_ID, per_FirstName, per_LastName, CONCAT_WS(" ",per_FirstName,per_LastName) AS fullname, per_fam_ID FROM person_per WHERE per_FirstName LIKE \'%' . $searchTerm . '%\' OR per_LastName LIKE \'%' . $searchTerm . '%\' OR per_Email LIKE \'%' . $searchTerm . '%\' OR CONCAT_WS(" ",per_FirstName,per_LastName) LIKE \'%' . $searchTerm . '%\' order by per_FirstName LIMIT 15';
$result = mysql_query($fetch);

$return = array();
while ($row = mysql_fetch_array($result)) {
$values['id'] = $row['per_ID'];
$values['famID'] = $row['per_fam_ID'];
$values['per_FirstName'] = $row['per_FirstName'];
$values['per_LastName'] = $row['per_LastName'];
$values['value'] = $row['per_FirstName'] . " " . $row['per_LastName'];
$values['familyID'] = $row['per_fam_ID'];
$values['firstName'] = $row['per_FirstName'];
$values['lastName'] = $row['per_LastName'];
$values['fullName'] = $row['per_FirstName'] . " " . $row['per_LastName'];

array_push($return, $values);
}
Expand Down
11 changes: 9 additions & 2 deletions docs/API/Endpoint Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
ChurchCRM leverages Slim 2.6.2 to provide REST access to the data elements.

## People
* [GET] /members/list/search/:query
* [GET] /api/persons/search/:query
* Returns a list of the members who's first name or last name matches the :query parameter

* [GET] /api/persons/:id/photo
* Returns a the correct photo for that person for a person with the :id value

## Families
No API Calls yet for Families
* [GET] /api/families/search/:query
* Returns a list of the families who's name matches the :query parameter

* [GET] /api/families/lastedited
* Returns a the last 10 updated families

## Deposits
No API Calls yet for Deposits
Expand Down