Skip to content

Commit

Permalink
Merge pull request #2538 from phili67/phili67-sql-update-queryview
Browse files Browse the repository at this point in the history
src/v2/templates/query/queryview.php : mise à jour
  • Loading branch information
phili67 authored Feb 12, 2024
2 parents de4a647 + 036c2ba commit 296bff9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/mysql/install/Install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,9 @@ INSERT INTO `queryparameters_qrp` (`qrp_ID`, `qrp_qry_ID`, `qrp_Type`, `qrp_Opti
(100, 100, 2, 'SELECT vol_ID AS Value, vol_Name AS Display FROM volunteeropportunity_vol ORDER BY vol_Name', 'Volunteer opportunities', 'First volunteer opportunity choice', 'volopp1', '1', 1, 0, '', 12, 1, 1, 2),
(101, 100, 2, 'SELECT vol_ID AS Value, vol_Name AS Display FROM volunteeropportunity_vol ORDER BY vol_Name', 'Volunteer opportunities', 'Second volunteer opportunity choice', 'volopp2', '1', 1, 0, '', 12, 1, 1, 2),
(200, 200, 2, 'SELECT custom_field as Value, custom_Name as Display FROM person_custom_master', 'Custom field', 'Choose customer person field', 'custom', '1', 0, 0, '', 0, 0, 0, 0),
(201, 200, 0, '', 'Field value', 'Match custom field to this value', 'value', '1', 0, 0, '', 0, 0, 0, 0);
(201, 200, 0, '', 'Field value', 'Match custom field to this value', 'value', '1', 0, 0, '', 0, 0, 0, 0),
(202, 201, 2, 'SELECT custom_field as Value, custom_Name as Display FROM person_custom_master', 'Custom field', 'Choose customer person field', 'custom', '1', 0, 0, '', 0, 0, 0, 0),
(203, 201, 0, '', 'Field value', 'Match custom field to this value', 'value', '1', 0, 0, '', 0, 0, 0, 0);

-- --------------------------------------------------------

Expand Down Expand Up @@ -1161,7 +1163,8 @@ INSERT INTO `query_qry` (`qry_ID`, `qry_SQL`, `qry_Name`, `qry_Description`, `qr
(37, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM `person_per` AS a WHERE per_confirm_report='Done';", 'Done confirmation of persons', 'Look for person who have confirmed', 1, 1),
(38, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM person_per AS a WHERE `per_fam_ID` IN (SELECT F.fam_ID FROM `family_fam` AS F WHERE F.fam_confirm_report='Done');", 'Done confirmation of families', 'Look for families who have confirmed', 1, 1),
(100, 'SELECT a.per_ID as AddToCart, CONCAT(''<a href=v2/people/person/view/'',a.per_ID,''>'',a.per_FirstName,'' '',a.per_LastName,''</a>'') AS Name, a.per_DateDeactivated as ''GDPR'' FROM person_per AS a LEFT JOIN person2volunteeropp_p2vo p2v1 ON (a.per_id = p2v1.p2vo_per_ID AND p2v1.p2vo_vol_ID = ~volopp1~) LEFT JOIN person2volunteeropp_p2vo p2v2 ON (a.per_id = p2v2.p2vo_per_ID AND p2v2.p2vo_vol_ID = ~volopp2~) WHERE p2v1.p2vo_per_ID=p2v2.p2vo_per_ID ORDER BY per_LastName', 'Volunteers', 'Find volunteers for who match two specific opportunity codes', 1, 6),
(200, 'SELECT a.per_ID as AddToCart, CONCAT(''<a href=v2/people/person/view/'',a.per_ID,''>'',a.per_FirstName,'' '',a.per_LastName,''</a>'') AS Name, a.per_DateDeactivated as ''GDPR'' FROM person_per AS a LEFT JOIN person_custom pc ON a.per_id = pc.per_ID WHERE pc.~custom~ LIKE ''%~value~%'' ORDER BY per_LastName', 'CustomSearch', 'Find people with a custom field value', 1, 7);
(200, 'SELECT a.per_ID as AddToCart, CONCAT(''<a href=v2/people/person/view/'',a.per_ID,''>'',a.per_FirstName,'' '',a.per_LastName,''</a>'') AS Name, a.per_DateDeactivated as ''GDPR'' FROM person_per AS a LEFT JOIN person_custom pc ON a.per_id = pc.per_ID WHERE pc.~custom~ LIKE ''%~value~%'' ORDER BY per_LastName', 'CustomSearch', 'Find people with a custom field value', 1, 7),
(201, 'SELECT a.per_ID as AddToCart, CONCAT(''<a href=v2/people/person/view/'',a.per_ID,''>'',a.per_FirstName,'' '',a.per_LastName,''</a>'') AS Name, a.per_DateDeactivated as ''GDPR'' FROM person_per AS a LEFT JOIN person_custom pc ON a.per_id = pc.per_ID WHERE pc.~custom~ IS ~value~ ORDER BY per_LastName', 'CustomSearch is NULL', 'Find people with a custom field value is NULL', 1, 7);


-- --------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion src/mysql/upgrade/8.0.0-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,11 @@ INSERT INTO `query_qry` (`qry_ID`, `qry_SQL`, `qry_Name`, `qry_Description`, `qr
(35, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM `person_per` AS a WHERE per_confirm_report='pending';", 'Awaiting confirmation of persons', 'Find person who are in pending confirmation process', 1, 1),
(36, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM person_per AS a WHERE `per_fam_ID` IN (SELECT F.fam_ID FROM `family_fam` AS F WHERE F.fam_confirm_report='pending');", 'Awaiting confirmation of families', 'Find families who are in pending confirmation process', 1, 1),
(37, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM `person_per` AS a WHERE per_confirm_report='Done';", 'Done confirmation of persons', 'Look for person who have confirmed', 1, 1),
(38, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM person_per AS a WHERE `per_fam_ID` IN (SELECT F.fam_ID FROM `family_fam` AS F WHERE F.fam_confirm_report='Done');", 'Done confirmation of families', 'Look for families who have confirmed', 1, 1);
(38, "SELECT a.per_ID as AddToCart, per_Email as Email, CONCAT('<a href=v2/people/person/view/',a.per_ID,'>',a.per_FirstName,' ',a.per_LastName,'</a>') AS Name, a.per_DateDeactivated as 'GDPR' FROM person_per AS a WHERE `per_fam_ID` IN (SELECT F.fam_ID FROM `family_fam` AS F WHERE F.fam_confirm_report='Done');", 'Done confirmation of families', 'Look for families who have confirmed', 1, 1);

INSERT INTO `queryparameters_qrp` (`qrp_ID`, `qrp_qry_ID`, `qrp_Type`, `qrp_OptionSQL`, `qrp_Name`, `qrp_Description`, `qrp_Alias`, `qrp_Default`, `qrp_Required`, `qrp_InputBoxSize`, `qrp_Validation`, `qrp_NumericMax`, `qrp_NumericMin`, `qrp_AlphaMinLength`, `qrp_AlphaMaxLength`) VALUES
(202, 201, 2, 'SELECT custom_field as Value, custom_Name as Display FROM person_custom_master', 'Custom field', 'Choose customer person field', 'custom', '1', 0, 0, '', 0, 0, 0, 0),
(203, 201, 0, '', 'Field value', 'Match custom field to this value', 'value', '1', 0, 0, '', 0, 0, 0, 0);

INSERT INTO `query_qry` (`qry_ID`, `qry_SQL`, `qry_Name`, `qry_Description`, `qry_Count`, `qry_Type_ID`) VALUES
(201, 'SELECT a.per_ID as AddToCart, CONCAT(''<a href=v2/people/person/view/'',a.per_ID,''>'',a.per_FirstName,'' '',a.per_LastName,''</a>'') AS Name, a.per_DateDeactivated as ''GDPR'' FROM person_per AS a LEFT JOIN person_custom pc ON a.per_id = pc.per_ID WHERE pc.~custom~ IS ~value~ ORDER BY per_LastName', 'CustomSearch is NULL', 'Find people with a custom field value is NULL', 1, 7);
41 changes: 26 additions & 15 deletions src/v2/templates/query/queryview.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ function ProcessSQL($vPOST, $qry_SQL, $rsParameters)
extract($aRow);

//Debugging code
//echo "--" . $qry_SQL . "<br>--" . "~" . $qrp_Alias . "~" . "<br>--" . $vPOST[$qrp_Alias] . "<p>";

?>
<?= "--" . $qry_SQL ?><br>-- ~<?= $qrp_Alias ?>~<br>--<?= $vPOST[$qrp_Alias] ?><p>
<?php
//Replace the placeholder with the parameter value
$qry_SQL = str_replace('~' . $qrp_Alias . '~', $vPOST[$qrp_Alias], $qry_SQL);
}
Expand All @@ -111,9 +112,11 @@ function DisplayRecordCount($qry_Count, $rsQueryResults)
//Are we supposed to display a count for this query?
if ($qry_Count == 1) {
//Display the count of the recordset
echo '<p align="center">';
echo mysqli_num_rows($rsQueryResults) . _(' record(s) returned');
echo '</p>';
?>
<p align="center">
<?= mysqli_num_rows($rsQueryResults) . _(' record(s) returned') ?>
</p>
<?php
}
}

Expand Down Expand Up @@ -141,8 +144,9 @@ class="btn btn-danger btn-sm"> <i class="fas fa-times"></i> <?= _('Remove From C
for ($iCount = 0; $iCount < mysqli_num_fields($rsQueryResults); $iCount++) {
//If this field is called "AddToCart", provision a headerless column to hold the cart action buttons
$fieldInfo = mysqli_fetch_field_direct($rsQueryResults, $iCount);
if ($fieldInfo->name != 'AddToCart' && $fieldInfo->name != 'GDPR') {
echo '<th>' . _($fieldInfo->name) . '</th>';
if ($fieldInfo->name != 'AddToCart' && $fieldInfo->name != 'GDPR') {?>
<th><?= _($fieldInfo->name) ?></th>
<?php
} elseif ($fieldInfo->name == 'AddToCart') {
?>
<th>
Expand All @@ -165,7 +169,9 @@ class="btn btn-danger btn-sm"> <i class="fas fa-times"></i> <?= _('Remove From C
$qry_real_Count++;

//Alternate the background color of the row
echo '<tr>';
?>
<tr>
<?php

//Loop through the fields and write each one
for ($iCount = 0; $iCount < mysqli_num_fields($rsQueryResults); $iCount++) {
Expand Down Expand Up @@ -202,15 +208,20 @@ class="btn btn-danger btn-sm"> <i class="fas fa-times"></i> <?= _('Remove From C
//Write the actual value of this row
if ( mb_strpos($aRow[$iCount],"<a href=") !== false) {
$res = str_replace("<a href=", "<a href=".$sRootPath."/", $aRow[$iCount]);
echo '<td>' . $res . '</td>';
?>
<td><?= $res ?></td>
<?php
} else {
echo '<td>' . $aRow[$iCount] . '</td>';
?>
<td><?= $aRow[$iCount] ?></td>
<?php
}

}
}

echo '</tr>';
?>
</tr>
<?php
} ?>
</tbody>
</table>
Expand Down Expand Up @@ -433,9 +444,9 @@ function DisplayParameterForm($rsParameters, $iQueryID, $sRootPath)
}
while ($aRow = mysqli_fetch_array($rsParameters)) {
$res = getQueryFormInput($aRow);

echo $res[1];

?>
<?= $res[1] ?>
<?php
} ?>

<div class="form-group text-right">
Expand Down

0 comments on commit 296bff9

Please sign in to comment.