call.inc.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 Notes from Call
  42. * @param int $reminderID ID of the Call-reminder, default: -1 (=> automatically add a Call)
  43. *
  44. * @return void
  45. *
  46. */
  47. public static function addCall($userID, $callDate, $callerTelNr, $labelID, $callNotes, $reminderID = -1) { // if reminder == -1 auto create one ?
  48. global $db;
  49. if($reminderID == -1) {
  50. Reminder::addReminder($userID, date("Y-m-d H:i:s", strtotime("+30 minutes")));
  51. $reminderID = Reminder::getLastReminder()->getID();
  52. }
  53. $db->insertQuery("INSERT INTO `calls`(`call_date`, `caller_telnr`, `label_id`, `notes`, `reminder_id`) VALUES ('" . $callDate . "', '" . $callerTelNr . "', " . $labelID . ", '" . $callNotes . "', " . $reminderID . ");");
  54. }
  55. /**
  56. * Get Call-Array by Label-ID
  57. *
  58. * @param int $labelID ID of Call-Label
  59. *
  60. * @return Array(Call) Array with selected Calls
  61. *
  62. */
  63. public static function getCallsByLabelID($labelID) {
  64. global $db;
  65. $calls = $db->selectQuery("SELECT * FROM `calls` WHERE `label_id` = " . $labelID . ";");
  66. $return = array();
  67. foreach($calls as $call) {
  68. $return[] = new Call($call->id, $call->call_date, $call->caller_telnr, $call->label_id, $call->notes, $call->reminder_id);
  69. }
  70. return $return;
  71. }
  72. }
  73. ?>