call.inc.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. class Call {
  3. private $id = NULL;
  4. private $callDate = NULL;
  5. private $callerTelNr = NULL;
  6. private $labelID = NULL;
  7. private $notes = NULL;
  8. private $reminderID = NULL;
  9. public function __construct($id, $callDate, $callerTelNr, $labelID, $notes, $reminderID) {
  10. $this->id = $id;
  11. $this->callDate = $callDate;
  12. $this->callerTelNr = $callerTelNr;
  13. $this->labelID = $labelID;
  14. $this->notes = $notes;
  15. $this->reminderID = $reminderID;
  16. }
  17. public function getID() {
  18. return $this->id;
  19. }
  20. public function getCallDate() {
  21. return $this->callDate;
  22. }
  23. public function getCallerTelNr() {
  24. return $this->callerTelNr;
  25. }
  26. public function getLabelID() {
  27. return $this->labelID;
  28. }
  29. public function getNotes() {
  30. return $this->notes;
  31. }
  32. public function getReminderID() {
  33. return $this->reminderID;
  34. }
  35. /**
  36. * Add a Call to DB
  37. *
  38. * @param string $callDate DateTime of Call
  39. * @param string $callerTelNr Telephone number of caller
  40. * @param int $labelID ID of Label
  41. * @param string $callNotes Taken notes of Call // TODO: check the english of this description
  42. * @param int $reminderID ID of the Call-reminder, default: -1 // TODO: -1 auto-adds reminder
  43. *
  44. * @return void
  45. *
  46. */
  47. public static function addCall($callDate, $callerTelNr, $labelID, $callNotes, $reminderID = -1) { // if reminder == -1 auto create one ?
  48. global $db;
  49. $db->insertQuery("INSERT INTO `calls`(`call_date`, `caller_telnr`, `label_id`, `notes`, `reminder_id`) VALUES ('" . $callDate . "', '" . $callerTelNr . "', " . $labelID . ", '" . $callNotes . "', " . $reminderID . ");");
  50. }
  51. /**
  52. * Get Call-Array by Label-ID
  53. *
  54. * @param int $labelID ID of Call-Label
  55. *
  56. * @return Array(Call) Array with selected Calls
  57. *
  58. */
  59. public static function getCallsByLabelID($labelID) {
  60. global $db;
  61. $calls = $db->selectQuery("SELECT * FROM `calls` WHERE `label_id` = " . $labelID . ";");
  62. $return = array();
  63. foreach($calls as $call) {
  64. $return[] = new Call($call->id, $call->call_date, $call->caller_telnr, $call->label_id, $call->notes, $call->reminder_id);
  65. }
  66. return $return;
  67. }
  68. }
  69. ?>