Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. class Facturen extends Database {
  4. public $klant = '';
  5. public $id = '';
  6. public $titel = '';
  7. public $factuurnummer = '';
  8. public $verloopdatum = '';
  9. public $totaal = '';
  10. public $betaald = 'Nee';
  11.  
  12. function Facturen() {
  13.  
  14. }
  15.  
  16. function get($limit = false, $sort = "id", $sortascdesc = "ASC") {
  17. $query = "SELECT * FROM facturen ORDER BY ". $sort ." ". $sortascdesc;
  18.  
  19. if($limit) {
  20. $query .= " LIMIT ". $limit;
  21. }
  22.  
  23. $result = mysql_query($query);
  24.  
  25. $facturen = array();
  26.  
  27. while($row = mysql_fetch_array($result)) {
  28. $factuur = new Facturen();
  29. $factuur = $factuur->getByID($row['id']);
  30.  
  31. $facturen[] = $factuur;
  32. }
  33.  
  34. return $facturen;
  35. }
  36.  
  37. function getByKlant($klant, $limit = false, $sort = "id", $sortascdesc = "ASC") {
  38. $query = "SELECT id FROM facturen WHERE klant='". $klant ."' ORDER BY ". $sort ." ". $sortascdesc;
  39.  
  40. if($limit) {
  41. $query .= " LIMIT ". $limit;
  42. }
  43.  
  44. $result = mysql_query($query);
  45.  
  46. $facturen = array();
  47.  
  48. while($row = mysql_fetch_array($result)) {
  49. $factuur = new Facturen();
  50. $factuur = $factuur->getByID($row['id']);
  51.  
  52. $facturen[] = $factuur;
  53. }
  54.  
  55. return $facturen;
  56. }
  57.  
  58. function getByID($id) {
  59. $result = mysql_fetch_array(mysql_query("SELECT * FROM facturen WHERE id='". $id ."'"));
  60.  
  61. $klanten = new Klant();
  62.  
  63. $this->klant = $klanten->getByID($result['klant']);
  64.  
  65. $this->id = $result['id'];
  66. $this->totaal = $result['totaalprijs'];
  67. $this->titel = $result['titel'];
  68. $this->factuurnummer = $result['factuurnummer'];
  69. $this->verloopdatum = $result['verloopdatum'];
  70. $this->betaald = $result['betaald'];
  71.  
  72. return $this;
  73. }
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement