[Vtigercrm-commits] [vtiger-commits] r7738 - in /vtigercrm/trunk: Smarty/templates/PrintReport.tpl Smarty/templates/ReportRun.tpl Smarty/templates/ReportRunContents.tpl modules/Reports/PrintReport.php modules/Reports/ReportRun.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon Jul 3 12:20:27 EDT 2006
Author: richie
Date: Mon Jul 3 10:20:18 2006
New Revision: 7738
Log:
print report has been integrated
Added:
vtigercrm/trunk/Smarty/templates/PrintReport.tpl
vtigercrm/trunk/modules/Reports/PrintReport.php
Modified:
vtigercrm/trunk/Smarty/templates/ReportRun.tpl
vtigercrm/trunk/Smarty/templates/ReportRunContents.tpl
vtigercrm/trunk/modules/Reports/ReportRun.php
Modified: vtigercrm/trunk/Smarty/templates/ReportRun.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/ReportRun.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/ReportRun.tpl Mon Jul 3 10:20:18 2006
@@ -173,5 +173,10 @@
getObj('report_info').innerHTML = reportinfr;
}
ReportInfor();
+
+{/literal}
+function goToPrintReport(id)
+{ldelim}
+ window.open("index.php?module=Reports&action=ReportsAjax&file=PrintReport&record="+id+"&stdDateFilterField="+document.NewReport.stdDateFilterField.options [document.NewReport.stdDateFilterField.selectedIndex].value+"&stdDateFilter="+document.NewReport.stdDateFilter.options[document.NewReport.stdDateFilter.selectedIndex].value+"&startdate="+document.NewReport.startdate.value+"&enddate="+document.NewReport.enddate.value,"{$MOD.LBL_Print_REPORT}","width=750,height=800,resizable=0,scrollbars=1,left=100");
+{rdelim}
</SCRIPT>
-{/literal}
Modified: vtigercrm/trunk/Smarty/templates/ReportRunContents.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/ReportRunContents.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/ReportRunContents.tpl Mon Jul 3 10:20:18 2006
@@ -13,7 +13,7 @@
<tbody><tr>
<td align="left" width="10%"><input class="classBtn" id="btnExport" name="btnExport" value="{$MOD.LBL_EXPORTPDF_BUTTON}" type="button" onClick="goToURL(CrearEnlace('CreatePDF',{$REPORTID}));" title="{$MOD.LBL_EXPORTPDF_BUTTON}"></td>
<td align="left" width="20%"><input class="classBtn" id="btnExport" name="btnExport" value="{$MOD.LBL_EXPORTXL_BUTTON}" type="button" onClick="goToURL(CrearEnlace('CreateXL',{$REPORTID}));" title="{$MOD.LBL_EXPORTXL_BUTTON}" ></td>
- <td align="left" width="70%"><input name="print" value=" Print Report " class="classBtn" type="button"></td>
+ <td align="left" width="70%"><input name="PrintReport" value="{$MOD.LBL_PRINT_REPORT}" onClick="goToPrintReport({$REPORTID});" class="classBtn" type="button"></td>
</tr>
</tbody>
</table>
@@ -56,7 +56,7 @@
<tbody><tr>
<td align="left" width="10%"><input class="classBtn" id="btnExport" name="btnExport" value="{$MOD.LBL_EXPORTPDF_BUTTON}" type="button" onClick="goToURL(CrearEnlace('CreatePDF',{$REPORTID}));" title="{$MOD.LBL_EXPORTPDF_BUTTON}"></td>
<td align="left" width="20%"><input class="classBtn" id="btnExport" name="btnExport" value="{$MOD.LBL_EXPORTXL_BUTTON}" type="button" onClick="goToURL(CrearEnlace('CreateXL',{$REPORTID}));" title="{$MOD.LBL_EXPORTXL_BUTTON}" ></td>
- <td align="left" width="70%"><input name="print" value="{$MOD.LBL_PRINT_REPORT}" class="classBtn" type="button"></td>
+ <td align="left" width="70%"><input name="PrintReport" value="{$MOD.LBL_PRINT_REPORT}" class="classBtn" onClick="goToPrintReport({$REPORTID});" type="button"></td>
</tr>
</tbody>
</table>
Modified: vtigercrm/trunk/modules/Reports/ReportRun.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/ReportRun.php (original)
+++ vtigercrm/trunk/modules/Reports/ReportRun.php Mon Jul 3 10:20:18 2006
@@ -1426,6 +1426,182 @@
}
}
return $coltotalhtml;
+ }elseif($outputformat == "PRINT")
+ {
+ $sSQL = $this->sGetSQLforReport($this->reportid,$filterlist);
+ $result = $adb->query($sSQL);
+ $y=$adb->num_fields($result);
+
+ if($result)
+ {
+ for ($x=0; $x<$y; $x++)
+ {
+ $fld = $adb->field_name($result, $x);
+ $header .= "<th>".str_replace($modules," ",$fld->name)."</th>";
+ }
+
+ $noofrows = $adb->num_rows($result);
+ $custom_field_values = $adb->fetch_array($result);
+ $groupslist = $this->getGroupingList($this->reportid);
+
+ do
+ {
+ $arraylists = Array();
+ if(count($groupslist) == 1)
+ {
+ $newvalue = $custom_field_values[0];
+ }elseif(count($groupslist) == 2)
+ {
+ $newvalue = $custom_field_values[0];
+ $snewvalue = $custom_field_values[1];
+ }elseif(count($groupslist) == 3)
+ {
+ $newvalue = $custom_field_values[0];
+ $snewvalue = $custom_field_values[1];
+ $tnewvalue = $custom_field_values[2];
+ }
+
+ if($newvalue == "") $newvalue = "-";
+
+ if($snewvalue == "") $snewvalue = "-";
+
+ if($tnewvalue == "") $tnewvalue = "-";
+
+ $valtemplate .= "<tr>";
+
+ for ($i=0; $i<$y; $i++)
+ {
+ $fld = $adb->field_name($result, $i);
+ $fieldvalue = $custom_field_values[$i];
+
+ if($fieldvalue == "" )
+ {
+ $fieldvalue = "-";
+ }
+ if(($lastvalue == $fieldvalue) && $this->reporttype == "summary")
+ {
+ if($this->reporttype == "summary")
+ {
+ $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>";
+ }else
+ {
+ $valtemplate .= "<td>".$fieldvalue."</td>";
+ }
+ }else if(($secondvalue == $fieldvalue) && $this->reporttype == "summary")
+ {
+ if($lastvalue == $newvalue)
+ {
+ $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>";
+ }else
+ {
+ $valtemplate .= "<td>".$fieldvalue."</td>";
+ }
+ }
+ else if(($thirdvalue == $fieldvalue) && $this->reporttype == "summary")
+ {
+ if($secondvalue == $snewvalue)
+ {
+ $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>";
+ }else
+ {
+ $valtemplate .= "<td>".$fieldvalue."</td>";
+ }
+ }
+ else
+ {
+ if($this->reporttype == "tabular")
+ {
+ $valtemplate .= "<td>".$fieldvalue."</td>";
+ }else
+ {
+ $valtemplate .= "<td>".$fieldvalue."</td>";
+ }
+ }
+ }
+ $valtemplate .= "</tr>";
+ $lastvalue = $newvalue;
+ $secondvalue = $snewvalue;
+ $thirdvalue = $tnewvalue;
+ $arr_val[] = $arraylists;
+ }while($custom_field_values = $adb->fetch_array($result));
+
+ $sHTML = '<tr>'.$header.'</tr>'.$valtemplate;
+ $return_data[] = $sHTML;
+ $return_data[] = $noofrows;
+ return $return_data;
+ }
+ }elseif($outputformat == "PRINT_TOTAL")
+ {
+ $escapedchars = Array('_SUM','_AVG','_MIN','_MAX');
+ $sSQL = $this->sGetSQLforReport($this->reportid,$filterlist,"COLUMNSTOTOTAL");
+ if(isset($this->totallist))
+ {
+ if($sSQL != "")
+ {
+ $result = $adb->query($sSQL);
+ $y=$adb->num_fields($result);
+ $custom_field_values = $adb->fetch_array($result);
+
+ $coltotalhtml .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" align="center" class="printReport" ><tr><th>Totals</th><th>SUM</th><th>AVG</th><th>MIN</th><th>MAX</th></tr>';
+
+ foreach($this->totallist as $key=>$value)
+ {
+ $fieldlist = explode(":",$key);
+ $totclmnflds[str_replace($escapedchars," ",$fieldlist[3])] = str_replace($escapedchars," ",$fieldlist[3]);
+ }
+
+ for($i =0;$i<$y;$i++)
+ {
+ $fld = $adb->field_name($result, $i);
+ $keyhdr[$fld->name] = $custom_field_values[$i];
+ }
+ foreach($totclmnflds as $key=>$value)
+ {
+
+ $coltotalhtml .= '<tr valign=top><td>'.str_replace($modules," ",$value).'</td>';
+ $arraykey = trim($value).'_SUM';
+ if(isset($keyhdr[$arraykey]))
+ {
+ $coltotalhtml .= '<td>'.$keyhdr[$arraykey].'</td>';
+ }else
+ {
+ $coltotalhtml .= '<td> </td>';
+ }
+
+ $arraykey = trim($value).'_AVG';
+ if(isset($keyhdr[$arraykey]))
+ {
+ $coltotalhtml .= '<td>'.$keyhdr[$arraykey].'</td>';
+ }else
+ {
+ $coltotalhtml .= '<td> </td>';
+ }
+
+ $arraykey = trim($value).'_MIN';
+ if(isset($keyhdr[$arraykey]))
+ {
+ $coltotalhtml .= '<td>'.$keyhdr[$arraykey].'</td>';
+ }else
+ {
+ $coltotalhtml .= '<td> </td>';
+ }
+
+ $arraykey = trim($value).'_MAX';
+ if(isset($keyhdr[$arraykey]))
+ {
+ $coltotalhtml .= '<td>'.$keyhdr[$arraykey].'</td>';
+ }else
+ {
+ $coltotalhtml .= '<td> </td>';
+ }
+
+ $coltotalhtml .= '<tr>';
+ }
+
+ $coltotalhtml .= "</table>";
+ }
+ }
+ return $coltotalhtml;
}
}
More information about the vtigercrm-commits
mailing list