添加了用户上传申请表的功能

This commit is contained in:
Li Jianxuan 2013-09-05 01:54:50 +00:00
parent b062e86e04
commit 3f4c945dbf
4 changed files with 241 additions and 112 deletions

View File

@ -2,7 +2,6 @@
use \data\DataService; use \data\DataService;
use Helpers\View as view; use Helpers\View as view;
use Order\Order; use Order\Order;
use Order\listener\OrderListener;
class DataController extends Zend_Controller_Action class DataController extends Zend_Controller_Action
{ {
@ -825,8 +824,6 @@ class DataController extends Zend_Controller_Action
} }
$order = new Order(); $order = new Order();
$orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener);
$status = $order->addOrder($uuid,json_encode($data['data']['site'],JSON_NUMERIC_CHECK)); $status = $order->addOrder($uuid,json_encode($data['data']['site'],JSON_NUMERIC_CHECK));
if($status !== true) if($status !== true)
{ {
@ -1633,8 +1630,6 @@ class DataController extends Zend_Controller_Action
//存在历史遗留问题,原来的数据并不能保证唯一 //存在历史遗留问题,原来的数据并不能保证唯一
$order = new Order(); $order = new Order();
$orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener);
$state = $order->addOrder($uuid); $state = $order->addOrder($uuid);
if($state !== true) if($state !== true)
@ -1667,8 +1662,6 @@ class DataController extends Zend_Controller_Action
} }
$order = new Order(); $order = new Order();
$orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener);
$state = $order->addOrder($uuid,$selections); $state = $order->addOrder($uuid,$selections);
if($state !== true) if($state !== true)
@ -1775,10 +1768,6 @@ class DataController extends Zend_Controller_Action
if (@$formData['save']) { if (@$formData['save']) {
$orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener);
$order->setPdfData($rows); $order->setPdfData($rows);
$s = $order->SaveOrder($formData); $s = $order->SaveOrder($formData);
@ -1797,12 +1786,7 @@ class DataController extends Zend_Controller_Action
} elseif ($formData['submit']) { } elseif ($formData['submit']) {
//提交 //提交
//生成PDF //生成PDF
$orderListener = new OrderListener();
@$order->events()->attachAggregate($orderListener);
$order->setPdfData($rows); $order->setPdfData($rows);
$s = $order->SubmitOrder($formData); $s = $order->SubmitOrder($formData);
if($s !== true) if($s !== true)
@ -1811,81 +1795,125 @@ class DataController extends Zend_Controller_Action
return true; return true;
} }
//跳转到/data/order并提示帮助信息告知用户已经发送EMAIL $this->view->msg = view::Msg('alert-success','提示信息:您的离线申请已经提交,请<a href="/data/order/ac/offline3">在线上传PDF的签字版PDF文件</a>。',0);
$this->view->msg = view::Msg('alert-success',"提示信息您的离线申请已经提交系统已经发送一封邮件给您请打印出申请表、签字后扫描为pdf并email给数据中心服务组仍可以采用邮寄方式具体信息请参考邮件说明。",0);
if (empty($ac)) $ac='offline3'; if (empty($ac)) $ac='offline3';
//$this->_redirect('/data/order');
} }
} else { } else {
$sql="select u.*,o.* from users u left join offlineapp o on u.id=o.userid where u.id=? ORDER BY o.id DESC"; $sql="select u.*,o.* from users u left join offlineapp o on u.id=o.userid where u.id=? ORDER BY o.id DESC";
$row=$this->db->fetchRow($sql,array($userid)); $row=$this->db->fetchRow($sql,array($userid));
/*$row=$ut->fetchRow('id='.$userid);
$formData['email']=$row->email;
$formData['phone']=$row->phone;
$formData['realname']=$row->realname;
$formData['unit']=$row->unit;
$formData['address']=$row->address;
$formData['purpose']=$row->project;
$formData['id']=$row->id;*/
$this->view->formData = $row; $this->view->formData = $row;
} }
} else } else{
$this->view->msg=view::Msg('alert-error',"错误:您还没有提交任何离线申请的数据,或您的数据申请已经提交(等待处理过程中)!",0); $this->view->msg=view::Msg('alert-error',"错误:您还没有提交任何离线申请的数据,或您的数据申请已经提交(等待处理过程中)!",0);
} }
return true;
}//pdf
if($ac == "commitapplicationform")
{
$this->_helper->viewRenderer->setNoRender();
$offlineappid = $this->_getParam('offlineappid');
if(!is_numeric($offlineappid) || $offlineappid < 1)
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
$order = new Order();
$status = $order->commitApplicationForm($offlineappid);
if( $status !== true)
{
$this->jsonexit(array("error"=>$status));
}else{
$this->jsonexit(array('success'=>1));
}
return true;
}
//index //index
$this->view->ac = $ac;
$this->_helper->viewRenderer('order');
if ($ac=='' || $ac=='online') if ($ac=='' || $ac=='online')
{ {
$status='d.status=0 and d.ts_approved is not null';
$this->view->tabID='order-online'; $this->view->tabID='order-online';
} else if ($ac=='offline1') { } else if ($ac=='offline1') {
$status='d.status in (1)';
$this->view->tabID='order-offline1'; $this->view->tabID='order-offline1';
} else if ($ac=='offline2') { } else if ($ac=='offline2') {
$status='d.status in (2)';
$this->view->tabID='order-offline2'; $this->view->tabID='order-offline2';
} else if ($ac=='offline3') { } else if ($ac=='offline3') {
$status='d.status in (3,4)';
$this->view->tabID='order-offline3'; $this->view->tabID='order-offline3';
} else if ($ac=='offline4') { } else if ($ac=='offline4') {
$status='d.status in (5)';
$this->view->tabID='order-offline4'; $this->view->tabID='order-offline4';
} }
//显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载 //显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载
$sql="select d.*,m.title,m.datatype from dataorder d left join metadata m on d.uuid=m.uuid $sql="select d.*,m.title,m.datatype from dataorder d left join metadata m on d.uuid=m.uuid
where $status and d.userid=? order by d.status,d.ts_created desc"; where d.userid=? order by d.status,d.ts_created desc";
$rows=$this->db->fetchAll($sql,array($userid)); $rows=$this->db->fetchAll($sql,array($userid));
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page')); $showorders = array();
$paginator->setItemCountPerPage(10); $counts = array(
$paginator->setView($this->view); 'onlineapp' => 0,
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); 'offline1' => 0,
$this->view->paginator=$paginator; 'offline2' => 0,
/*foreach($rows as $row) { 'offline3' => 0,
switch ($row['status']){ 'offline4' => 0
);
if(count($rows) > 0) {
foreach($rows as $k=>$v)
{
switch($v['status']) {
case 0: case 0:
$dataorder0[]=$row; $counts['onlineapp'] ++;
break; break;
case 1: case 1:
$dataorder1[]=$row; $counts['offline1'] ++;
break; break;
case 2: case 2:
$counts['offline2'] ++;
break;
case 3: case 3:
$counts['offline3'] ++;
break;
case 4: case 4:
$dataorder2[]=$row; $counts['offline3'] ++;
break; break;
case 5: case 5:
$dataorder3[]=$row; $counts['offline4'] ++;
break; break;
default: }
switch($ac){
default :
if($v['status'] == 0 && !empty($v['ts_approved']))$showorders[] = $rows[$k];
break;
case 'online' :
if($v['status'] == 0 && !empty($v['ts_approved']))$showorders[] = $rows[$k];
break;
case 'offline1' :
if($v['status'] == 1) $showorders[] = $rows[$k];
break;
case 'offline2' :
if($v['status'] == 2) $showorders[] = $rows[$k];
break;
case 'offline3' :
if($v['status'] == 3 || $v['status'] == 4) $showorders[] = $rows[$k];
$this->view->offlineappid = $v['offlineappid'];
$this->view->applicationform = $v['applicationform'];
$this->view->offlineappstatus = $v['status'];
break;
case 'offline4' :
if($v['status'] == 5) $showorders[] = $rows[$k];
break; break;
} }
} }
@$this->view->dataorder0=$dataorder0; }
@$this->view->dataorder1=$dataorder1;
@$this->view->dataorder2=$dataorder2; $this->view->counts = $counts;
@$this->view->dataorder3=$dataorder3;*/ view::addPaginator($showorders,$this,10);
} }
/* /*

View File

@ -1,4 +1,10 @@
<?php <?php
use Helpers\View;
use Helpers\dbh;
use Files\Files;
use Files\Output;
use Files\Listener\FileListener;
class ServiceController extends Zend_Controller_Action class ServiceController extends Zend_Controller_Action
{ {
private $limit=10; private $limit=10;
@ -1550,6 +1556,56 @@ class ServiceController extends Zend_Controller_Action
} }
//上传申请表
function uploadapplicationformAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('offlineappid');
if(empty($id))
{
$this->jsonexit(array('error'=>"参数错误"));
return true;
}
$uid = view::User('id');
if(!is_numeric($uid))
{
$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{
$sql = "UPDATE dataorder SET applicationform='{$statu['file']}' WHERE offlineappid=$id AND userid=$uid AND status IN (3,4)";
if($this->db->exec($sql))
{
$this->jsonexit(array("success"=>1));
return true;
}else{
$this->jsonexit(array('error'=>"申请表上传失败".$sql));
return true;
}
}
}
//下载申请表
public function downloadapplicationformAction()
{
}
/* /*
输出验证码 输出验证码
*/ */
@ -1728,4 +1784,9 @@ class ServiceController extends Zend_Controller_Action
Zend_Matrixcode::render('qrcode', $code_params, 'image', $renderer_params); Zend_Matrixcode::render('qrcode', $code_params, 'image', $renderer_params);
} }
public function jsonexit($data){
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
return true;
}
} }

