Page 1 of 1

modify child records

Posted: 2021-01-05 22:08
by utony
Does anyone know how to modify a child record TV??? or even a child record DVP??? I'm pulling my hair out. Any help would be appreciated.

Re: modify child records

Posted: 2021-01-06 14:46
by pbottcher
Hi,

as far as I remember you can use the standard hooks/TABLENAME.php (init, ...) functions to handle the child TV. There are some restrictions, but if you do not state what you need, it is not possible to say how it might be done.

Re: modify child records

Posted: 2021-01-06 16:44
by utony
I want to modify the way the child record looks when it prints out. I can easily modify the tablename.dvp on the parent, but the child table file attached to the parent does not look the same as a parent table.dvp file.

Re: modify child records

Posted: 2021-01-06 18:36
by pbottcher
Hi,

you can edit the

templates/children-TABLENAME-printable.php file to adjust this.

NOTE: This file might be overwritten on recreation of your project.

Re: modify child records

Posted: 2021-01-06 18:44
by utony
<?php if(!isset($Translation)) die('No direct access allowed.'); ?>
<?php $current_table = 'Activity_Log_Activities'; ?>
<?php
$cleaner = new CI_Input();
$cleaner->charset = datalist_db_encoding;
?>
<script>
<?php echo $current_table; ?>GetChildrenRecordsList = function(command) {
var param = {
ChildTable: "<?php echo $parameters['ChildTable']; ?>",
ChildLookupField: "<?php echo $parameters['ChildLookupField']; ?>",
SelectedID: "<?php echo addslashes($parameters['SelectedID']); ?>",
Page: <?php echo addslashes($parameters['Page']); ?>,
SortBy: <?php echo ($parameters['SortBy'] === false ? '""' : $parameters['SortBy']); ?>,
SortDirection: '<?php echo $parameters['SortDirection']; ?>',
AutoClose: <?php echo ($config['auto-close'] ? 'true' : 'false'); ?>
};
var panelID = "panel_<?php echo "{$parameters['ChildTable']}-{$parameters['ChildLookupField']}"; ?>";
var mbWidth = window.innerWidth * 0.9;
var mbHeight = window.innerHeight * 0.8;
if(mbWidth > 1000) { mbWidth = 1000; }
if(mbHeight > 800) { mbHeight = 800; }

switch(command.Verb) {
case 'sort': /* order by given field index in 'SortBy' */
post("parent-children.php", {
ChildTable: param.ChildTable,
ChildLookupField: param.ChildLookupField,
SelectedID: param.SelectedID,
Page: param.Page,
SortBy: command.SortBy,
SortDirection: command.SortDirection,
Operation: 'get-records-printable'
}, panelID, undefined, 'pc-loading', function() { AppGini.calculatedFields.init() });
break;
case 'page': /* next or previous page as provided by 'Page' */
if(command.Page.toLowerCase() == 'next') { command.Page = param.Page + 1; }
else if(command.Page.toLowerCase() == 'previous') { command.Page = param.Page - 1; }

if(command.Page < 1 || command.Page > <?php echo ceil($totalMatches / $config['records-per-page']); ?>) { return; }
post("parent-children.php", {
ChildTable: param.ChildTable,
ChildLookupField: param.ChildLookupField,
SelectedID: param.SelectedID,
Page: command.Page,
SortBy: param.SortBy,
SortDirection: param.SortDirection,
Operation: 'get-records-printable'
}, panelID, undefined, 'pc-loading', function() { AppGini.calculatedFields.init() });
break;
case 'reload': /* just a way of refreshing children, retaining sorting and pagination & without reloading the whole page */
post("parent-children.php", {
ChildTable: param.ChildTable,
ChildLookupField: param.ChildLookupField,
SelectedID: param.SelectedID,
Page: param.Page,
SortBy: param.SortBy,
SortDirection: param.SortDirection,
Operation: 'get-records-printable'
}, panelID, undefined, 'pc-loading', function() { AppGini.calculatedFields.init() });
break;
}
};
</script>

<div class="row">
<div class="col-xs-12 col-md-12">

<div class="page-header"><h1>
<?php echo ($config['table-icon'] ? '<img src="' . $config['table-icon'] . '">' : ''); ?>
<?php echo $config['tab-label']; ?>
</h1></div>


