You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

societe.class.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
  3. require_once(DOL_DOCUMENT_ROOT."/photocopies/class/phcp.class.php");
  4. class CSociete extends Societe {
  5. function fetch($id){
  6. $r = parent::fetch($id);
  7. $this->phcps = array();
  8. $sql = "SELECT";
  9. $sql.= " t.rowid";
  10. $sql.= " FROM ".MAIN_DB_PREFIX."phcp as t";
  11. $sql.= " WHERE t.fk_societe = ".$this->id;
  12. dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
  13. $resql=$this->db->query($sql);
  14. if ($resql){
  15. if ($num = $this->db->num_rows($resql)){
  16. $i = 0;
  17. while ($i < $num){
  18. $obj = $this->db->fetch_object($resql);
  19. if ($obj){
  20. $phcp = new Phcp($this->db);
  21. $phcp->fetch($obj->rowid);
  22. $this->phcps[]= $phcp;
  23. }
  24. $i++;
  25. }
  26. }
  27. }
  28. return $r;
  29. }
  30. function all($sortfield = "s.nom", $sortorder = "asc"){
  31. global $conf, $langs;
  32. $sql = "SELECT";
  33. $sql.= " s.rowid";
  34. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  35. $sql.= " ORDER BY ".$sortfield." ".$sortorder;
  36. $list = array();
  37. dol_syslog(get_class($this)."::all sql=".$sql, LOG_DEBUG);
  38. $resql=$this->db->query($sql);
  39. if ($resql){
  40. if ($num = $this->db->num_rows($resql)){
  41. $i = 0;
  42. while ($i < $num){
  43. $obj = $this->db->fetch_object($resql);
  44. if ($obj){
  45. $societe = new CSociete($this->db);
  46. $societe->fetch($obj->rowid);
  47. $list[]= $societe;
  48. }
  49. $i++;
  50. }
  51. }
  52. }
  53. return $list;
  54. }
  55. }
  56. ?>