diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 3574031f..cc7591c5 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -961,327 +961,19 @@ class DataController extends Zend_Controller_Action $mailtp=new EmailText($this->db,'online-download-en',$data); $mail=new WestdcMailer($this->view->config->smtp); $mail->setBodyText($mailtp->getBody()); $mail->setFrom($this->view->config->service->email,'CARD data service'); $mail->addTo($user->email); $mail->setSubject($mailtp->getSubject()); @$mail->send(); $sql="update onlineapp set has_send_mail=true where id=?"; $sth=$this->db->prepare($sql); $sth->execute(array($onlineappid)); } } - /* - * 离线申请(可以包括在线数据),在无数据参数时,则显示已有列表 - */ - function orderAction() - { - $this->view->pageID = "account-dataorder"; - $ac = $this->_request->getParam('ac'); - - $uuid = $this->_request->getParam('uuid'); - - $del = $this->_request->getParam('del'); - $apply = $this->_request->getParam('apply'); - $finish = $this->_request->getParam('finish'); - $cancel = $this->_request->getParam('cancel'); - $wsn = $this->_request->getParam('wsn'); - $pdf = $this->_request->getParam('pdf'); - $selections = $this->_request->getParam('data'); - - //if (empty($uuid)) $this->_redirect('/data'); - $userid = view::User('id'); - - //添加到数据篮 - if ($uuid) - { - //存在历史遗留问题,原来的数据并不能保证唯一 - - $order = new Order(); - $state = $order->addOrder($uuid); - - if($state !== true) - { - if(!is_array($state)) - { - $this->view->msg = view::Msg('alert-error',$state); - }else{ - $service_type = $order->serviceTypeTest($state['service_type']); - if($service_type !== false) - { - view::Post($this,$service_type,$state['service_url']."?href=".urlencode(view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid); - }else{ - $this->view->msg = view::Msg('alert-error',"Error: could not add this dataset."); - } - } - }else{ - $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application."); - } - - if (empty($ac)) $ac='offline1'; - - } - - elseif ($selections) - { - if(empty($uuid)) - { - $this->view->msg = view::Msg('alert-error',"Error: Wrong parameter."); - } - - $order = new Order(); - $state = $order->addOrder($uuid,$selections); - - if($state !== true) - { - $this->view->msg = view::Msg('alert-error',$state); - }else{ - $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application."); - } - - if (empty($ac)) $ac='offline1'; - } - - //删除申请 - elseif ($del) { - $order = new Order(); - $state = $order->del($del); - if($state !== true) - { - $this->view->msg = view::Msg('alert-error',$state); - }else{ - $this->view->msg = view::Msg('alert-success',"The order is canceled."); - } - $this->_redirect('/data/order'); - } - - //提交申请 - elseif ($apply) { - if($apply == "all" || !is_numeric($apply)) - { - $apply = -1; - } - $order = new Order(); - $state = $order->apply($apply); - if($state !== true) - { - $this->view->msg = view::Msg('alert-error',$state); - }else{ - $this->view->msg = view::Msg('alert-success',"提交成功,您可以点击“提交离线申请”来生成PDF申请表"); - } - if (empty($ac)) $ac='offline2'; - } - - //完成 - elseif ($finish) { - if ($finish=='all') { - $sql=$this->db->quoteInto("update dataorder set ts_approved=now() where status=0 and userid=?",$userid); - $this->db->query($sql); - $sql="update ftpuser set datacount=0 where userid=?"; - $this->db->query($sql,array($userid)); - } else { - $sql="update dataorder set ts_approved=now() where status=0 and userid=? and id=?"; - $this->db->query($sql,array($userid,(int)$finish)); - $sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0"; - $this->db->query($sql,array($userid)); - } - } - - elseif($wsn) - { - $this->_helper->viewRenderer('order-wsn'); - - return true; - } - - elseif ($cancel) { - if ($cancel=='all') { - $sql=$this->db->quoteInto("update dataorder set ts_approved=now(),status=-1 where status=0 and userid=?",$userid); - $this->db->query($sql); - $sql="update ftpuser set datacount=0 where userid=?"; - $this->db->query($sql,array($userid)); - } else { - $sql="update dataorder set ts_approved=now(),status=-1 where status in (0,1,2) and userid=? and id=?"; - $this->db->query($sql,array($userid,(int)$cancel)); - $sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0"; - $this->db->query($sql,array($userid)); - } - if (empty($ac)) $ac='offline2'; - } - - //生成PDF离线申请文件 - elseif ($pdf) { - - //用户信息可以从SESSION中读取?离线申请信息 - //$sql="select * from users where id=?"; - $order = new Order(); - $rows = $order->getOrderItemForPdf(); - $this->view->projectType = $order->projectType; - - if ($rows) { - $this->_helper->viewRenderer('pdf'); - - $this->view->data2 = $rows; - - if ($this->_request->isPost()) { - - $this->view->formData = $formData = $this->_request->getPost(); - - $datalist=''; - foreach($rows as $i=>$row) - { - $datalist.=($i+1).". ".$row['title'].";"; - } - $formData['datalist'] = $datalist; - - if (@$formData['save']) { - - $order->setPdfData($rows); - - $s = $order->SaveOrder($formData); - - if($s !== true) - { - $this->view->error = view::Msg('alert-error',$s); - return true; - } - - //不能修改顺序 - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - return true; - } elseif ($formData['submit']) { - //生成PDF - $order->setPdfData($rows); - $s = $order->SubmitOrder($formData); - - if($s !== true) - { - $this->view->error = view::Msg('alert-error',$s); - return true; - } - - $this->view->msg = view::Msg('alert-success','提示信息:您的离线申请已经提交,请在线上传PDF的签字版PDF文件。',0); - if (empty($ac)) $ac='offline3'; - } - } else { - $sql="select u.* 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)); - $this->view->formData = $row; - } - } else{ - $this->view->msg=view::Msg('alert-error',"错误:您还没有提交任何离线申请的数据,或您的数据申请已经提交(等待处理过程中)!",0); - } - return true; - }//pdf - - if($ac == "commitapplicationform") - { - $offlineappid = $this->_getParam('offlineappid'); - - if(!is_numeric($offlineappid) || $offlineappid < 1) - { - view::Post($this,"参数错误",-1); - return true; - } - - $order = new Order(); - $status = $order->commitApplicationForm($offlineappid); - - if( $status !== true) - { - view::Post($this,$status,-1); - }else{ - view::Post($this,"申请已提交,请等待管理员接收并通过数据所有者审核",'/data/order/ac/offline3'); - } - - return true; - } - - //index - $this->view->ac = $ac; - $this->_helper->viewRenderer('order'); - if ($ac=='' || $ac=='online') - { - $this->view->tabID='order-online'; - } else if ($ac=='offline1') { - $this->view->tabID='order-offline1'; - } else if ($ac=='offline2') { - $this->view->tabID='order-offline2'; - } else if ($ac=='offline3') { - $this->view->tabID='order-offline3'; - } else if ($ac=='offline4') { - $this->view->tabID='order-offline4'; - } - //显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载 - $sql="select d.*,m.title,m.datatype,off.applicationform from dataorder d - left join metadata m on d.uuid=m.uuid - left join offlineapp off ON off.id = d.offlineappid - where d.userid=? order by d.status,d.ts_created desc"; - $rows=$this->db->fetchAll($sql,array($userid)); - - $showorders = array(); - $counts = array( - 'onlineapp' => 0, - 'offline1' => 0, - 'offline2' => 0, - 'offline3' => 0, - 'offline4' => 0 - ); - - if(count($rows) > 0) { - foreach($rows as $k=>$v) - { - switch($v['status']) { - case 0: - $counts['onlineapp'] ++; - break; - case 1: - $counts['offline1'] ++; - break; - case 2: - $counts['offline2'] ++; - break; - case 3: - $counts['offline3'] ++; - break; - case 4: - $counts['offline3'] ++; - break; - case 5: - $counts['offline4'] ++; - break; - } - 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]; - $this->view->offlineappid = $v['offlineappid']; - $this->view->applicationform = $v['applicationform']; - $this->view->offlineappstatus = $v['status']; - } - 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; - } - } - } - - $this->view->counts = $counts; - view::addPaginator($showorders,$this,10); - - } + /* * 离线申请(可以包括在线数据),在无数据参数时,则显示已有列表 */ function orderAction() { $this->view->pageID = "account-dataorder"; $ac = $this->_request->getParam('ac'); $uuid = $this->_request->getParam('uuid'); $del = $this->_request->getParam('del'); $apply = $this->_request->getParam('apply'); $finish = $this->_request->getParam('finish'); $cancel = $this->_request->getParam('cancel'); $wsn = $this->_request->getParam('wsn'); $pdf = $this->_request->getParam('pdf'); $selections = $this->_request->getParam('data'); //if (empty($uuid)) $this->_redirect('/data'); $userid = view::User('id'); //添加到数据篮 if ($uuid) { //存在历史遗留问题,原来的数据并不能保证唯一 $order = new Order(); $state = $order->addOrder($uuid); if($state !== true) { if(!is_array($state)) { $this->view->msg = view::Msg('alert-error',$state); }else{ $service_type = $order->serviceTypeTest($state['service_type']); if($service_type !== false) { view::Post($this,$service_type,$state['service_url']."?href=".urlencode(view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid); }else{ $this->view->msg = view::Msg('alert-error',"Error: could not add this dataset."); } } }else{ $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application."); } if (empty($ac)) $ac='offline1'; } elseif ($selections) { if(empty($uuid)) { $this->view->msg = view::Msg('alert-error',"Error: Wrong parameter."); } $order = new Order(); $state = $order->addOrder($uuid,$selections); if($state !== true) { $this->view->msg = view::Msg('alert-error',$state); }else{ $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application."); } if (empty($ac)) $ac='offline1'; } //删除申请 elseif ($del) { $order = new Order(); $state = $order->del($del); if($state !== true) { $this->view->msg = view::Msg('alert-error',$state); }else{ $this->view->msg = view::Msg('alert-success',"The order is canceled."); } $this->_redirect('/data/order'); } //提交申请 elseif ($apply) { if($apply == "all" || !is_numeric($apply)) { $apply = -1; } + $order = new Order(); $state = $order->apply($apply); if($state !== true) { $this->view->msg = view::Msg('alert-error',$state); }else{ $this->view->msg = view::Msg('alert-success',"Please click Submitting to generate your pdf Order."); } if (empty($ac)) $ac='offline2'; } //完成 elseif ($finish) { if ($finish=='all') { $sql=$this->db->quoteInto("update dataorder set ts_approved=now() where status=0 and userid=?",$userid); $this->db->query($sql); $sql="update ftpuser set datacount=0 where userid=?"; $this->db->query($sql,array($userid)); } else { $sql="update dataorder set ts_approved=now() where status=0 and userid=? and id=?"; $this->db->query($sql,array($userid,(int)$finish)); $sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0"; $this->db->query($sql,array($userid)); } } elseif($wsn){ $this->_helper->viewRenderer('order-wsn'); return true; } + elseif ($cancel) { if ($cancel=='all') { $sql=$this->db->quoteInto("update dataorder set ts_approved=now(),status=-1 where status=0 and userid=?",$userid); $this->db->query($sql); $sql="update ftpuser set datacount=0 where userid=?"; $this->db->query($sql,array($userid)); } else { $sql="update dataorder set ts_approved=now(),status=-1 where status in (0,1,2) and userid=? and id=?"; $this->db->query($sql,array($userid,(int)$cancel)); $sql="update ftpuser set datacount=datacount-1 where userid=? and datacount>0"; $this->db->query($sql,array($userid)); } if (empty($ac)) $ac='offline2'; } //生成PDF离线申请文件 elseif ($pdf) { //用户信息可以从SESSION中读取?离线申请信息 //$sql="select * from users where id=?"; $order = new Order(); $rows = $order->getOrderItemForPdf(); $this->view->projectType = $order->projectType; if ($rows) { $this->_helper->viewRenderer('pdf'); $this->view->data2 = $rows; if ($this->_request->isPost()) { $this->view->formData = $formData = $this->_request->getPost(); $datalist=''; foreach($rows as $i=>$row) { $datalist.=($i+1).". ".$row['title'].";"; } $formData['datalist'] = $datalist; if (@$formData['save']) { $order->setPdfData($rows); $s = $order->SaveOrder($formData); if($s !== true) { $this->view->error = view::Msg('alert-error',$s); return true; } //不能修改顺序 $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); return true; } elseif ($formData['submit']) { //生成PDF $order->setPdfData($rows); $s = $order->SubmitOrder($formData); if($s !== true) { $this->view->error = view::Msg('alert-error',$s); return true; } + $this->view->msg = view::Msg('alert-success','Message: Your offline order is submitted. Please upload your PDF with personal signature.',0); if (empty($ac)) $ac='offline3'; } } else { $sql="select u.* 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)); $this->view->formData = $row; } } else{ $this->view->msg=view::Msg('alert-error',"Error: You have not submitted any order, or you need to wait the auditing.",0); } return true; }//pdf if($ac == "commitapplicationform") { $offlineappid = $this->_getParam('offlineappid'); if(!is_numeric($offlineappid) || $offlineappid < 1) { view::Post($this,"Wrong parameter",-1); return true; } $order = new Order(); $status = $order->commitApplicationForm($offlineappid); if( $status !== true) { view::Post($this,$status,-1); }else{ view::Post($this,"Your order has submitted, please wait CARD receive your order.",'/data/order/ac/offline3'); } return true; } + //index $this->view->ac = $ac; $this->_helper->viewRenderer('order'); if ($ac=='' || $ac=='online') { $this->view->tabID='order-online'; } else if ($ac=='offline1') { $this->view->tabID='order-offline1'; } else if ($ac=='offline2') { $this->view->tabID='order-offline2'; } else if ($ac=='offline3') { $this->view->tabID='order-offline3'; } else if ($ac=='offline4') { $this->view->tabID='order-offline4'; } + //显示已经申请的数据,包括已经提交的申请和未提交的申请,还有已经处理完成的申请,正在进行的在线数据下载 $sql="select d.*,m.title,m.datatype,off.applicationform from dataorder d right join en.metadata m on d.uuid=m.uuid left join offlineapp off ON off.id = d.offlineappid where d.userid=? order by d.status,d.ts_created desc"; $rows=$this->db->fetchAll($sql,array($userid)); $showorders = array(); $counts = array( 'onlineapp' => 0, 'offline1' => 0, 'offline2' => 0, 'offline3' => 0, 'offline4' => 0 ); if(count($rows) > 0) { foreach($rows as $k=>$v) { switch($v['status']) { case 0: $counts['onlineapp'] ++; break; case 1: $counts['offline1'] ++; break; case 2: $counts['offline2'] ++; break; case 3: $counts['offline3'] ++; break; case 4: $counts['offline3'] ++; break; case 5: $counts['offline4'] ++; break; } + 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]; $this->view->offlineappid = $v['offlineappid']; $this->view->applicationform = $v['applicationform']; $this->view->offlineappstatus = $v['status']; + } 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; } } } $this->view->counts = $counts; view::addPaginator($showorders,$this,10); } /* * 查看数据缩略图 */ function thumbAction() { $page=(int)$this->_request->getParam('page'); if (empty($page)) $page=1; $offset=$this->limit*($page-1); $state=$this->db->query("select count(*) from en.normalmetadata"); $row=$state->fetchAll(); $sum=$row[0]['count']; $select=$this->db->select(); $select->from('en.normalmetadata as m','m.*') ->order('m.title desc')->limitPage($page,9); $this->view->metadata = $this->db->fetchAll($select); $this->view->page=new Pagination($sum,$page,$this->limit); } diff --git a/application/default/views/scripts/account/edit.phtml b/application/default/views/scripts/account/edit.phtml index c37d8411..792f815f 100755 --- a/application/default/views/scripts/account/edit.phtml +++ b/application/default/views/scripts/account/edit.phtml @@ -1,6 +1,6 @@ headTitle($this->config->title->site); - $this->headTitle('我的账户'); + $this->headTitle('My account'); $this->headTitle()->setSeparator(' - '); ?>
tabID=='order-offline1') { - echo '放入订单 - 移除'; + echo 'put into order + remove'; } elseif ($this->tabID=='order-offline2') { switch($order['status']) { case 2: if(empty($order['applicationform'])) - echo "请生成pdf并上传".' 移除'; + echo "Please scan the pdf and upload".' remove'; else - echo 'PDF已上传,请确认订单'; + echo 'You have uploaded the PDF, please confirm the order'; break; case 3: - echo '申请表已上传'; + echo 'PDF has been uploaded.'; break; default: break; @@ -107,18 +108,18 @@ if ($this->tabID=='order-offline1') { switch($order['status']) { case 3: if(!empty($order['applicationform'])) - echo '申请表已上传'; + echo 'PDF has been uploaded.'; else - echo '请上传申请表'; + echo 'Please upload the PDF'; break; case 4: if(!empty($order['applicationform'])) - { echo "已收到申请,请等待审批。日期:";echo date('Y-m-d',strtotime($order['ts_received']));} + { echo "The order has received, please wait the approvement. Date: ";echo date('Y-m-d',strtotime($order['ts_received']));} else - echo '请上传申请表'; + echo 'Please upload the PDF'; break; case 5: - echo "已通过申请,请查收邮件"; + echo "Approved, please check email"; break; default: break; diff --git a/application/models/RegisterForm.php b/application/models/RegisterForm.php index 09195618..e7ee082d 100755 --- a/application/models/RegisterForm.php +++ b/application/models/RegisterForm.php @@ -8,19 +8,19 @@ class RegisterForm extends Zend_Form $this->setName('Register'); $username = new Zend_Form_Element_Text('username'); - $username->setLabel('用户名')->setRequired(true) + $username->setLabel('Username')->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('StringLength',false,array(3,50)) ->addPrefixPath('Validator','validator/','validate') ->addValidator('NotInTable',false,array('username')); $password=new Zend_Form_Element_Password('password'); - $password->setLabel('密码') + $password->setLabel('Password') ->setRequired(true) - ->setDescription('长度在6到20位字符之间') + ->setDescription('Length in 6-20 chars') ->addValidator('StringLength',false,array(6,20)); $password_confirm=new Zend_Form_Element_Password('password_confirm'); - $password_confirm->setLabel('确认密码')->addPrefixPath('Validator','validator/','validate') + $password_confirm->setLabel('Confirm password')->addPrefixPath('Validator','validator/','validate') ->setRequired(true)->addValidator('Confirmation',false,array('password')); $email=new Zend_Form_Element_Text('email'); @@ -30,7 +30,7 @@ class RegisterForm extends Zend_Form ->addValidator('NotEmpty') ->addValidator('EmailAddress'); $email_repeat=new Zend_Form_Element_Text('email_repeat'); - $email_repeat->setLabel('确认E-Mail') + $email_repeat->setLabel('Confirm E-Mail') ->setRequired(true) ->addPrefixPath('Validator','validator/','validate') ->addValidator('NotInTable',false,array('email')) @@ -38,21 +38,21 @@ class RegisterForm extends Zend_Form $realname=new Zend_Form_Element_Text('realname'); - $realname->setLabel('真实姓名')->setRequired(false); + $realname->setLabel('Real name')->setRequired(false); $phone=new Zend_Form_Element_Text('phone'); - $phone->setLabel('电话')->setRequired(false); + $phone->setLabel('Phone')->setRequired(false); $unit=new Zend_Form_Element_Text('unit'); - $unit->setLabel('单位')->setRequired(false); + $unit->setLabel('Organization')->setRequired(false); $address=new Zend_Form_Element_Text('address'); - $address->setLabel('联系地址')->setRequired(false); + $address->setLabel('Address')->setRequired(false); $project=new Zend_Form_Element_Textarea('project'); - $project->setLabel('科研项目')->setRequired(false)->setAttrib('rows',4); + $project->setLabel('Fund')->setRequired(false)->setAttrib('rows',4); $id = new Zend_Form_Element_Hidden('id'); - $submit = new Zend_Form_Element_Submit('注册'); + $submit = new Zend_Form_Element_Submit('Register'); $submit->setAttrib('id', 'submitbutton'); $this->addElements(array($id, $username,$password,$password_confirm,$email,$email_repeat,$realname,$phone,$unit,$address,$project,$submit)); |