<commit_before><?php
/* * *****************************************************************************
 *
 *  filename    : GroupReports.php
 *  last change : 2003-09-03
 *  description : Detailed reports on group members
 *
 *  http://www.churchcrm.io/
 *  Copyright 2003 <NAME>, <NAME>
 *  Copyright 2004-2012 <NAME>
 *
 *  ChurchCRM is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 * **************************************************************************** */

// Include the function library
require "Include/Config.php";
require "Include/Functions.php";

// Get all the groups
$sSQL = "SELECT * FROM group_grp ORDER BY grp_Name";
$rsGroups = RunQuery($sSQL);

// Set the page title and include HTML header
$sPageTitle = gettext("Group reports");
require "Include/Header.php";
?>

<script type="text/javascript">
    var IFrameObj; // our IFrame object

    function UpdateRoles()
    {
        var group_ID = document.getElementById('GroupID').value;
        if (!document.createElement) {
            return true
        }
        ;
        var IFrameDoc;
        var URL = 'RPCdummy.php?mode=GroupRolesSelect&data=' + group_ID;
        if (!IFrameObj && document.createElement) {
            var tempIFrame = document.createElement('iframe');
            tempIFrame.setAttribute('id', 'RSIFrame');
            tempIFrame.style.border = '0px';
            tempIFrame.style.width = '0px';
            tempIFrame.style.height = '0px';
            IFrameObj = document.body.appendChild(tempIFrame);

            if (document.frames) {
                // For IE5 Mac
                IFrameObj = document.frames['RSIFrame'];
            }
        }

        if (navigator.userAgent.indexOf('Gecko') != -1
                && !IFrameObj.contentDocument) {
            // For NS6
            setTimeout('AddToCart()', 10);
            return false;
        }

        if (IFrameObj.contentDocument) {
            // For NS6
            IFrameDoc = IFrameObj.contentDocument;
        } else if (IFrameObj.contentWindow) {
            // For IE5.5 and IE6
            IFrameDoc = IFrameObj.contentWindow.document;
        } else if (IFrameObj.document) {
            // For IE5
            IFrameDoc = IFrameObj.document;
        } else {
            return true;
        }

        IFrameDoc.location.replace(URL);
        return false;
    }

    function updateGroupRoles(generated_html)
    {
        if (generated_html == "invalid") {
            document.getElementById('GroupRole').innerHTML = <?= '\'<p class="LargeError">' . gettext("Invalid Group or No Roles Available!") . '<p>\';'; ?>
        } else {
            document.getElementById('GroupRole').innerHTML = generated_html;
        }
    }
</script>

<?php if (!isset($_POST["GroupID"])) { ?>
    <div class="row">
        <div class="box col-lg-4 col-xs-4">
            <div class="box-header with-border">
                <h3 class="box-title"><?= gettext("Select the group you would like to report:") ?></h3>
            </div>
            <div class="box-body">
                <form method="POST" action="GroupReports.php">
                    <div class="row">
                        <div class="col-xs-6">
                            <label for="GroupID"><?= gettext("Select Group:") ?></label>
                            <select id="GroupID" name="GroupID" onChange="UpdateRoles();">
                                <?php
                                // Create the group select drop-down
                                echo "<option value=\"0\">" . gettext('None') . "</option>";
                                while ($aRow = mysql_fetch_array($rsGroups)) {
                                    extract($aRow);
                                    echo "<option value=\"" . $grp_ID . "\">" . $grp_Name . "</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
                            <label for=""><?= gettext("Select Role:") ?></label>
                            <span id="GroupRole"><?= gettext("No Group Selected") ?></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
                            <label for="OnlyCart"><?= gettext("Only cart persons?:") ?></label>
                            <input type="checkbox" Name="OnlyCart" value="1">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
                            <label for="ReportModel"><?= gettext("Report Model:") ?></label>
                            <input type="radio" Name="ReportModel" value="1" checked><?= gettext("Report for group and role selected") ?><br>
                            <input type="radio" Name="ReportModel" value="2"><?= gettext("Report for any role in group selected") ?><br>
                            <?php
                            //<input type="radio" Name="ReportModel" value="3"><?= gettext("Report any group and role")  
                            ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6"><commit_msg>GroupReports role listing now uses API call to /api/groups/:groupID<commit_after><?php
/* * *****************************************************************************
 *
 *  filename    : GroupReports.php
 *  last change : 2003-09-03
 *  description : Detailed reports on group members
 *
 *  http://www.churchcrm.io/
 *  Copyright 2003 <NAME>, <NAME>
 *  Copyright 2004-2012 <NAME>
 *
 *  ChurchCRM is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 * **************************************************************************** */

// Include the function library
require "Include/Config.php";
require "Include/Functions.php";

// Get all the groups
$sSQL = "SELECT * FROM group_grp ORDER BY grp_Name";
$rsGroups = RunQuery($sSQL);

// Set the page title and include HTML header
$sPageTitle = gettext("Group reports");
require "Include/Header.php";
?>

<script type="text/javascript">
    function UpdateRoles()
    {
        var group_ID = $('#GroupID option:selected').val();  // get the selected group ID
       $.ajax({
            method: "GET",
            url:   window.CRM.root+"/api/groups/"+group_ID,
        }).done(function(data){
           var defaultRole=data.groups.grp_DefaultRole;
           var html ="";
           $.each(data.groups.roles, function(index,value){
                html +="<option value=\"" + value.lst_OptionID + "\"";
                if (value.lst_OptionID === defaultRole ) {
                    html += " selected";
                }
		html+=">" + value.lst_OptionName + "</option>";
           });
           $("#GroupRole").html(html);
        });
    }
</script>

<?php if (!isset($_POST["GroupID"])) { ?>
    <div class="row">
        <div class="box col-lg-4 col-xs-4">
            <div class="box-header with-border">
                <h3 class="box-title"><?= gettext("Select the group you would like to report:") ?></h3>
            </div>
            <div class="box-body">
                <form method="POST" action="GroupReports.php">
                    <div class="row">
                        <div class="col-xs-6">
                            <label for="GroupID"><?= gettext("Select Group:") ?></label>
                            <select id="GroupID" name="GroupID" onChange="UpdateRoles();">
                                <?php
                                // Create the group select drop-down
                                echo "<option value=\"0\">" . gettext('None') . "</option>";
                                while ($aRow = mysql_fetch_array($rsGroups)) {
                                    extract($aRow);
                                    echo "<option value=\"" . $grp_ID . "\">" . $grp_Name . "</option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
                            <label for=""><?= gettext("Select Role:") ?></label>
                            <select name="GroupRole" id="GroupRole">
                                <option><?= gettext("No Group Selected") ?></option>
                            </select>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
                            <label for="OnlyCart"><?= gettext("Only cart persons?:") ?></label>
                            <input type="checkbox" Name="OnlyCart" value="1">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <label for="ReportModel"><?= gettext("Report Model:") ?></label>
                            <input type="radio" Name="ReportModel" value="1" checked><?= gettext("Report for group and role selected") ?>
                            <input type="radio" Name="ReportModel" value="2"><?= gettext("Report for any role in group selected") ?>
                            <?php
                            //<input type="radio" Name="ReportModel" value="3"><?= gettext("Report any group and role")  
                            ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6">
{'fraction_non_alphanumeric': 0.16527052330738148, 'fraction_numerical': 0.008278308859761507, 'mean_word_length': 1.4995073891625617, 'pattern_counts': {'":': 0, '<': 140, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7559378', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2524, 'n_words': 633}