2011-09-20 03:57:39 +00:00
< ? php
2013-09-05 01:56:30 +00:00
use Helpers\View as view ;
2013-08-16 09:59:59 +00:00
use Files\Files ;
2013-08-19 08:17:50 +00:00
use Files\Output ;
2013-08-16 09:59:59 +00:00
use Files\Listener\FileListener ;
2013-09-25 09:44:21 +00:00
use Order\Manager\Offlineapp ;
2013-11-05 07:57:17 +00:00
use Order\Manager\Application ;
2013-09-25 09:26:41 +00:00
use data\DataService ;
2013-09-25 09:30:39 +00:00
use Mail\Mail ;
2013-08-16 09:59:59 +00:00
2011-09-20 03:57:39 +00:00
class Admin_DownController extends Zend_Controller_Action
{
function preDispatch ()
{
$this -> db = Zend_Registry :: get ( 'db' );
$this -> view -> config = Zend_Registry :: get ( 'config' );
$this -> messenger = $this -> _helper -> getHelper ( 'FlashMessenger' );
$this -> view -> messages = $this -> messenger -> getMessages ();
2013-05-17 00:41:46 +00:00
$this -> _helper -> layout -> setLayout ( 'administry' );
2013-08-16 09:59:59 +00:00
$this -> view -> Theme = new Theme ();
2011-09-20 03:57:39 +00:00
}
function postDispatch ()
{
$this -> view -> messages = $this -> messenger -> getMessages ();
}
function indexAction ()
{
//其他连接
}
2014-06-11 07:06:54 +00:00
2011-09-20 03:57:39 +00:00
//离线数据申请管理
function offlineappAction ()
2013-10-08 03:35:49 +00:00
{
2013-09-27 08:10:03 +00:00
set_time_limit ( 0 );
2013-01-29 08:05:45 +00:00
include_once ( " Dataorder.php " );
$DO = new Dataorder ( $this -> db );
2011-09-20 03:57:39 +00:00
$finish = ( int ) $this -> _getParam ( 'finish' );
$deny = ( int ) $this -> _getParam ( 'deny' );
$page = ( int ) $this -> _getParam ( 'page' );
2014-07-22 09:22:34 +00:00
$ac = $this -> _getParam ( 'ac' );
2013-01-29 08:05:45 +00:00
$q = $this -> _getParam ( 'q' );
2014-07-22 09:22:34 +00:00
2014-06-11 07:06:54 +00:00
$submd = $this -> view -> config -> sub -> metadata ;
2011-09-20 03:57:39 +00:00
2013-10-08 03:35:49 +00:00
if ( $ac == " pending " )
{
$keyword = " " ;
if ( ! empty ( $q ))
{
$keyword = $q ;
}
$rows = $DO -> fetchAllOfflineApp ( 3 , $keyword );
view :: addPaginator ( $rows , $this , 10 );
return true ;
}
2011-09-20 03:57:39 +00:00
if ( ! $page ) $page = 1 ;
2014-07-22 09:22:34 +00:00
if ( $finish ) {
2012-08-27 01:54:38 +00:00
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2011-09-20 03:57:39 +00:00
try {
2012-08-27 01:54:38 +00:00
2012-03-12 09:44:13 +00:00
$sql = " SELECT authorpermitted FROM dataorder WHERE offlineappid=? " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ( array ( $finish ));
$row = $sth -> fetch ();
if ( $row [ 'authorpermitted' ] < 0 )
{
2012-08-27 01:54:38 +00:00
$data = array (
'error' => " 数据作者明确反对该下载申请,所以不能进行进一步通过 " ,
);
$this -> jsonexit ( $data );
return true ;
//$this->messenger->addMessage('提示信息:数据作者明确反对该下载申请,所以不能进行进一步通过');
//$this->_redirect('/admin/down/offlineapp/'.$page);
2012-03-12 09:44:13 +00:00
}
2013-10-08 03:35:49 +00:00
//如果是wsn数据则生成数据
2013-09-26 10:38:59 +00:00
//wsn数据在ftp服务器端进行处理
/* $dataservice = new DataService ();
@ $dataservice -> makeWsnData (); */
2013-09-06 07:56:41 +00:00
2011-09-20 03:57:39 +00:00
$sql = " update dataorder set status=5,ts_approved=now() where offlineappid=? " ;
$this -> db -> query ( $sql , array ( $finish ));
2013-10-08 08:45:58 +00:00
$sql = " update offlineapp set ts_approved=now(),status=5 where id=? and ts_approved is null " ;
2011-09-20 03:57:39 +00:00
$this -> db -> query ( $sql , array ( $finish ));
$sql = " select * from offlineapp where id=? " ;
$row = $this -> db -> fetchRow ( $sql , array ( $finish ));
$sql = " select * from dataorder left join dataset on dataset.uuid=dataorder.uuid where dataorder.offlineappid=? " ;
$rs = $this -> db -> fetchAll ( $sql , array ( $finish ));
$has_ftp1 = false ;
2013-05-26 03:58:38 +00:00
$has_ftp2 = false ;
2011-09-20 03:57:39 +00:00
foreach ( $rs as $data ) {
2012-08-27 01:54:38 +00:00
if ( $data [ 'host' ] == 'ftp1.westgis.ac.cn' )
$has_ftp1 = true ;
2013-12-14 04:19:58 +00:00
if ( $data [ 'host' ] == 'ftp.sanjiangyuan.org.cn' )
2013-05-26 03:58:38 +00:00
$has_ftp2 = true ;
2011-09-20 03:57:39 +00:00
// deal with ftp.westgis.ac.cn, use g6 to add path
// todo ...
}
2013-09-06 07:56:41 +00:00
2013-05-26 03:58:38 +00:00
//deal with ftp1&ftp2 account, for offline data
if ( $has_ftp1 || $has_ftp2 ) {
$password = md5 ( 'westdc' . $row [ 'userid' ] . rand ( 1000 , 9999 ));
if ( $has_ftp1 )
{
$user = ( object ) array ( " id " => $row [ 'userid' ],
2013-12-14 04:19:58 +00:00
" username " => " sjy_ " . $row [ 'userid' ],
2013-05-26 03:58:38 +00:00
" password " => $password ,
2011-09-20 03:57:39 +00:00
" time " => date ( 'Y-m-d H:i:s' , strtotime ( '+2 week' )),
2012-08-27 01:54:38 +00:00
//"path"=>$path,
" param " => " offlineappid= " . $finish ,
2012-06-25 14:25:48 +00:00
" host " => 'ftp1.westgis.ac.cn' ,
2011-09-20 03:57:39 +00:00
" maxdata " => $this -> view -> config -> download -> max ,
" datacount " => 1 //represent one offline application
);
2013-05-26 03:58:38 +00:00
$proftp = new Proftp ();
$proftp -> db = $this -> db ;
if ( ! $proftp -> createuser ( $user ))
{
$user -> datacount = 0 ; //force this offline to be true
$proftp -> createuser ( $user );
$data = array (
'error' => " 该用户申请的数据过多,请检查该用户之前已完成的申请 " ,
);
2012-08-27 01:54:38 +00:00
2013-05-26 03:58:38 +00:00
$this -> jsonexit ( $data );
return true ;
//$this->messenger->addMessage('提示信息:该用户申请的数据过多,请检查该用户之前已完成的申请。');
}
}
if ( $has_ftp2 )
{
$user = ( object ) array ( " id " => $row [ 'userid' ],
2013-12-14 04:19:58 +00:00
" username " => " sjy_ " . $row [ 'userid' ],
2013-05-26 03:58:38 +00:00
" password " => $password ,
" time " => date ( 'Y-m-d H:i:s' , strtotime ( '+2 week' )),
//"path"=>$path,
" param " => " offlineappid= " . $finish ,
2013-12-14 04:19:58 +00:00
" host " => 'ftp.sanjiangyuan.org.cn' ,
2013-05-26 03:58:38 +00:00
" maxdata " => $this -> view -> config -> download -> max ,
" datacount " => 1 //represent one offline application
);
$proftp = new Pureftp ();
$proftp -> db = $this -> db ;
if ( ! $proftp -> createuser ( $user ))
{
$user -> datacount = 0 ; //force this offline to be true
$proftp -> createuser ( $user );
$data = array (
'error' => " 该用户申请的数据过多,请检查该用户之前已完成的申请 " ,
);
$this -> jsonexit ( $data );
return true ;
}
}
if ( $has_ftp1 && ! $has_ftp2 )
{
$ftphost = 'ftp://ftp1.westgis.ac.cn' ;
} else if ( ! $has_ftp1 && $has_ftp2 )
{
2013-12-14 04:19:58 +00:00
$ftphost = 'ftp://ftp.sanjiangyuan.org.cn' ;
2013-05-26 03:58:38 +00:00
} else if ( $has_ftp1 && $has_ftp2 )
{
2013-12-14 04:19:58 +00:00
$ftphost = 'ftp://ftp1.westgis.ac.cn 以及 ftp://ftp.sanjiangyuan.org.cn' ;
2013-05-26 03:58:38 +00:00
}
//发送用户邮件进行信息提示和说明
$mail = new WestdcMailer ( $this -> view -> config -> smtp );
//实例化EmailText
$mailtp = new EmailText ( $this -> db , 'offline-finish' ,
array ( 'user' => $row [ 'username' ], 'datalist' => str_replace ( " ; " , " \n " , $row [ 'datalist' ]),
'ftpuser' => $user -> username , 'ftppwd' => $proftp -> pwd , 'ftptime' => $proftp -> time , 'ftphost' => $ftphost ));
$mail -> setBodyText ( $mailtp -> getBody ());
2014-06-11 07:35:28 +00:00
$mail -> setFrom ( $this -> view -> config -> service -> email , '数据服务组' );
2013-05-26 03:58:38 +00:00
$mail -> addTo ( $row [ 'email' ]);
2014-06-11 07:35:28 +00:00
$mail -> addCc ( $this -> view -> config -> service -> email , '数据服务组' );
2013-05-26 03:58:38 +00:00
$mail -> setSubject ( $mailtp -> getSubject ());
$mail -> send ();
} //offline deal
2012-08-27 01:54:38 +00:00
//$this->messenger->addMessage('提示信息:该离线数据已经处理完成。');
$data = array (
'msg' => " 该离线数据已经处理完成 " ,
'finish' => $finish
);
$this -> jsonexit ( $data );
return true ;
2011-09-20 03:57:39 +00:00
} catch ( Exception $e ) {
//提示信息
2012-08-27 01:54:38 +00:00
//$this->messenger->addMessage($e->getMessage());
//$this->messenger->addMessage('提示信息:该数据有可能还没有收到纸质申请表。');
$data = array (
'error' => $e -> getMessage (),
);
$this -> jsonexit ( $data );
return true ;
2011-09-20 03:57:39 +00:00
}
2012-08-27 01:54:38 +00:00
//$this->_redirect('/admin/down/offlineapp/'.$page);
2014-07-22 09:22:34 +00:00
} //通过
elseif ( $deny ) {
2012-08-27 01:54:38 +00:00
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2011-09-20 03:57:39 +00:00
$sql = " update dataorder set status=-1 where offlineappid=? and (status=3 or status=4) " ;
$this -> db -> query ( $sql , array ( $deny ));
2012-08-27 01:54:38 +00:00
$data = array (
'msg' => '已删除该用户离线申请' ,
2014-07-22 09:22:34 +00:00
'finish' => $deny
2012-08-27 01:54:38 +00:00
);
$this -> jsonexit ( $data );
return true ;
//$this->messenger->addMessage('提示信息:已拒绝该用户离线申请。');
//$this->_redirect('/admin/down/offlineapp/'.$page);
2014-07-22 09:22:34 +00:00
} //拒绝
2013-01-29 08:05:45 +00:00
$keyword = " " ;
if ( ! empty ( $q ))
{
$keyword = $q ;
}
2014-07-22 03:27:09 +00:00
$application = new \Order\Manager\Application ;
2014-07-22 09:22:34 +00:00
$rows = $application -> fetchByData ( $keyword );
2013-01-29 08:05:45 +00:00
2011-09-20 03:57:39 +00:00
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $page );
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
2013-01-29 08:05:45 +00:00
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
2011-09-20 03:57:39 +00:00
$this -> view -> paginator = $paginator ;
2013-01-29 08:05:45 +00:00
2011-09-20 03:57:39 +00:00
}
2013-08-16 09:59:59 +00:00
//上传申请表
function uploadapplicationformAction ()
{
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$id = $this -> _getParam ( 'orderid' );
if ( empty ( $id ))
{
$this -> jsonexit ( array ( 'error' => " 参数错误 " ));
return true ;
}
$files = new Files ();
$FileListener = new FileListener ();
@ $files -> events () -> attachAggregate ( $FileListener );
$statu = $files -> uploadApplicationForm ( $_FILES [ 'Filedata' ], $id );
if ( isset ( $statu [ 'error' ]))
{
$this -> jsonexit ( $statu );
return true ;
} else {
2013-09-06 07:56:41 +00:00
$sql = " UPDATE offlineapp SET applicationform=' { $statu [ 'file' ] } ' WHERE id= $id " ;
2013-08-16 09:59:59 +00:00
if ( $this -> db -> exec ( $sql ))
{
$this -> jsonexit ( array ( " success " => 1 ));
return true ;
} else {
$this -> jsonexit ( array ( 'error' => " 数据库记录更新失败 " . $sql ));
return true ;
}
}
}
2013-09-05 01:56:30 +00:00
public function applicationformAction ()
{
$ac = $this -> _getParam ( 'ac' );
if ( $ac == " view " )
{
$link = $this -> _getParam ( 'link' );
$content = file_get_contents ( $link );
header ( " Content-Disposition: inline; filename=applicationform.pdf " );
header ( " Content-Type:application/pdf " );
echo $content ;
exit ();
}
2013-09-09 03:11:29 +00:00
if ( $ac == " download " )
{
$link = $this -> _getParam ( 'link' );
$content = file_get_contents ( $link );
$output = new Output ();
$output -> pushDownload ( $content , " 申请表.pdf " , 'pdf' );
exit ();
}
2013-09-05 01:56:30 +00:00
}
2011-09-20 03:57:39 +00:00
//离线数据服务记录
function offlineAction ()
{
$add = ( int ) $this -> _getParam ( 'add' );
$edit = ( int ) $this -> _getParam ( 'edit' );
$delete = ( int ) $this -> _getParam ( 'delete' );
$down = ( int ) $this -> _getParam ( 'down' );
$update = $this -> _getParam ( 'update' );
$show = $this -> _getParam ( 'show' );
$undelete = $this -> _getParam ( 'undelete' );
2011-09-29 02:24:47 +00:00
$emaillist = $this -> _getParam ( 'emaillist' );
2013-01-29 08:05:45 +00:00
$monthreport = $this -> _getParam ( 'monthreport' );
2014-06-11 08:04:43 +00:00
$submd = $this -> view -> config -> sub -> metadata ;
2011-09-20 03:57:39 +00:00
if ( $add ) {
$form = new OfflinelogForm ();
$form -> pdf -> setDestination ( $this -> view -> config -> offline -> savepath );
if ( $this -> _request -> isPost ()) {
$formdata = $this -> _request -> getPost ();
if ( $form -> isValid ( $formdata )) {
$uploadedData = $form -> getValues ();
$pdf = basename ( $form -> pdf -> getFileName ());
2013-11-14 06:45:21 +00:00
$sql = " insert into offlineapp (username,email,unit,phone,address,postcode,project,pdflink,datalist,ts_created,ts_approved,project_id,project_title,project_type) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
$this -> db -> query ( $sql , array ( $formdata [ 'username' ], $formdata [ 'email' ], $formdata [ 'unit' ], $formdata [ 'phone' ], $formdata [ 'address' ], $formdata [ 'postcode' ],
$formdata [ 'project' ], $pdf , $formdata [ 'datalist' ], $formdata [ 'ts_approved' ]), $formdata [ 'ts_approved' ],
$formdata [ 'project_id' ], $formdata [ 'project_title' ], $formdata [ 'project_type' ]);
2011-09-20 03:57:39 +00:00
$this -> messenger -> addMessage ( '提示信息:您已经成功添加该离线服务记录。' );
$this -> _redirect ( '/admin/down/offline' );
} else {
$form -> populate ( $formdata );
}
}
$this -> view -> form = $form ;
$this -> _helper -> viewRenderer ( 'offlineadd' );
2011-09-29 02:28:27 +00:00
} //添加服务记录
elseif ( $edit ){
2011-09-20 03:57:39 +00:00
$form = new OfflinelogForm ();
$form -> pdf -> setRequired ( false );
if ( $this -> _request -> isPost ()) {
$formdata = $this -> _request -> getPost ();
if ( $form -> isValid ( $formdata )) {
$uploadedData = $form -> getValues ();
$pdf = basename ( $form -> pdf -> getFileName ());
$sql = " update offlineapp set username=?,email=?,unit=?,phone=?,address=?,postcode=?,project=?, " ;
if ( $form -> pdf -> isUploaded ()) $sql .= " pdflink=?, " ;
2013-11-14 06:45:21 +00:00
$sql .= " datalist=?,ts_approved=?,project_id=?,project_title=?,project_type=? where id=? " ;
2011-09-20 03:57:39 +00:00
$param = array ( $formdata [ 'username' ], $formdata [ 'email' ], $formdata [ 'unit' ], $formdata [ 'phone' ], $formdata [ 'address' ], $formdata [ 'postcode' ], $formdata [ 'project' ]);
if ( $form -> pdf -> isUploaded ()) $param [] = $pdf ;
$param [] = $formdata [ 'datalist' ];
$param [] = $formdata [ 'ts_approved' ];
2013-11-14 06:45:21 +00:00
$param [] = $formdata [ 'project_id' ];
$param [] = $formdata [ 'project_title' ];
$param [] = $formdata [ 'project_type' ];
2011-09-20 03:57:39 +00:00
$param [] = $edit ;
$this -> db -> query ( $sql , $param );
$this -> messenger -> addMessage ( '提示信息:您已经编辑添加该记录。' );
2012-01-09 09:10:07 +00:00
$page = $this -> _getParam ( 'page' );
if ( ! empty ( $page ))
$this -> _redirect ( '/admin/down/offline/page/' . $page );
else
$this -> _redirect ( '/admin/down/offline/' );
2011-09-20 03:57:39 +00:00
} else {
$form -> populate ( $formdata );
}
} else {
$sql = " select * from offlineapp where id=? " ;
$formdata = $this -> db -> fetchRow ( $sql , array ( $edit ));
$form -> submit -> setLabel ( '保存' );
$form -> populate ( $formdata );
}
$this -> view -> form = $form ;
$this -> _helper -> viewRenderer ( 'offlineadd' );
2011-09-29 02:28:27 +00:00
} //编辑
elseif ( $delete ) {
2011-09-20 03:57:39 +00:00
$sql = " delete from offlineapp where id=' $delete ' " ;
$sql2 = " delete from dataorder where offlineappid=' $delete ' " ;
if ( $this -> db -> exec ( $sql ) > 0 )
{
if ( $this -> db -> exec ( $sql2 ) > 0 )
{
$this -> messenger -> addMessage ( '成功删除了数据服务记录,并且删除了关联的申请记录' );
$this -> _redirect ( " /admin/down/offline " );
}
else
{
$this -> messenger -> addMessage ( '成功删除了数据服务记录,但并未找到关联的申请记录' );
$this -> _redirect ( " /admin/down/offline " );
}
}
else {
$this -> messenger -> addMessage ( '删除失败' );
$this -> _redirect ( " /admin/down/offline " );
}
2011-09-29 02:28:27 +00:00
} //删除服务记录
else if ( $down ) {
2011-09-20 03:57:39 +00:00
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$sql = " select * from offlineapp where ts_approved is not null and pdflink is not null order by ts_created desc " ;
$rows = $this -> db -> fetchAll ( $sql );
2013-08-19 08:17:50 +00:00
2011-09-20 03:57:39 +00:00
foreach ( $rows as $row ){
2013-08-19 08:17:50 +00:00
$content .= '"' . $row [ 'username' ] . '","' . $row [ 'unit' ] . '","' . $row [ 'phone' ] . '","' . $row [ 'address' ] . '","' . $row [ 'postcode' ] . '","' . str_replace ( " \" " , " ' " , $row [ 'project' ]) . '","' . str_replace ( " \" " , " ' " , $row [ 'datalist' ]) . '","' . $row [ 'email' ] . '",' . $row [ 'ts_created' ] . " \r \n " ;
2011-09-20 03:57:39 +00:00
}
2013-08-16 09:59:59 +00:00
$output = new Output ( $this -> db );
2013-08-19 08:17:50 +00:00
$output -> Download ( " offlineapp.csv " , $content , " string " );
2011-09-29 02:28:27 +00:00
} //下载离线服务记录
else if ( $update ) {
2011-09-20 03:57:39 +00:00
$sql = ' select o . id as oid , o . userid , o . username as un , u . email as uemail , o . email , u . realname as rn , u . id as uid from offlineapp o
right join users u on o . email = u . email
where o . userid is null and o . ts_approved is not null and o . email is not null ' ;
$re = $this -> db -> query ( $sql );
$row = $re -> fetchAll ();
$s = 0 ;
foreach ( $row as $k => $v )
{
if ( empty ( $v [ 'userid' ]))
{
$sql = " update offlineapp set userid=' { $v [ 'uid' ] } ' where id=' { $v [ 'oid' ] } ' " ;
if ( $this -> db -> exec ( $sql )) $s ++ ;
}
}
$this -> messenger -> addMessage ( '提示信息:已有 ' . $s . ' 条记录被更改' );
$this -> _redirect ( '/admin/down/offline' );
} //同步用户账户与离线申请记录
2011-09-29 02:28:27 +00:00
2011-09-20 03:57:39 +00:00
else if ( $show ){
$sql = " select * from offlineapp where id=' $show ' " ;
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
$this -> view -> infos = $row ;
$this -> _helper -> viewRenderer ( 'offlineshow' );
} //查看单条记录
2011-09-29 02:28:27 +00:00
2011-09-29 02:24:47 +00:00
else if ( $emaillist )
{
$sql = " select distinct(t.*) from
(
2014-06-11 08:04:43 +00:00
select u . email from dataorder d left join users u on d . userid = u . id where ( d . status = 0 or d . status = 5 ) and d . uuid in ( select uuid from $submd )
2011-09-29 02:24:47 +00:00
union
2014-06-11 08:04:43 +00:00
select o . email from offlineapp o where o . userid is null and o . email is not null and o . id in ( select offlineappid from dataorder where uuid in ( select uuid from $submd ))
2011-09-29 02:24:47 +00:00
) as t " ;
$re = $this -> db -> query ( $sql );
$rows = $re -> fetchAll ();
$filecontent = " " ;
foreach ( $rows as $row ){
$filecontent .= $row [ 'email' ] . " \r \n " ;
}
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$this -> getResponse () -> setHeader ( 'Content-Type' , 'application/octet-stream' )
-> setHeader ( 'Content-Disposition' , 'attachment; filename="emails.txt"' )
-> setHeader ( 'Content-Length' , strlen ( $filecontent ))
-> setHeader ( 'Content-Type' , 'application/force-download' )
-> setHeader ( 'Content-Type' , 'application/download' )
-> setHeader ( 'Content-Description' , 'File Transfer' )
-> setHeader ( 'Content-Transfer-Encoding' , 'binary' )
-> setHeader ( 'Expires' , 0 )
-> setHeader ( 'Cache-Control' , 'must-revalidate, post-check=0, pre-check=0' )
-> setHeader ( 'Pragma' , 'public' )
-> setBody ( $filecontent );
2013-01-29 08:05:45 +00:00
} //下载邮箱地址列表
else if ( $monthreport ) { //月份上报服务记录, 输出格式为excel
require_once 'PHPExcel.php' ;
$objExcel = new PHPExcel ();
$objWriter = new PHPExcel_Writer_Excel5 ( $objExcel );
//设置文档基本属性
$objProps = $objExcel -> getProperties ();
$objProps -> setCreator ( " westdc " );
$objProps -> setLastModifiedBy ( " westdc " );
$objProps -> setTitle ( " Office XLS Test Document " );
$objProps -> setSubject ( " Office XLS Test Document, Demo " );
$objProps -> setDescription ( " Test document, generated by PHPExcel. " );
$objProps -> setKeywords ( " office excel PHPExcel " );
$objProps -> setCategory ( " Test " );
//设置当前的sheet索引, 用于后续的内容操作。
//一般只有在使用多个sheet的时候才需要显示调用。
//缺省情况下, PHPExcel会自动创建第一个sheet被设置SheetIndex=0
$objExcel -> setActiveSheetIndex ( 0 );
$objActSheet = $objExcel -> getActiveSheet ();
//设置当前活动sheet的名称
$objActSheet -> setTitle ( '离线服务记录' );
2014-01-07 12:33:15 +00:00
if ( date ( 'm' ) == 1 )
{
$ym = ( date ( 'Y' ) - 1 ) . '-12-1' ;
} else {
$ym = date ( 'Y-' ) . ( date ( 'm' ) - 1 ) . '-1' ;
}
2013-01-29 08:05:45 +00:00
$sql = " select o.username,o.unit,o.phone,o.address,o.postcode,o.project,regexp_replace(o.datalist,' \ (.+?MB \ )','','g') as datalist,date(o.ts_approved) as date,o.email,o.project_id,o.project_type,o.project_title,sum(m.filesize) as filesize
from offlineapp o left join dataorder d on o . id = d . offlineappid left join metadata m on d . uuid = m . uuid
2014-01-07 12:33:15 +00:00
where o . ts_approved >= '".$ym."' and o . ts_approved < '".date(' Y - m ')."-1' and o . pdflink is not null and o . ts_approved is not null and d . status = 5 group by o . id order by o . ts_approved
2013-01-29 08:05:45 +00:00
" ;
2012-12-08 14:41:10 +00:00
$re = $this -> db -> query ( $sql );
2013-01-29 08:05:45 +00:00
$rows = $re -> fetchAll ();
foreach ( $rows as $i => $row )
{
$k = $i + 1 ;
$objActSheet -> setCellValue ( 'A' . $k , $row [ 'username' ]);
$objActSheet -> setCellValue ( 'B' . $k , $row [ 'unit' ]);
$objActSheet -> setCellValue ( 'C' . $k , $row [ 'phone' ]);
$objActSheet -> setCellValue ( 'D' . $k , $row [ 'address' ]);
$objActSheet -> setCellValue ( 'E' . $k , $row [ 'postcode' ]);
$objActSheet -> setCellValue ( 'F' . $k , $row [ 'project' ]);
$objActSheet -> setCellValue ( 'G' . $k , $row [ 'datalist' ]);
$objActSheet -> setCellValue ( 'H' . $k , $row [ 'date' ]);
$objActSheet -> setCellValue ( 'I' . $k , $row [ 'email' ]);
$objActSheet -> setCellValue ( 'J' . $k , $row [ 'project_id' ]);
$objActSheet -> setCellValue ( 'K' . $k , $row [ 'project_type' ]);
$objActSheet -> setCellValue ( 'L' . $k , $row [ 'project_title' ]);
$objActSheet -> setCellValue ( 'M' . $k , $row [ 'filesize' ]);
}
//添加一个新的worksheet
$objExcel -> createSheet ();
$objExcel -> setActiveSheetIndex ( 1 );
$objActSheet = $objExcel -> getActiveSheet ();
$objActSheet -> setTitle ( '在线服务记录' );
$sql = " select o.username,o.unit,o.phone,o.address,o.postcode,o.project,date(o.ts_created) as date,o.email,o.project_id,o.project_type,o.project_title,m.filesize,m.title
from onlineapp o left join dataorder d on o . id = d . onlineappid left join metadata m on d . uuid = m . uuid
2014-01-07 12:37:27 +00:00
where o . ts_created >= '".$ym."' and o . ts_created < '".date(' Y - m ')."-1' and d . status = 0 order by o . ts_created
2013-01-29 08:05:45 +00:00
" ;
2012-12-08 14:41:10 +00:00
$re = $this -> db -> query ( $sql );
2013-01-29 08:05:45 +00:00
$rows = $re -> fetchAll ();
foreach ( $rows as $i => $row )
{
$k = $i + 1 ;
$objActSheet -> setCellValue ( 'A' . $k , $row [ 'username' ]);
$objActSheet -> setCellValue ( 'B' . $k , $row [ 'unit' ]);
$objActSheet -> setCellValue ( 'C' . $k , $row [ 'phone' ]);
$objActSheet -> setCellValue ( 'D' . $k , $row [ 'address' ]);
$objActSheet -> setCellValue ( 'E' . $k , $row [ 'postcode' ]);
$objActSheet -> setCellValue ( 'F' . $k , $row [ 'project' ]);
$objActSheet -> setCellValue ( 'G' . $k , $row [ 'title' ]);
$objActSheet -> setCellValue ( 'H' . $k , $row [ 'date' ]);
$objActSheet -> setCellValue ( 'I' . $k , $row [ 'email' ]);
$objActSheet -> setCellValue ( 'J' . $k , $row [ 'project_id' ]);
$objActSheet -> setCellValue ( 'K' . $k , $row [ 'project_type' ]);
$objActSheet -> setCellValue ( 'L' . $k , $row [ 'project_title' ]);
$objActSheet -> setCellValue ( 'M' . $k , $row [ 'filesize' ]);
}
/* $objExcel -> createSheet ();
$objExcel -> setActiveSheetIndex ( 2 );
$objActSheet = $objExcel -> getActiveSheet ();
$objActSheet -> setTitle ( '服务总量' );
$sql = " select sum(m.filesize)/1024 from dataorder o left join metadata m on o.uuid=m.uuid
where o . ts_created >= '2012-07-01' and o . ts_created < '2012-8-1' and o . status = 0 " ;
2012-12-08 14:41:10 +00:00
$re = $this -> db -> query ( $sql );
2013-01-29 08:05:45 +00:00
$rows = $re -> fetchAll (); */
//输出内容
$outputFileName = " westdc- " . date ( 'Ym' ) . " .xls " ;
2012-12-08 14:41:10 +00:00
$this -> _helper -> layout -> disableLayout ();
2013-01-29 08:05:45 +00:00
$this -> _helper -> viewRenderer -> setNoRender ();
//到浏览器
header ( " Content-Type: application/force-download " );
header ( " Content-Type: application/octet-stream " );
header ( " Content-Type: application/download " );
header ( 'Content-Disposition:inline;filename="' . $outputFileName . '"' );
header ( " Content-Transfer-Encoding: binary " );
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " );
header ( " Cache-Control: must-revalidate, post-check=0, pre-check=0 " );
header ( " Pragma: no-cache " );
$objWriter -> save ( 'php://output' );
2012-12-08 14:41:10 +00:00
/* $this -> getResponse () -> setHeader ( 'Content-Type' , 'application/octet-stream' )
-> setHeader ( 'Content-Disposition' , 'attachment; filename="westdc.xls"' )
//->setHeader('Content-Length', strlen($filecontent))
-> setHeader ( 'Content-Type' , 'application/force-download' )
-> setHeader ( 'Content-Type' , 'application/download' )
-> setHeader ( 'Content-Description' , 'File Transfer' )
-> setHeader ( 'Content-Transfer-Encoding' , 'binary' )
-> setHeader ( 'Expires' , 0 )
-> setHeader ( 'Cache-Control' , 'must-revalidate, post-check=0, pre-check=0' )
-> setHeader ( 'Pragma' , 'public' )
2013-01-29 08:05:45 +00:00
-> setBody ( $objWriter -> save ( 'php://output' )); */
2012-12-08 14:41:10 +00:00
}
2011-09-29 02:28:27 +00:00
2012-01-09 09:10:07 +00:00
$this -> view -> page = $this -> _getParam ( 'page' );
2013-11-05 07:57:17 +00:00
$application = new Application ();
$this -> view -> q = $application -> keyword = $this -> _getParam ( 'q' );
$application -> filter = $this -> _getParam ( 'filter' );
view :: addPaginator ( $application -> passed (), $this , 20 );
return true ;
2011-09-20 03:57:39 +00:00
}
//在线数据下载情况, 仅针对onlineapp表, 自2011-9-8开始记录。
function onlineAction ()
{
$show = ( int ) $this -> _getParam ( 'show' );
$delete = ( int ) $this -> _getParam ( 'delete' );
2014-06-11 07:35:28 +00:00
$submd = $this -> view -> config -> sub -> metadata ;
2011-09-20 03:57:39 +00:00
if ( empty ( $show ) && empty ( $delete ))
{
$select = $this -> db -> select ();
2012-06-06 09:45:19 +00:00
$select -> from ( 'onlineapp as o' , array ( 'id' , 'userid' , 'unit' , 'username' , 'ts_created' , 'project' , 'project_id' , 'project_type' , 'project_title' ))
2014-06-11 07:45:06 +00:00
-> join ( $submd . ' as m' , 'o.uuid = m.uuid' , array ( 'title' , 'uuid' ))
2011-12-21 03:47:33 +00:00
-> where ( 'o.id in (select distinct(onlineappid) from dataorder)' )
2011-09-20 03:57:39 +00:00
-> order ( 'o.id desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $this -> db -> fetchAll ( $select ));
$this -> view -> count = $count ;
} //列表
elseif ( $delete )
{
2012-01-09 09:10:07 +00:00
try {
2011-12-09 03:08:02 +00:00
$sql = " delete from onlineapp where id=? " ;
2012-01-09 09:10:07 +00:00
$this -> db -> query ( $sql , array ( $delete ));
$sql = " delete from dataorder where onlineappid=? " ;
2011-12-09 03:08:02 +00:00
$this -> db -> query ( $sql , array ( $delete ));
2011-09-20 03:57:39 +00:00
$this -> messenger -> addMessage ( '该记录已删除' );
} catch ( Exception $e ) {
$this -> messenger -> addMessage ( $e -> getMessage ());
}
$this -> _redirect ( " /admin/down/online/ " );
} //删除
elseif ( $show )
{
$sql = " select o.*,u.username as uname,u.id as uid,m.title,m.uuid
from onlineapp as o
left join users as u on u . id = o . userid
2014-06-11 07:45:06 +00:00
left join $submd as m on o . uuid = m . uuid
2011-09-20 03:57:39 +00:00
where o . id = ? " ;
$result = $this -> db -> query ( $sql , $show );
$rows = $result -> fetch ();
$this -> view -> infos = $rows ;
$this -> _helper -> viewRenderer ( 'onlineshow' );
} //查看详细
} //onlineAction
function userAction ()
{
$show = ( int ) $this -> _getParam ( 'show' );
$search = $this -> _getParam ( 'search' );
$keyword = $this -> view -> keyword = $this -> _getParam ( 'keyword' );
2014-06-11 07:42:44 +00:00
$submd = $this -> view -> config -> sub -> metadata ;
2011-09-20 03:57:39 +00:00
if ( empty ( $show ))
{
$select = $this -> db -> select ();
$select -> from ( 'dataorder as o' , 'count(o.id) as num' )
-> join ( 'users as u' , 'u.id = o.userid' , array ( 'realname' , 'id as uid' , 'unit' ))
-> where ( 'o.status=0 or o.status=5' )
2014-06-11 07:43:18 +00:00
-> where ( " o.uuid in (select uuid from $submd ) " )
2011-09-20 03:57:39 +00:00
-> where ( 'o.userid = u.id' );
if ( ! empty ( $search ) && ! empty ( $keyword ))
{
$select -> Where ( 'u.realname like ? or u.unit like ? ' , '%' . $keyword . '%' );
$this -> view -> title = '“' . $keyword . '”的搜索结果 :' ;
}
$select -> group ( 'uid' )
-> group ( 'realname' )
-> group ( 'unit' )
-> order ( 'num desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $this -> db -> fetchAll ( $select ));
$this -> view -> count = $count ;
} //列表
elseif ( $show )
{
$select = $this -> db -> select ();
$select -> from ( 'dataorder as o' , array ( 'id' , 'ts_created' , 'userid' , 'offlineappid' , 'onlineappid' ))
2014-06-11 07:42:44 +00:00
-> joinLeft ( $submd . ' as m' , 'o.uuid = m.uuid' , array ( 'title' , 'uuid' , 'filesize' ))
2011-09-20 03:57:39 +00:00
-> joinLeft ( 'users as u' , 'u.id=o.userid' , array ( 'realname as username' ))
-> where ( 'o.userid = ?' , $show )
-> where ( 'o.status=0 or o.status=5' )
-> order ( 'o.id desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
$sql = " select username,realname from users where id=' $show ' " ;
$re = $this -> db -> query ( $sql );
$t = $re -> fetch ();
$this -> view -> infos = $t ;
$this -> _helper -> viewRenderer ( 'showuser' );
} //查看单个用户的下载记录
} //userAction 用户下载情况
function dataAction ()
{
$show = $this -> _getParam ( 'show' );
$search = $this -> _getParam ( 'search' );
$keyword = $this -> view -> keyword = $this -> _getParam ( 'keyword' );
2014-06-11 07:35:28 +00:00
$submd = $this -> view -> config -> sub -> metadata ;
2011-09-20 03:57:39 +00:00
if ( empty ( $show ))
{
$select = $this -> db -> select ();
$select -> from ( 'dataorder as o' , 'count(o.id) as num' )
2014-06-11 07:35:28 +00:00
-> join ( $submd . ' as m' , 'o.uuid = m.uuid' , array ( 'title' , 'uuid' ))
2014-06-11 07:36:20 +00:00
-> where ( 'o.uuid = m.uuid and (o.status=0 or o.status=5)' );
2011-09-20 03:57:39 +00:00
if ( ! empty ( $search ) && ! empty ( $keyword ))
{
$select -> Where ( 'm.title like ? or m.title_en like ?' , '%' . $keyword . '%' );
$this -> view -> title = '“' . $keyword . '”的搜索结果 :' ;
}
$select -> group ( 'm.title' )
-> group ( 'm.uuid' )
-> order ( 'num desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( 20 );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $this -> db -> fetchAll ( $select ));
$this -> view -> count = $count ;
} //数据下载情况列表
elseif ( $show )
{
$select = $this -> db -> select ();
2011-09-20 04:00:25 +00:00
$select -> from ( 'dataorder as o' , array ( 'ts_created' , 'ts_created' , 'offlineappid' , 'onlineappid' ))
2014-06-11 07:35:28 +00:00
-> join ( $submd . ' as m' , 'o.uuid = m.uuid' , array ( 'title' , 'uuid' ))
2011-09-20 03:57:39 +00:00
-> join ( 'users as u' , 'o.userid=u.id' , array ( 'id as userid' , 'username' , 'realname' ))
-> where ( 'm.uuid = ? and (o.status=0 or o.status=5)' , $show )
-> order ( 'o.id desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
2014-06-11 07:35:28 +00:00
$sql = " select title,uuid from $submd where uuid=' $show ' " ;
2011-09-20 03:57:39 +00:00
$re = $this -> db -> query ( $sql );
$t = $re -> fetch ();
$this -> view -> infos = $t ;
$this -> _helper -> viewRenderer ( 'showdata' );
} //查看单个数据下载情况
} //dataAction 数据下载情况
2012-09-11 07:06:33 +00:00
/*
* sendmailAction () 邮件通知
*
* Param uuid $uuid //元数据UUID
*
* return Ajax - response
*
* 传入元数据UUID, 判断是否为当前用户的数据, 如果是, 即可向已经下载过该数据的所有用户发送电子邮件
*/
public function sendmailAction ()
{
$uuid = $this -> _getParam ( 'uuid' );
$ac = $this -> _getParam ( 'ac' );
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$uid = $user -> id ;
}
if ( empty ( $uuid ) || empty ( $uid ))
{
$this -> view -> error = " 参数错误 " ;
return true ;
}
$sql = " SELECT m.title,m.description,g.id as gid,mds.status as mdstatus,m.uuid FROM normalmetadata m
LEFT JOIN geonetworkmetadata g on m . uuid = g . uuid
LEFT JOIN mdstatus mds ON m . uuid = mds . uuid
WHERE m . uuid = ? " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ( array ( $uuid ));
$metadata = $sth -> fetch ();
if ( empty ( $metadata [ 'uuid' ]))
{
$this -> view -> error = " 数据不存在或者您可能没有该数据的管理权限 " ;
return true ;
}
$this -> view -> metadata = $metadata ;
2012-11-02 14:35:13 +00:00
$sql = " select distinct u.email
2012-09-11 07:06:33 +00:00
from dataorder d
LEFT JOIN users u on d . userid = u . id
2014-01-29 04:39:36 +00:00
WHERE u . email IS NOT NULL and d . status in ( 0 , 5 ) and d . ts_approved is not null
2012-09-11 07:06:33 +00:00
AND d . uuid = ?
GROUP BY u . email " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ( array ( $uuid ));
$mails = $sth -> fetchAll ();
$this -> view -> mailinfo = count ( $mails );
if ( $ac == " send " )
{
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$title = $this -> _getParam ( 'title' );
$body = $this -> _getParam ( 'body' );
foreach ( $mails as $k => $v )
{
$mail = new WestdcMailer ( $this -> view -> config -> smtp );
2014-06-11 07:35:28 +00:00
$mail -> setFrom ( $this -> view -> config -> service -> email , '数据服务组' );
2012-09-11 07:06:33 +00:00
$mail -> setBodyText ( $body );
$mail -> setSubject ( $title );
$mail -> addTo ( $v [ 'email' ]);
//$mail->addTo("Jack@sookon.com");
if ( $mail -> send ())
{
echo $v [ 'email' ] . " ...发送成功!<br /> " ;
} else {
echo $v [ 'email' ] . " ...发送失败!<br /> " ;
}
}
}
} //sendmailAction() 为下载过某数据的用户发送邮件
2011-09-20 03:57:39 +00:00
function searchAction ()
{
$search = $this -> _getParam ( 'search' );
$keyword = $this -> view -> keyword = $this -> _getParam ( 'keyword' );
$select = $this -> db -> select ();
if ( ! empty ( $search ) && ! empty ( $keyword ))
{
$select -> from ( 'onlineapp as o' , array ( 'id' , 'userid' , 'unit' , 'username' , 'ts_created' , 'project' ))
-> Where ( 'o.username like ? ' , '%' . $keyword . '%' )
-> orWhere ( 'o.unit like ? ' , '%' . $keyword . '%' )
-> orWhere ( 'o.project like ? ' , '%' . $keyword . '%' )
-> orWhere ( 'm.title like ? ' , '%' . $keyword . '%' )
-> join ( 'metadata as m' , 'o.uuid = m.uuid' , array ( 'title' , 'uuid' ))
-> order ( 'o.id desc' );
$paginator = Zend_Paginator :: factory ( $select );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( 15 );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$this -> _helper -> viewRenderer ( 'online' );
$count = count ( $this -> db -> fetchAll ( $select ));
$this -> view -> count = $count ;
$this -> view -> title = '搜索结果 :' ;
}
else {
$this -> _redirect ( " /admin/down/online " );
}
} //searchAction 搜索
function updateAction (){
/* $select = $this -> db -> select ();
$select -> from ( 'offlineapp as o' , array ( 'username as un' , 'email' ))
-> join ( 'users as u' , 'u.email=o.email' )
-> where ( 'o.userid is null and o.ts_approved is not null and o.email is not null' ); */
$sql = ' select o . id as oid , o . userid , o . username as un , u . email as uemail , o . email , u . realname as rn , u . id as uid from offlineapp o
right join users u on o . email = u . email
where o . userid is null and o . ts_approved is not null and o . email is not null ' ;
$re = $this -> db -> query ( $sql );
$row = $re -> fetchAll ();
foreach ( $row as $k => $v )
{
if ( empty ( $v [ 'userid' ]))
{
$sql = " update offlineapp set userid=' { $v [ 'uid' ] } ' where id=' { $v [ 'oid' ] } ' " ;
$row [ $k ][ 'sql' ] = $sql ;
//$re=$this->db-exec($sql);
}
}
$paginator = Zend_Paginator :: factory ( $row );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( 20 );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $row );
$this -> view -> count = $count ;
$this -> _helper -> viewRenderer ( 'update' );
}
function fixofflineAction (){
$fix = $this -> _getParam ( 'fix' );
$orders = $this -> _getParam ( 'orders' );
$nouserid = $this -> _getParam ( 'nouserid' );
if ( $fix )
{
if ( ! empty ( $orders ))
{
$num = 0 ;
foreach ( $orders as $k => $v )
{
$ex = split ( ',' , $v );
$sql = " update offlineapp set userid=' { $ex [ 0 ] } ' where id=' { $ex [ 1 ] } ' " ;
if ( $this -> db -> exec ( $sql ))
$num ++ ;
}
$this -> messenger -> addMessage ( '已经匹配了' . $num . '条记录' );
$this -> _redirect ( " /admin/down/fixoffline " );
}
else {
$this -> messenger -> addMessage ( '请选择要匹配的条目' );
$this -> _redirect ( " /admin/down/fixoffline " );
}
}
if ( $nouserid )
{
$sql = " select * from offlineapp where userid is null " ;
$re = $this -> db -> query ( $sql );
$row = $re -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $row );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( 20 );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $row );
$this -> view -> count = $count ;
$this -> _helper -> viewRenderer ( 'nouserid' );
}
else {
$sql = " select o.id as oid,o.username as un,o.unit as uu,u.username,u.realname rn,u.unit,u.id as uid
from offlineapp o right join users u on trim ( o . username ) = trim ( u . realname )
where o . userid is null and o . id > 0
order by o . id " ;
$re = $this -> db -> query ( $sql );
$row = $re -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $row );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( 20 );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
$this -> view -> paginator = $paginator ;
$count = count ( $row );
$this -> view -> count = $count ;
}
2012-08-27 01:54:38 +00:00
} //fixofflineAction 用户匹配
public function jsonexit ( $data ){
$this -> getResponse () -> setHeader ( 'Content-Type' , 'application/json' ) -> appendBody ( json_encode ( $data , JSON_NUMERIC_CHECK ));
return true ;
2012-12-08 14:41:10 +00:00
}
2011-09-20 03:57:39 +00:00
}