AuthenticationController.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class AuthenticationController extends DooController {
  6. function getAuthentication(){
  7. $key = $this->get_args('key')? $this->get_args('key') :"";
  8. if (!empty($key)){
  9. Doo::loadModel ( 'longle' );
  10. $longle = new longle ();
  11. Doo::loadModel('staff');
  12. $staff=new staff();
  13. Doo::loadModel('client');
  14. $client=new client();
  15. //status=3 or status=4 or status=5
  16. $longleInfo=$longle->getOne(array ('where' => "key_num= '".$key."' and (status=3 or status=4 or status=5 or status=9 or status=10)",'asArray' => TRUE));
  17. if (empty($longleInfo)){
  18. echo json_encode(array('list'=>array()));die;
  19. }
  20. $clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
  21. $staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
  22. $productCount=explode('+', $longleInfo['product']);
  23. $list['product']=strtr($longleInfo['product'],"+"," ");
  24. $list['productCount']=count($productCount);
  25. $list['key_num']=$key;
  26. $list['telephone']=$staffInfo['telephone'];
  27. $list['username']=$staffInfo['category'].$staffInfo['username'];
  28. $list['qq']=$staffInfo['qq'];
  29. $count=mb_strlen($longleInfo['client'],'UTF8');
  30. if ($clientInfo['gender']=='男')
  31. $k=' 先生';
  32. else
  33. $k=' 女士';
  34. if ($count<=2)
  35. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."*".$k;
  36. elseif ($count>2&&$count<=4)
  37. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."**".$k;
  38. else
  39. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."***".$k;
  40. echo json_encode(array('list'=>$list));die;
  41. }
  42. echo json_encode(array('list'=>array()));die;
  43. }
  44. function getAuthenticationBySerial(){
  45. $key = $this->get_args('SerialNumber')? $this->get_args('SerialNumber') :"";
  46. if (!empty($key)){
  47. Doo::loadModel ( 'longle' );
  48. $longle = new longle ();
  49. Doo::loadModel('staff');
  50. $staff=new staff();
  51. Doo::loadModel('client');
  52. $client=new client();
  53. $longleInfo=$longle->getOne(array ('where' => "SerialNumber= '".$key."' and (status=3 or status=4 or status=5 or status=9 or status=10)",'asArray' => TRUE));
  54. //echo "SerialNumber= '".$key."' and (status=3 or status=4 or status=5 or status=10)";
  55. if (empty($longleInfo)){
  56. echo json_encode(array('list'=>array()));die;
  57. }
  58. $clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
  59. $staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
  60. $productCount=explode('+', $longleInfo['product']);
  61. $list['product']=strtr($longleInfo['product'],"+"," ");
  62. $list['productCount']=count($productCount);
  63. $list['key_num']=$longleInfo['key_num'];
  64. $list['telephone']=$staffInfo['telephone'];
  65. $list['username']=$staffInfo['category'].$staffInfo['username'];
  66. $list['qq']=$staffInfo['qq'];
  67. if ($clientInfo['gender']=='男')
  68. $k=' 先生';
  69. else
  70. $k=' 女士';
  71. $list['client']=$longleInfo['client'].$k;
  72. $list['SerialNumber']=$this->half_replace($longleInfo['SerialNumber']);
  73. echo json_encode(array('list'=>$list));die;
  74. }
  75. echo json_encode(array('list'=>array()));die;
  76. }
  77. function half_replace($str){
  78. $len = strlen($str)/2;
  79. return substr_replace($str,str_repeat('*',$len),ceil(($len)/2),$len);
  80. }
  81. /**
  82. * 获取get或者POST值
  83. * @param string $name 属性名称
  84. * @return fixed 值
  85. */
  86. function get_args($name) {
  87. if (isset ( $_GET [$name] )) {
  88. if (is_array ( $_GET [$name] ))
  89. return $_GET [$name];
  90. else {
  91. //return addslashes ( $_GET [$name] );
  92. return $_GET [$name] ;
  93. }
  94. } elseif (isset ( $_POST [$name] )) {
  95. if (is_array ( $_POST [$name] ))
  96. return $_POST [$name];
  97. else {
  98. //return addslashes ( $_POST [$name] );
  99. return $_POST [$name];
  100. }
  101. } else {
  102. return false;
  103. }
  104. }
  105. }
  106. ?>