<div class="table-responsive">
<table data-tablename="<?php echo $current_table; ?>" class="table table-striped table-hover table-condensed table-bordered">
<thead>
<tr>
<?php if(is_array($config['display-fields'])) foreach($config['display-fields'] as $fieldIndex => $fieldLabel) { ?>
<th
<?php if($config['sortable-fields'][$fieldIndex]) { ?>
onclick="<?php echo $current_table; ?>GetChildrenRecordsList({
Verb: 'sort',
SortBy: <?php echo $fieldIndex; ?>,
SortDirection: '<?php echo ($parameters['SortBy'] == $fieldIndex && $parameters['SortDirection'] == 'asc' ? 'desc' : 'asc'); ?>'
});"
style="cursor: pointer;"
tabindex="0"
<?php } ?>
class="<?php echo "{$current_table}-{$config['display-field-names'][$fieldIndex]}"; ?>">
<?php echo $fieldLabel; ?>
<?php if($parameters['SortBy'] == $fieldIndex && $parameters['SortDirection'] == 'desc') { ?>
<i class="glyphicon glyphicon-sort-by-attributes-alt text-warning"></i>
<?php } elseif($parameters['SortBy'] == $fieldIndex && $parameters['SortDirection'] == 'asc') { ?>
<i class="glyphicon glyphicon-sort-by-attributes text-warning"></i>
<?php } ?>
</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php if(is_array($records)) foreach($records as $pkValue => $record) { ?>
<tr data-id="<?php echo html_attr($pkValue); ?>">
<td class="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][2]}"; ?>" id="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][2]}-" . html_attr($record[$config['child-primary-key-index']]); ?>"><?php echo safe_html($record[2]); ?></td>
<td class="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][3]}"; ?>" id="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][3]}-" . html_attr($record[$config['child-primary-key-index']]); ?>"><?php echo safe_html($record[3]); ?></td>
<td class="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][6]}"; ?>" id="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][6]}-" . html_attr($record[$config['child-primary-key-index']]); ?>"><?php echo safe_html($record[6]); ?></td>
<td class="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][7]}"; ?>" id="<?php echo "{$parameters['ChildTable']}-{$config['display-field-names'][7]}-" . html_attr($record[$config['child-primary-key-index']]); ?>"><?php echo safe_html($record[7]); ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td colspan="<?php echo count($config['display-fields']); ?>">
<?php if($totalMatches) { ?>
<?php if($config['show-page-progress']) { ?>
<span style="margin: 10px;">
<?php $firstRecord = ($parameters['Page'] - 1) * $config['records-per-page'] + 1; ?>
<?php echo str_replace(array('<FirstRecord>', '<LastRecord>', '<RecordCount>'), array($firstRecord, $firstRecord + count($records) - 1, $totalMatches), $Translation['records x to y of z']); ?>
</span>
<?php } ?>
<?php } else { ?>
<span class="text-danger" style="margin: 10px;"><?php echo $Translation['No matches found!']; ?></span>
<?php } ?>
</td>
</tr>
</tfoot>
</table>
</div>
<?php if($totalMatches > $config['records-per-page']) { ?>
<div class="row hidden-print">
<div class="col-xs-12">
<button
type="button"
class="btn btn-default btn-previous"
<?php echo $parameters['Page'] <= 1 ? 'disabled' : ''; ?>
><i class="glyphicon glyphicon-chevron-left"></i>
</button>
<button
type="button"
class="btn btn-default btn-next"
<?php echo ($firstRecord + count($records) - 1) == $totalMatches ? 'disabled' : ''; ?>
><i class="glyphicon glyphicon-chevron-right"></i>
</button>
</div>
</div>
<?php } ?>
</div>
</div>

<script>
$j(function() {
$j('img[src^="thumbnail.php?i=&"').parent().hide();

$j('.btn-previous, .btn-next').on('click', function() {
$j('.btn-previous, .btn-next')
.prop('disabled', true);
$j(this).find('.glyphicon')
.removeClass('glyphicon-chevron-right glyphicon-chevron-left')
.addClass('glyphicon-refresh loop-rotate');

<?php echo $current_table; ?>GetChildrenRecordsList({
Verb: 'page',
Page: ($j(this).hasClass('btn-next') ? 'next' : 'previous')
});
});
})
</script>



:D :D :D :D :D

Can you point out where I can modify the data to stack using grid style and go from horizontal to vertical

Re: modify child records

Posted: 2021-01-06 18:52
by utony
Here is the parent table for that in html

<!-- Edit this file to change the layout of the detail view print preview page -->


<div class="panel-heading"><h3 class="panel-title">
<strong><%%DETAIL_VIEW_TITLE%%></strong>
<div class="hidden-print pull-right">
<div class="btn-group">
<button type="button" id="print" onclick="window.print();" title="<%%TRANSLATION(Print)%%>" class="btn btn-primary"><i class="glyphicon glyphicon-print"></i> <%%TRANSLATION(Print)%%></button>
<button type="submit" id="back" title="<%%TRANSLATION(Cancel Printing)%%>" class="btn btn-default"><i class="glyphicon glyphicon-remove-circle"></i> <%%TRANSLATION(Cancel Printing)%%></button>
</div>
</div>
<div class="clearfix"></div>
</h3></div>