View File

@ -0,0 +1,18 @@
<div id="upload-form" class="modal hide fade" tabindex="-1" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">申请表上传</h3>
</div>
<div class="modal-body">
<form id="application-form">
<div id="fsUploadProgress">允许上传20M以内的 PDF 文件</div>
<input type="file" name="Filedata" id="file_upload" />
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">取消上传</button>
</div>
</div>
<script>
_this.SessionID = '<?php echo session_id(); ?>';
</script>

View File

@ -3,11 +3,10 @@
$this->headTitle($this->config->title->data); $this->headTitle($this->config->title->data);
$this->headTitle('离线申请'); $this->headTitle('离线申请');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>'); $this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>'); $this->theme->AppendPlus($this,'colorbox');
$this->breadcrumb('离线申请'); $this->theme->AppendPlus($this,'uploadify');
$this->breadcrumb()->setSeparator(' > '); $this->theme->AppendModel($this,'offlineapp-uploader');
$this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
?> ?>
<?= $this->render('breadcrumbs.phtml') ?> <?= $this->render('breadcrumbs.phtml') ?>
<div class="row"> <div class="row">
@ -28,11 +27,11 @@ $this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
?> ?>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li id="Nav-order-offline1"><a href="/data/order/ac/offline1">未提交的数据</a></li> <li id="Nav-order-offline1"><a href="/data/order/ac/offline1">未提交的数据<?= !empty($this->counts['offline1']) ? '<span class="badge badge-info">'.$this->counts['offline1'].'</span>':'' ?></a></li>
<li id="Nav-order-offline2"><a href="/data/order/ac/offline2">正在提交的数据</a></li> <li id="Nav-order-offline2"><a href="/data/order/ac/offline2">正在提交的数据<?= !empty($this->counts['offline2']) ? '<span class="badge badge-info">'.$this->counts['offline2'].'</span>':'' ?></a></li>
<li id="Nav-order-offline3"><a href="/data/order/ac/offline3">等待通过的申请</a></li> <li id="Nav-order-offline3"><a href="/data/order/ac/offline3">等待通过的申请<?= !empty($this->counts['offline3']) ? '<span class="badge badge-info">'.$this->counts['offline3'].'</span>':'' ?></a></li>
<li id="Nav-order-offline4"><a href="/data/order/ac/offline4">已通过的申请</a></li> <li id="Nav-order-offline4"><a href="/data/order/ac/offline4">已通过的申请<?= !empty($this->counts['offline4']) ? '<span class="badge badge-info">'.$this->counts['offline4'].'</span>':'' ?></a></li>
<li id="Nav-order-online"><a href="/data/order/ac/online">在线数据</a></li> <li id="Nav-order-online"><a href="/data/order/ac/online">在线数据<?= !empty($this->counts['onlineapp']) ? '<span class="badge badge-info">'.$this->counts['onlineapp'].'</span>':'' ?></a></li>
</ul> </ul>
<!-- content --> <!-- content -->
<?php if (!empty($this->paginator)) : ?> <?php if (!empty($this->paginator)) : ?>
@ -47,7 +46,17 @@ echo '<a class="btn btn-primary" href="/data/order/apply/all">提交所有数据
} elseif ($this->tabID=='order-offline2') { } elseif ($this->tabID=='order-offline2') {
echo '<a class="btn btn-primary" href="/data/order/pdf/1">提交离线申请</a>'; echo '<a class="btn btn-primary" href="/data/order/pdf/1">提交离线申请</a>';
} elseif ($this->tabID=='order-offline3') { } elseif ($this->tabID=='order-offline3') {
echo '申请状态'; if(count($this->paginator))
{
if(empty($this->applicationform))
echo '<a class="btn btn-primary" href="javascript:void(0);" onclick="upload.showUploadForm('.$this->offlineappid.');">上传申请表</a>';
else
if($this->offlineappstatus == 3)
{
echo '<a class="btn btn-warning" href="javascript:void(0);" onclick="upload.showUploadForm('.$this->offlineappid.');">重新上传申请表</a> ';
echo '<a class="btn btn-success" href="javascript:void(0);" onclick="commit('.$this->offlineappid.');">确认申请</a>';
}
}
} elseif ($this->tabID=='order-offline4') { } elseif ($this->tabID=='order-offline4') {
echo '通过时间'; echo '通过时间';
} }
@ -72,7 +81,10 @@ if ($this->tabID=='order-offline1') {
echo ' <a class="btn" href="/data/order/cancel/'.$order['id'].'">取消</a>'; echo ' <a class="btn" href="/data/order/cancel/'.$order['id'].'">取消</a>';
break; break;
case 3: case 3:
echo "请打印签字扫描为pdf并email或邮寄"; if(!empty($order['applicationform']))
echo '<span class="label label-success">申请表已上传</span>';
else
echo '<span class="label label-warning">请上传申请表</span>';
break; break;
default: default:
break; break;
@ -80,10 +92,16 @@ if ($this->tabID=='order-offline1') {
} elseif ($this->tabID=='order-offline3') { } elseif ($this->tabID=='order-offline3') {
switch($order['status']) { switch($order['status']) {
case 3: case 3:
echo "请打印签字扫描为pdf并email或邮寄"; if(!empty($order['applicationform']))
echo '<span class="label label-success">申请表已上传</span>';
else
echo '<span class="label label-warning">请上传申请表</span>';
break; break;
case 4: case 4:
echo "已收到申请,请等待审批。日期:";echo date('Y-m-d',strtotime($order['ts_received'])); if(!empty($order['applicationform']))
{ echo "已收到申请,请等待审批。日期:";echo date('Y-m-d',strtotime($order['ts_received']));}
else
echo '<span class="label label-warning">请上传申请表</span>';
break; break;
case 5: case 5:
echo "已通过申请,请查收邮件"; echo "已通过申请,请查收邮件";
@ -105,3 +123,7 @@ if ($this->tabID=='order-offline1') {
</div><!--/span--> </div><!--/span-->
</div><!--/row--> </div><!--/row-->
<script>$('#Nav-<?= $this->tabID?>').addClass("active");</script> <script>$('#Nav-<?= $this->tabID?>').addClass("active");</script>
<script>
var _this = {};
</script>
<?= $this->partial('data/offlineapp-uploaderform.phtml'); ?>