Skip to content

Commit

Permalink
New Group settings - Active/Email Export (#2009)
Browse files Browse the repository at this point in the history
* moved group to ORM

* fixed cleanup error

* Apply fixes from StyleCI (#1866)

* adding isActive & EnableEmailExport flags to the DB

starting #1846

* added default values

* added 2.6.0-groups.sql

* fixed sql error

* correct line fixed

* style cleanup

* added bootstrap-toggle

* Apply fixes from StyleCI (#2006)

* more style cleanup

* using toggle buttons to show current db status

* removed extra breaks

* Apply fixes from StyleCI (#2007)

* JS cleanup

single script and document .ready func

* added API/Calls to taggel status and email export

added the api
added ajax class to call new APIs on button toggle

* revert MemberEmailExport.php

* fixed bad merge

* added group setttings
  • Loading branch information
DawoudIO authored Feb 27, 2017
1 parent 729b7f8 commit eb0f2c6
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ src/skin/churchcrm.min.css
src/skin/jquery-photo-uploader
src/skin/randomcolor
src/skin/bootbox
src/skin/bootstrap-toggle

# Configuration files with passwords
src/Include/Config.php
Expand Down
7 changes: 7 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ module.exports = function (grunt) {
flatten: true,
src: ['node_modules/bootbox/bootbox.min.js'],
dest: 'src/skin/bootbox/'
},
{
expand: true,
filter: 'isFile',
flatten: true,
src: ['node_modules/bootstrap-toggle/css/bootstrap-toggle.css', 'node_modules/bootstrap-toggle/js/bootstrap-toggle.js'],
dest: 'src/skin/bootstrap-toggle/'
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions docs/API/Endpoint Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ ChurchCRM leverages Slim 2.6.2 to provide REST access to the data elements.
* requires JSON in the POST body with roleID set to the ID of the user's role in the specified group
* [POST] /api/:groupID/setGroupSpecificPropertyStatus
* requires JSON property GroupSpecificPropertyStatus either true or false
* [POST] /api/:groupID/settings/active/{true/false}
* sets the status to true or false
* [POST] /api/:groupID/settings/email/export/{true/false}
* sets the email export status to true or false



Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"font-awesome": "4.7.0",
"fullcalendar": "3.0.1",
"jquery-photo-uploader": "1.0.9",
"initial-js": "0.3.4"
"initial-js": "0.3.4",
"bootstrap-toggle": "2.2.2"
},
"scripts": {
"install": "grunt clean && grunt updateVersions && grunt curl-dir && grunt copy && grunt sass",
Expand Down
2 changes: 2 additions & 0 deletions propel/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@
<column name="grp_Name" phpName="Name" type="VARCHAR" size="50" required="true" defaultValue=""/>
<column name="grp_Description" phpName="Description" type="LONGVARCHAR"/>
<column name="grp_hasSpecialProps" phpName="HasSpecialProps" type="BOOLEAN" defaultValue="0"/>
<column name="grp_active" phpName="Active" type="BOOLEAN" size="1" required="true"/>
<column name="grp_include_email_export" phpName="IncludeInEmailExport" type="BOOLEAN" size="1" required="true"/>
<foreign-key foreignTable="list_lst">
<reference local="grp_Type" foreign="lst_OptionID"/>
</foreign-key>
Expand Down
79 changes: 43 additions & 36 deletions src/GroupView.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if ($_SESSION['bManageGroups']) {
echo '<a class="btn btn-app" href="GroupEditor.php?GroupID=' . $thisGroup->getId() . '"><i class="fa fa-pencil"></i>' . gettext('Edit this Group') . '</a>';
echo '<button class="btn btn-app" id="deleteGroupButton"><i class="fa fa-trash"></i>' . gettext('Delete this Group') . '</button>'; ?>


<!-- MEMBER ROLE MODAL-->
<div class="modal fade" id="changeMembership" tabindex="-1" role="dialog" aria-labelledby="deleteGroup" aria-hidden="true">
Expand Down Expand Up @@ -253,43 +253,49 @@
</div>
</div>

<div class="box">
<div class="box-body">
<?= $thisGroup->getDescription() ?>
<p/><p/><p/>
<button class="btn btn-success" type="button">
<?= gettext('Type of Group') ?> <span class="badge"> <?= $sGroupType ?> </span>
</button>
<button class="btn btn-info" type="button">
<?php if (!is_null($defaultRole)) {
?>
<?= gettext('Default Role') ?> <span class="badge"><?= $defaultRole->getOptionName() ?></span>
<?php

} ?>
</button>
<button class="btn btn-primary" type="button">
<?= gettext('Total Members') ?> <span class="badge" id="iTotalMembers"></span>
</button>
</div>
</div>


<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><?= gettext('Group Properties') ?></h3>
<h3 class="box-title"><?= gettext('Quick Settings') ?></h3>
</div>
<div class="box-body">
<form>
<div class="col-sm-3"> <b><?= gettext('Status') ?>:</b> <input data-size="small" id="isGroupActive" type="checkbox" data-toggle="toggle" data-on="<?= gettext('Active') ?>" data-off="<?= gettext('Disabled') ?>"> </div>
<div class="col-sm-3"> <b><?= gettext('Email export') ?>:</b> <input data-size="small" id="isGroupEmailExport" type="checkbox" data-toggle="toggle" data-on="<?= gettext('Include') ?>" data-off="<?= gettext('Exclude') ?>"></div>
</form>
</div>
</div>

<table border="0" width="100%" cellspacing="0" cellpadding="5">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><?= gettext('Group Properties') ?></h3>
</div>
<div class="box-body">
<table width="100%">
<tr>
<td width="25%" valign="top" align="center">
<div class="LightShadedBox">
<b class="LargeText"><?= $thisGroup->getName() ?></b>
<br>
<?= $thisGroup->getDescription(); ?>
<br><br>
<table width="98%">
<tr>
<td align="center"><div class="TinyShadedBox"><font size="3">
<?= gettext('Total Members:') ?><span id="iTotalMembers"></span>
<br>
<?= gettext('Type of Group:') ?> <?= $sGroupType ?>
<br>
<?php if (!is_null($defaultRole)) {
?>
<?= gettext('Default Role:') ?> <?= $defaultRole->getOptionName() ?>
<?php
} ?>
</font></div></td>
</tr>
</table>
</div>
</td>
<td width="75%" valign="top" align="left">

<b><?= gettext('Group-Specific Properties:') ?></b>
<td>
<b><?= gettext('Group-Specific Properties') ?>:</b>

<?php
if ($thisGroup->getHasSpecialProps()) {
Expand Down Expand Up @@ -333,14 +339,14 @@
}

//Print Assigned Properties
echo '<br>';
echo '<b>'.gettext('Assigned Properties:').'</b>';
echo '<br><hr/>';
echo '<b>'.gettext('Assigned Properties').':</b>';
$sAssignedProperties = ',';

//Was anything returned?
if (mysqli_num_rows($rsAssignedProperties) == 0) {
// No, indicate nothing returned
echo '<p align="center">'.gettext('No property assignments.').'</p>';
echo '<p>'.gettext('No property assignments').'.</p>';
} else {
// Display table of properties
?>
Expand Down Expand Up @@ -411,7 +417,7 @@

if ($_SESSION['bManageGroups']) {
echo '<form method="post" action="PropertyAssign.php?GroupID='.$iGroupID.'">';
echo '<p align="center">';
echo '<p>';
echo '<span>'.gettext('Assign a New Property:').'</span>';
echo '<select name="PropertyID">';

Expand All @@ -425,7 +431,7 @@
}

echo '</select>';
echo '<input type="submit" class="btn" value="'.gettext('Assign').'" name="Submit" style="font-size: 8pt;">';
echo ' <input type="submit" class="btn btn-success" value="'.gettext('Assign').'" name="Submit" style="font-size: 8pt;">';
echo '</p></form>';
} else {
echo '<br><br><br>';
Expand Down Expand Up @@ -479,11 +485,12 @@
</form>
</div>
</div>

<script>
window.CRM.currentGroup = <?= $iGroupID ?>;
var dataT = 0;
$(document).ready(function() {
$(document).ready(function () {
$('#isGroupActive').prop('checked', <?= $thisGroup->isActive()? 'true': 'false' ?>).change();
$('#isGroupEmailExport').prop('checked', <?= $thisGroup->isIncludeInEmailExport()? 'true': 'false' ?>).change();
$("#deleteGroupButton").click(function() {
console.log("click");
bootbox.confirm({
Expand Down
1 change: 1 addition & 0 deletions src/Include/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@

<script src="<?= SystemURLs::getRootPath() ?>/skin/bootbox/bootbox.min.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/fastclick/fastclick.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/bootstrap-toggle/bootstrap-toggle.js"></script>

<script src="<?= SystemURLs::getRootPath() ?>/skin/js/ShowAge.js"></script>
<script src="<?= SystemURLs::getRootPath() ?>/skin/js/IssueReporter.js"></script>
Expand Down
34 changes: 34 additions & 0 deletions src/api/routes/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,38 @@
echo json_encode(['status' => 'group specific properties disabled']);
}
});

$this->post('/{groupID:[0-9]+}/settings/active/{value}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$flag = $args['value'];
if ($flag == "true" || $flag == "false") {
$group = GroupQuery::create()->findOneById($groupID);
if ($group != null) {
$group->setActive($flag);
$group->save();
} else {
return $response->withStatus(500)->withJson(['status' => "error", 'reason' => 'invalid group id']);
}
return $response->withJson(['status' => "success"]);
} else {
return $response->withStatus(500)->withJson(['status' => "error", 'reason' => 'invalid status value']);
}
});

$this->post('/{groupID:[0-9]+}/settings/email/export/{value}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$flag = $args['value'];
if ($flag == "true" || $flag == "false") {
$group = GroupQuery::create()->findOneById($groupID);
if ($group != null) {
$group->setIncludeInEmailExport($flag);
$group->save();
} else {
return $response->withStatus(500)->withJson(['status' => "error", 'reason' => 'invalid group id']);
}
return $response->withJson(['status' => "success"]);
} else {
return $response->withStatus(500)->withJson(['status' => "error", 'reason' => 'invalid export value']);
}
});
});
2 changes: 2 additions & 0 deletions src/mysql/install/Install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ CREATE TABLE `group_grp` (
`grp_Name` varchar(50) NOT NULL default '',
`grp_Description` text,
`grp_hasSpecialProps` BOOLEAN NOT NULL default 0,
`grp_active` BOOLEAN NOT NULL default 1,
`grp_include_email_export` BOOLEAN NOT NULL default 1,
PRIMARY KEY (`grp_ID`),
UNIQUE KEY `grp_ID` (`grp_ID`),
KEY `grp_ID_2` (`grp_ID`)
Expand Down
15 changes: 8 additions & 7 deletions src/mysql/upgrade.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@
"dbVersion":"2.6.0"
},
"current": {
"versions":[
"2.6.0"
],
"scripts":[
],
"dbVersion": "2.7.0"
"versions": [
"2.6.0"
],
"scripts":[
"/mysql/upgrade/2.7.0-groups.sql"
],
"dbVersion": "2.7.0"
}
}
}
3 changes: 3 additions & 0 deletions src/mysql/upgrade/2.7.0-groups.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE group_grp
ADD COLUMN grp_active BOOLEAN NOT NULL DEFAULT 1 AFTER grp_hasSpecialProps,
ADD COLUMN grp_include_email_export BOOLEAN NOT NULL DEFAULT 1 AFTER grp_active;
1 change: 1 addition & 0 deletions src/skin/churchcrm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@import 'adminlte/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css';


@import 'bootstrap-toggle/bootstrap-toggle.css';
@import 'fullcalendar/fullcalendar.min.css';
@import 'fullcalendar/fullcalendar.print.css' print;

Expand Down
24 changes: 21 additions & 3 deletions src/skin/js/GroupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ $(document).ready(function () {
},
callback: function (result)
{
if (result)
if (result)
{
$.each(deletedRows, function (index, value) {
$.ajax({
Expand Down Expand Up @@ -132,7 +132,7 @@ $(document).ready(function () {
})
};
$.ajax({
type: 'POST',
type: 'POST',
url: window.CRM.root + '/api/cart/',
dataType: 'json',
contentType: "application/json",
Expand All @@ -146,7 +146,7 @@ $(document).ready(function () {
}

});

//copy membership
$("#addSelectedToGroup").click(function () {
$("#selectTargetGroupModal").modal("show");
Expand Down Expand Up @@ -306,6 +306,24 @@ function initDataTable() {
}
});

$('#isGroupActive').change(function() {
$.ajax({
type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
url: window.CRM.root + '/api/groups/' + window.CRM.currentGroup + '/settings/active/' + $(this).prop('checked'),
dataType: 'json', // what type of data do we expect back from the server
encode: true
});
});

$('#isGroupEmailExport').change(function() {
$.ajax({
type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
url: window.CRM.root + '/api/groups/' + window.CRM.currentGroup + '/settings/email/export/' + $(this).prop('checked'),
dataType: 'json', // what type of data do we expect back from the server
encode: true
});
});

$(document).on('click', '.groupRow', function () {
$(this).toggleClass('selected');
var selectedRows = dataT.rows('.selected').data().length;
Expand Down

0 comments on commit eb0f2c6

Please sign in to comment.