client_staff.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. return $result;
  40. }
  41. public function synClient($sid ,$district){
  42. $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."%' ";
  43. $query = Doo::db ()->query ( $sql );
  44. $result = $query->fetchAll ();
  45. return $result;
  46. }
  47. public function getProject(){
  48. return $this->find ( array ('asc' => 'pid', 'asArray' => TRUE ) );
  49. }
  50. public function getProjectByIdList($projectid){
  51. return $this->find ( array ('where' => "pid= '".$projectid."'", 'asArray' => TRUE ) );
  52. }
  53. }
  54. ?>