<div class="panel-body">
<fieldset class="form-horizontal">
<!-- Field: ACTIVITY DATE -->
<div class="form-group Activity_Log_Activities-ACTIVITY_DATE" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">ACTIVITY DATE</label>
<div class="col-xs-9">
<div class="form-control-static"><%%COMBOTEXT(ACTIVITY_DATE)%%></div>
</div>
</div>
<!-- Field: ACTIVITY TYPE (37) -->
<div class="form-group Activity_Log_Activities-ACTIVITY_TYPE" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">ACTIVITY TYPE (37)</label>
<div class="col-xs-9">
<div class="form-control-static"><span id="ACTIVITY_TYPE<%%RND1%%>"><%%COMBOTEXT(ACTIVITY_TYPE)%%></span></div>
</div>
</div>
<!-- Field: K9 -->
<div class="form-group Activity_Log_Activities-K9" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">K9</label>
<div class="col-xs-9">
<div class="form-control-static"><span id="K9<%%RND1%%>"><%%COMBOTEXT(K9)%%></span></div>
</div>
</div>
<!-- Field: HANDLER -->
<div class="form-group Activity_Log_Activities-HANDLER" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">HANDLER</label>
<div class="col-xs-9">
<div class="form-control-static"><span id="HANDLER<%%RND1%%>"><%%COMBOTEXT(HANDLER)%%></span></div>
</div>
</div>
<!-- Field: DID K9 INDICATE/ALERT -->
<div class="form-group Activity_Log_Activities-K9_ALERT" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">DID K9 INDICATE/ALERT</label>
<div class="col-xs-9">
<div class="form-control-static"><%%COMBOTEXT(K9_ALERT)%%></div>
</div>
</div>
<!-- Field: DRUG FOUND -->
<div class="form-group Activity_Log_Activities-DRUG_FOUND" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">DRUG FOUND</label>
<div class="col-xs-9">
<div class="form-control-static"><%%COMBOTEXT(DRUG_FOUND)%%></div>
</div>
</div>
<!-- Field: VERBAL CORROBORATION -->
<div class="form-group Activity_Log_Activities-VERBAL_CORROBORATION" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">VERBAL CORROBORATION</label>
<div class="col-xs-9">
<div class="form-control-static"><%%VALUE(VERBAL_CORROBORATION)%%></div>
</div>
</div>
<!-- Field: GENERAL NOTES -->
<div class="form-group Activity_Log_Activities-GENERAL_NOTES" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">GENERAL NOTES</label>
<div class="col-xs-9">
<div class="form-control-static"><%%VALUE(GENERAL_NOTES)%%></div>
</div>
</div>
<!-- Field: RECORD CREATED BY -->
<div class="form-group Activity_Log_Activities-RECORD_CREATED_BY" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">RECORD CREATED BY</label>
<div class="col-xs-9">
<div class="form-control-static"><%%VALUE(RECORD_CREATED_BY)%%></div>
</div>
</div>
<!-- Field: RECORD LAST EDITED BY -->
<div class="form-group Activity_Log_Activities-RECORD_LAST_EDITED_BY" style="border-bottom: dotted 1px #DDD;">
<label class="col-xs-3 control-label">RECORD LAST EDITED BY</label>
<div class="col-xs-9">
<div class="form-control-static"><%%VALUE(RECORD_LAST_EDITED_BY)%%></div>
</div>
</div>
</fieldset>
</div>
-----------
I need to be able to modify the child in the same fashion as I can this file. Am I making my self clear now? Sorry if not.

I like the child records underneath the parent record on the parent Detail view, so when printing I can get all the attached child records in one report. But the child-printable-php file is not easy to work with to achieve what I am looking for.

Is there a way to pull the parent and all child records into one PDF output?

Re: modify child records

Posted: 2021-01-06 19:37
by pbottcher
Hi,

maybe you can make a screenshot of what you have now and what you want to get.

Re: modify child records

Posted: 2021-01-07 01:35
by utony
This is what I am talking about. I need the child to display better than this when I print the parent at the top and the child at the bottom. What can I do to make the child printable better???

Re: modify child records

Posted: 2021-01-07 01:36
by utony
As you can see the child data is not properly disaplayed on print. I need everything printed clean

Re: modify child records

Posted: 2021-01-07 15:55
by pbottcher
Hi,

thanks for sharing, but how do you want to display that data. What if you have 50 child records, ...?

You see the

<thead>
<tbody>
<?php if(is_array($records)) foreach($records as $pkValue => $record) { ?>

definitions where the layout is defined. So you can change it to whatever you need.

Re: modify child records

Posted: 2021-01-07 16:24
by utony
So that is where I am lost. HTML no problem for me. PHP I get confused. Can you point me in the right direction for some options to do things with the data? vertical list, maybe 4-4-4, or 6-6, bootstrap grid????

Re: modify child records

Posted: 2021-01-07 16:52
by utony
Maybe a code example? and how to insert it in the child-printable file? I built a beautiful output report with the parent table data, the child data is what is throwing me for a loop. I can easily modify the tablename.dvp templates, but when it comes to the child template, it is some much harder. Thanks for your time on this. I am so stick! Any help is wanted!!!!

Re: modify child records

Posted: 2021-01-07 21:31
by pbottcher
Hi,

it is not really easy to anticipate what you try to a achieve. It would be helpful to see your expected result.

Re: modify child records

Posted: 2021-01-08 01:45
by utony
Something like this ---

Data Data Data Data

Data Data Data Data

Just want to stack it 4 wide then down vertical