company.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class company extends DooModel {
  4. public $cid;
  5. public $companyname;
  6. public $nature;
  7. public $local;
  8. public $fax;
  9. public $webservice;
  10. public $department;
  11. public $staffid;
  12. public $district;
  13. public $position;
  14. public $office;
  15. public $address;
  16. public $ride;
  17. public $landmarks;
  18. public $stay;
  19. public $tag;
  20. public $_table = 'CLD_company';
  21. public $_primarykey = 'cid';
  22. public $_fields = array ('cid', 'companyname','staffid', 'district' ,'nature' ,'local', 'fax', 'webservice','department' , 'position', 'office', 'address', 'ride','landmarks','stay' );
  23. public function getCompanyByCid($cid){
  24. return $this->find ( array ('where' => "cid= '".$cid."'", 'asArray' => TRUE ) );
  25. }
  26. public function getCompanyByStaff($sid){
  27. return $this->find ( array ('where' => "staffid= '".$sid."'", 'asArray' => TRUE ) );
  28. }
  29. public function getCompanyByDistrict($sid,$district,$isadmin,$page,$size,$tagSQL){
  30. if($page==1)
  31. $page=0;
  32. if($isadmin!=0){
  33. if($tagSQL){
  34. $sql = "select b.cid,a.tag,b.companyname,b.nature,b.local,b.fax,b.webservice,b.position,b.office,b.address,b.ride,b.district,b.landmarks from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where ".$district." limit ".$page.','.$size ;
  35. $query = Doo::db ()->query ( $sql );
  36. $result = $query->fetchAll ();
  37. return $result;
  38. }else
  39. return $this->find ( array ('select'=>'companyname,cid,local,district,staffid,nature','where'=>$district,'limit'=>$page.','.$size, 'asArray' => TRUE ) );
  40. }else//"staffid= '".$sid."' and ".
  41. return $this->find ( array ('select'=>'companyname,cid,local,district,staffid,nature','where' => $district, 'limit'=>$page.','.$size, 'asArray' => TRUE ) );
  42. }
  43. public function getCompanyByCompanyname($name){
  44. return $this->find ( array ('where' => "companyname= '".$name."'", 'asArray' => TRUE ) );
  45. }
  46. public function searchCompany($search){
  47. return $this->find ( array ('where' => "companyname like '%".$search."%'", 'asArray' => TRUE ) );
  48. }
  49. public function getCompanyByName($name,$local){
  50. return $this->getOne ( array ('where' => "companyname= '".$name."' and local='".$local."'", 'asArray' => TRUE ) );
  51. }
  52. }
  53. ?>