client_staff.php 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class client_staff extends DooModel {
  4. public $csid;
  5. public $sid;
  6. public $cid;
  7. public $_table = 'CLD_client_staff';
  8. public $_primarykey = 'csid';
  9. public $_fields = array('csid', 'sid', 'cid');
  10. function getClientByCid($cid){
  11. $sql = "select * from " . $this->_table . " as a left join CLD_staff as b on (a.sid=b.sid) where a.cid= '".$cid."' " ;
  12. $query = Doo::db ()->query ( $sql );
  13. $result = $query->fetch ();
  14. return $result;
  15. }
  16. function getClientByStaff($condition="",$limit,$staffid="",$sid,$search,$tooltip,$cateid,$tagSQL=''){
  17. if (!empty($staffid)){
  18. //$staffid="and a.sid= '".$staffid."'";
  19. //a.cid,a.gender,a.clientname,a.keynum,a.companyid,a.companyname,a.updatetime,a.servicetime,a.department,a.position left join CLD_tag_client as c on (b.cid=c.client) " . $this->_table . " as a ".$staffid."
  20. $sql = "select b.landmarks,b.stay,b.local,b.ride,b.address,b.district,b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename,b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client and c.sid=".$staffid.") where 1 ".$condition." ".$limit ;
  21. }else{//
  22. if(strlen($condition)==1||empty($condition))
  23. $sql = "select b.landmarks,b.stay,b.local,b.ride,b.address,b.district,b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename,b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_client as b ".$limit ;
  24. else//left join CLD_tag_client as c on (a.cid=c.client) where 1 ".$condition."
  25. $sql = "select a.landmarks,a.stay,a.local,a.ride,a.address,a.district,a.office,a.fax,a.email,a.qq,a.phone,a.mark,a.nicename,a.cid,a.gender,a.clientname,a.keynum,a.companyid,a.companyname,a.updatetime,a.servicetime,a.department,a.position,a.priority,a.telephone from CLD_client as a left join CLD_tag_client as c on (c.client=a.cid and c.sid=".$sid." ) where 1 ".$condition." ".$limit ;
  26. }
  27. if(!empty($search))
  28. $sql = "select b.landmarks,b.stay,b.local,b.ride,b.address,b.district,b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename,b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_client as b where 1 ".$condition." ".$limit ;
  29. if(!empty($tooltip)){
  30. $condition=str_replace("a.","c.",$condition);
  31. if ($tagSQL)
  32. $sql = "select b.address,b.district, b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename, b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (a.cid=b.cid ) where a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition." ".$limit ;
  33. else
  34. $sql = "select b.address,b.district, b.office,b.fax,b.email,b.qq,b.phone,b.mark,b.nicename, b.cid,b.gender,b.clientname,b.keynum,b.companyid,b.companyname,b.updatetime,b.servicetime,b.department,b.position,b.priority,b.telephone from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition." ".$limit ;
  35. }
  36. // echo $sql;//die;
  37. $query = Doo::db ()->query ( $sql );
  38. $result = $query->fetchAll ();
  39. Doo::loadClass ( 'XDeode' );
  40. $XDeode = new XDeode ( 5 );
  41. foreach ($result as $key=>$value){
  42. $result[$key]['companyidKey'] = $XDeode->encode( $value['companyid'] );
  43. }
  44. return $result;
  45. }
  46. public function synClient($sid ,$district){
  47. $sql="select b.cid,b.sid,a.district from CLD_client as a right join " . $this->_table . " as b on (b.cid=a.cid and b.sid !=".$sid." ) where a.district LIKE '".$district."%' ";
  48. $query = Doo::db ()->query ( $sql );
  49. $result = $query->fetchAll ();
  50. return $result;
  51. }
  52. public function getProject(){
  53. return $this->find ( array ('asc' => 'pid', 'asArray' => TRUE ) );
  54. }
  55. public function getProjectByIdList($projectid){
  56. return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) );
  57. }
  58. }
  59. ?>