CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Add "Quick Edit" ability for dates on a report
Pages: [1]

Author Topic: Add "Quick Edit" ability for dates on a report  (Read 841 times)

Robert Townrow

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.4.8
  • CMS version: Drupal 6.24
  • MySQL version: 5.1.63
  • PHP version: 5.3.2-1ubuntu4.18 on Apache/2.2.14 (Ubuntu)
Add "Quick Edit" ability for dates on a report
October 31, 2012, 10:18:18 am
I've stopped this approach for now, so please look at my posting here instead: http://forum.civicrm.org/index.php/topic,26810.0.html
I'm keeping the post here just for reference purposes - delete if you so wish


Hi,

I've been asked to 'streamline' the process of modifying CiviCRM cases from the main report listing those cases. The cases already use a custom report, due to the addition of various date fields. It is these date fields which we wish to modify (plus the main "Case Date", which we call the "Target Date"  - see "How to Create Reports which show overdue schedules in red" )

Currently, the user must click the link to the case and edit it in a new screen (in a modified version of the "Activity" template). They can then modify the dates and save it, and go back to the report (which currently must be refreshed to display the updated information).

Instead, we want to be able to change the dates directly in the report. So for this, I need to do 2 things:
(1) Display the dates in the report as jQuery calendar controls (using the jCalendar.tpl template), so that the user can change these
(2) then either:
   (A) Use an asynchronous AJAX call to update the data in the database once the user makes a change (a disadvantage to this is that if the user makes a change accidentally, there is no chance to confirm and the original value is lost)
   (B) Add a Save button to the report which will save just the changed records to the database (and then refresh the report to ensure data is up-to-date again). I think this is my preferred option.

So far, I have modified my custom table.tpl file from the following:

{foreach from=$columnHeaders item=header key=field}
                    {assign var=fieldLink value=$field|cat:"_link"}
                    {assign var=fieldHover value=$field|cat:"_hover"}
                    <td class="crm-report-{$field}{if $header.type eq 1024 OR $header.type eq 1} report-contents-right{elseif $row.$field eq 'Subtotal'} report-label{/if}">
                        {if $row.$fieldLink}
                            <a title="{$row.$fieldHover}" href="{$row.$fieldLink}">
                        {/if}
                       
                        {if $row.$field eq 'Subtotal'}
                            {$row.$field}
                        {elseif $header.type & 4 OR $header.type & 256}   
                            {if $header.group_by eq 'MONTH' or $header.group_by eq 'QUARTER'}
                                {$row.$field|crmDate:$config->dateformatPartial}
                            {elseif $header.group_by eq 'YEAR'}   
                                {$row.$field|crmDate:$config->dateformatYear}
                            {else}   
                                {if $header.type & 4}   
                                   {$row.$field|truncate:10:''|crmDate}
                                {else}
                                   {$row.$field|crmDate}
                                {/if}
                            {/if}
                        {elseif $header.type eq 1024}
                            <span class="nowrap">{$row.$field|crmMoney}</span>
                        {else}
                        {* add calendar control here: *}
                        {* <td class="label">{$form.activity_date_time.label}</td>
                        {include file="CRM/common/jcalendar.tpl" elementName=$row.$field} *}
                            {$row.$field}
                        {/if}
                       
                        {if $row.$fieldLink}</a>{/if}
                    </td>                   
                {/foreach}

To this:

{foreach from=$columnHeaders item=header key=field}                   
        <td class="label">{$row.$field}</td>
        <td class="view-value">{include file="CRM/common/jcalendar.tpl" elementName=$row.$field}</td>
{/foreach}

Of course, this turns everything into calendar controls, which isn't what I want, but I'm not sure how to select the correct cells in the table?
It also fails to display the data (e.g. 18/01/2011), and I'm unsure how to proceed.

I've only just started with CiviCRM and have only a little PHP experience, so I might be attempting something too ambitious. However, please let me know if any advice (or documentation I should read - I've read some of the basics about the structure of CiviCRM and its Smarty template system, but I still don't understand 100% how the data moves from the PHP report to being processed by the Smarty template, etc.

Thanks for any suggestions.

« Last Edit: November 14, 2012, 07:57:05 am by Robert Townrow »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Add "Quick Edit" ability for dates on a report

This forum was archived on 2017-11-26.