* list all mentee page can print mentee list
* print can base on the user preference
http://code.google.com/p/scu-smp/source/detail?r=279
Modified:
/trunk/smp-php/smp/command/mentee/ListAllMenteeCommand.php
/trunk/smp-php/smp/datagrid/MenteeDatagrid.php
/trunk/smp-php/smp/service/MenteeService.php
/trunk/smp-php/smp/util/FormBuilder.php
/trunk/smp-php/smp/view/mentee/listAllMentee.php
=======================================
--- /trunk/smp-php/smp/command/mentee/ListAllMenteeCommand.php Sat Oct 2
00:51:21 2010
+++ /trunk/smp-php/smp/command/mentee/ListAllMenteeCommand.php Fri Oct 8
00:07:33 2010
@@ -11,8 +11,7 @@
require_once('smp/service/MenteeService.php');
require_once('smp/domain/Student.php');
require_once('smp/base/SessionRegistry.php');
-class smp_command_mentee_ListAllMenteeCommand extends smp_command_Command {
-
+class smp_command_mentee_ListAllMenteeCommand extends smp_command_Command {
function doExecute(smp_controller_Request $request) {
$menteeService = new smp_service_MenteeService();
@@ -28,13 +27,21 @@
$mentee->setExpired((is_null($request->getProperty('expired')) ? null :
true));
$mentee->setMatched((is_null($request->getProperty('matched')) ? null :
true));
+
$mentee->setStudent($student);
smp_base_SessionRegistry::setSearchEntity('mentee_ListAllMentee_MenteeSearch',
$mentee);
}
$mentee =
smp_base_SessionRegistry::getSearchEntity('mentee_ListAllMentee_MenteeSearch');
$request->setSearchEntity($mentee);
- $datagrid = $menteeService->getAllMenteeDatagrid($mentee);
+ $outputFormat = $request->getProperty('output_format');
+ if(is_null($outputFormat)){
+ $datagrid = $menteeService->getAllMenteeDatagrid($mentee);
+ }else{
+ $datagrid = $menteeService->getAllMenteeDatagrid($mentee, false);
+ }
+
+
$request->setDatagrid($datagrid);
$request->setTitle("List of Mentees");
}
=======================================
--- /trunk/smp-php/smp/datagrid/MenteeDatagrid.php Sat Oct 2 00:51:21 2010
+++ /trunk/smp-php/smp/datagrid/MenteeDatagrid.php Fri Oct 8 00:07:33 2010
@@ -7,9 +7,11 @@
* @version 1.0
*/
require_once('smp/datagrid/Datagrid.php');
+
+
class smp_datagrid_MenteeDatagrid extends smp_datagrid_Datagrid {
- function getMenteeDatagrid($mentee = null) {
+ function getMenteeDatagrid($mentee = null, $paging=ture) {
self::$options['fields'] = array
('id','firstname', 'lastname', 'student_number', 'course_id', 'gender', 'study_mode');
self::$options['labels'] = array (
'id' => 'Id',
@@ -25,7 +27,12 @@
$query = "SELECT smp_mentee.id, smp_mentee.expired,
smp_student.firstname, smp_student.lastname, smp_student.student_number,
smp_student.course_id, smp_student.gender, smp_student.study_mode
FROM smp_mentee INNER JOIN smp_student WHERE smp_mentee.student_id =
smp_student.id ".$menteeSearchCriteria.$studentSearchCriteria;
- self::$datagrid->setDefaultSort(array('id' => 'DESC'));
+
+ if(!$paging){
+ self::$datagrid = new Structures_DataGrid();
+ }
+
+ self::$datagrid->setDefaultSort(array('id' => 'ASC'));
self::$datagrid->bind($query, self::$options);
return self::$datagrid;
=======================================
--- /trunk/smp-php/smp/service/MenteeService.php Fri Oct 1 23:34:50 2010
+++ /trunk/smp-php/smp/service/MenteeService.php Fri Oct 8 00:07:33 2010
@@ -53,8 +53,8 @@
*
* @param smp_domain_Mentee $mentee
*/
- function getAllMenteeDatagrid($mentee = null){
- return $this->menteeDatagrid->getMenteeDatagrid($mentee);
+ function getAllMenteeDatagrid($mentee = null, $paging = true){
+ return $this->menteeDatagrid->getMenteeDatagrid($mentee, $paging);
}
/** This method return datagrid of all matched mentees.
=======================================
--- /trunk/smp-php/smp/util/FormBuilder.php Mon Sep 20 01:10:16 2010
+++ /trunk/smp-php/smp/util/FormBuilder.php Fri Oct 8 00:07:33 2010
@@ -20,7 +20,7 @@
}
function open($strId, $cssClass = "form_Container", $strAction = "",
$strMethod = "post", $strEnctype = "multipart",$arrOtherAttributes =
array()) {
- $strId = $this->getHtmlAttributeString($strId == "", "id", $strId);
+ $strId = $this->getHtmlAttributeString($strId != "", "id", $strId);
$strAction = (($strAction == "") ? $this->strFileName : $strAction);
$strOtherAttributes = $this->getOtherAttributes($arrOtherAttributes);
switch ($strMethod) {
=======================================
--- /trunk/smp-php/smp/view/mentee/listAllMentee.php Sat Oct 2 00:51:21
2010
+++ /trunk/smp-php/smp/view/mentee/listAllMentee.php Fri Oct 8 00:07:33
2010
@@ -7,32 +7,49 @@
* @author <a href="mailto:sl...@scu.edu.au">Bruce</a>
* @version 1.0
*/
-include('smp/view/common/header.php');
-require_once('smp/util/OptionProvider.php');
+require_once('smp/view/ViewHelper.php');
require_once('smp/util/DatagridUtil.php');
-
-$indent = " ";
-print $indent."<br><h1>List of Mentees</h1><br>\r\n";
-
-include("smp/view/search/menteeSearchFullPanel.php");
-
-$datagrid = $request->getDatagrid();
-
-$datagrid = smp_util_DatagridUtil::formatColumn('id', $datagrid);
+$request=VH::getRequest();
+$datagrid=& $request->getDatagrid();
//use Formatter to edit generated data
$datagrid = smp_util_DatagridUtil::formatColumn('study_mode', $datagrid);
$datagrid = smp_util_DatagridUtil::formatColumn('course_id', $datagrid);
$datagrid = smp_util_DatagridUtil::formatColumn('gender', $datagrid);
-$datagrid->addColumn(new Structures_DataGrid_Column('Mark as
Expired',null,null,array('width'=>'15%'),null,'printMarkAsExpired()'));
-
-$table = smp_util_DatagridUtil::getCustomHtmlTable();
-$datagrid->fill($table, smp_util_DatagridUtil::getRenderOptions());
-
-print $table->toHtml();
-$datagrid->render(DATAGRID_RENDER_PAGER);
-
-include('smp/view/common/footer.php');
+if(is_null($request->getProperty('output_format'))){
+ include('smp/view/common/header.php');
+ $datagrid = smp_util_DatagridUtil::formatColumn('id', $datagrid);
+ $datagrid->addColumn(new Structures_DataGrid_Column('Mark as
Expired',null,null,array('width'=>'15%'),null,'printMarkAsExpired()'));
+
+ $indent = " ";
+ print $indent."<br><h1>List of Mentees</h1><br>\r\n";
+
+ include("smp/view/search/menteeSearchFullPanel.php");
+
+ $table = smp_util_DatagridUtil::getCustomHtmlTable();
+
+ $datagrid->fill($table, smp_util_DatagridUtil::getRenderOptions());
+
+ print $table->toHtml();
+ $datagrid->render(DATAGRID_RENDER_PAGER);
+
+ print $indent. "<br />\r\n";
+ print $indent. "<div style=\"clear:both;padding-left:800px;\">\r\n";
+ print $indent. " <a
href=\"index.php?cmd=mentee/listAllMentee&output_format=CSV\">\r\n";//todo
create the functions
+ print $indent. " <img src=\"static/images/csv.png\">\r\n";
+ print $indent. " </a>\r\n";
+ print $indent. " <span> | </span>\r\n";
+ print $indent. " <a
href=\"index.php?cmd=mentee/listAllMentee&output_format=XLS\">\r\n";//todo
create the functions
+ print $indent. " <img src=\"static/images/xls.png\">\r\n";
+ print $indent. " </a>\r\n";
+ print $indent. "</div>\r\n";
+ include('smp/view/common/footer.php');
+
+}else if(!is_null($request->getProperty('output_format')) &&
$request->getProperty('output_format')=='XLS'){
+ $datagrid->render(DATAGRID_RENDER_XLS);
+}else if(!is_null($request->getProperty('output_format')) &&
$request->getProperty('output_format')=='CSV'){
+ $datagrid->render(DATAGRID_RENDER_CSV);
+}
function printMarkAsExpired($params){
$menteeId = $params['record']['id'];
@@ -44,8 +61,8 @@
}
}
function format_course_id($params){
- $key = $params['record']['course_id'];
- return VH::getValueFromDynamicArray('course', $key);
+ $key = $params['record']['course_id'];
+ return VH::getValueFromDynamicArray('course', $key);
}
function format_id($params) {
$id = $params['record']['id'];